You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2012/07/12 16:07:58 UTC
svn commit: r1360688 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/
lucene/spatial/src/java/org/apache/lucene/spatial/prefix/
lucene/spatial/src/java/org/apache/lucene/spatial/vector/ ...
Author: dsmiley
Date: Thu Jul 12 14:07:57 2012
New Revision: 1360688
URL: http://svn.apache.org/viewvc?rev=1360688&view=rev
Log:
LUCENE-4192 remove spatial isPolyField and createField
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java
lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java
lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java Thu Jul 12 14:07:57 2012
@@ -59,11 +59,6 @@ public abstract class SpatialStrategy {
return ctx;
}
- /** Corresponds with Solr's FieldType.isPolyField(). */
- public boolean isPolyField() {
- return false;
- }
-
/**
* The name of the field or the prefix of them if there are multiple
* fields needed internally.
@@ -74,26 +69,19 @@ public abstract class SpatialStrategy {
}
/**
- * Corresponds with Solr's FieldType.createField().
- *
- * This may return a null field if it does not want to make anything.
- * This is reasonable behavior if 'ignoreIncompatibleGeometry=true' and the
- * geometry is incompatible
- */
- public abstract IndexableField createField(Shape shape);
-
- /**
- * Corresponds with Solr's FieldType.createFields().
+ * Returns the IndexableField(s) from the <code>shape</code> that are to be
+ * added to the {@link org.apache.lucene.document.Document}. These fields
+ * are expected to be marked as indexed and not stored.
* <p/>
- * Note: If you want to <i>store</i> the shape as a string for retrieval in search
- * results, you could add it like this:
+ * Note: If you want to <i>store</i> the shape as a string for retrieval in
+ * search results, you could add it like this:
* <pre>document.add(new StoredField(fieldName,ctx.toString(shape)));</pre>
- * The particular string representation used doesn't matter to the Strategy since it
- * doesn't use it.
+ * The particular string representation used doesn't matter to the Strategy
+ * since it doesn't use it.
+ *
+ * @return Not null nor will it have null elements.
*/
- public IndexableField[] createFields(Shape shape) {
- return new IndexableField[]{createField(shape)};
- }
+ public abstract IndexableField[] createIndexableFields(Shape shape);
/**
* The value source yields a number that is proportional to the distance between the query shape and indexed data.
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java Thu Jul 12 14:07:57 2012
@@ -62,7 +62,7 @@ public abstract class PrefixTreeStrategy
}
@Override
- public IndexableField createField(Shape shape) {
+ public IndexableField[] createIndexableFields(Shape shape) {
int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct);
List<Node> cells = grid.getNodes(shape, detailLevel, true);//true=intermediates cells
//If shape isn't a point, add a full-resolution center-point so that
@@ -77,7 +77,8 @@ public abstract class PrefixTreeStrategy
//TODO is CellTokenStream supposed to be re-used somehow? see Uwe's comments:
// http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
- return new Field(getFieldName(),new CellTokenStream(cells.iterator()), FIELD_TYPE);
+ Field field = new Field(getFieldName(), new CellTokenStream(cells.iterator()), FIELD_TYPE);
+ return new IndexableField[]{field};
}
/* Indexed, tokenized, not stored. */
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java Thu Jul 12 14:07:57 2012
@@ -77,12 +77,7 @@ public class TwoDoublesStrategy extends
}
@Override
- public boolean isPolyField() {
- return true;
- }
-
- @Override
- public IndexableField[] createFields(Shape shape) {
+ public IndexableField[] createIndexableFields(Shape shape) {
if( shape instanceof Point ) {
Point point = (Point)shape;
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
@@ -99,11 +94,6 @@ public class TwoDoublesStrategy extends
}
@Override
- public IndexableField createField(Shape shape) {
- throw new UnsupportedOperationException("Point is poly field");
- }
-
- @Override
public ValueSource makeValueSource(SpatialArgs args) {
Point p = args.getShape().getCenter();
return new DistanceValueSource(this, p, ctx.getDistCalc());
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java Thu Jul 12 14:07:57 2012
@@ -194,7 +194,7 @@ public class PortedSolr3Test extends Str
private Document newDoc(String id, Shape shape) {
Document doc = new Document();
doc.add(new StringField("id", id, Field.Store.YES));
- for (IndexableField f : strategy.createFields(shape)) {
+ for (IndexableField f : strategy.createIndexableFields(shape)) {
doc.add(f);
}
if (storeShape)
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java Thu Jul 12 14:07:57 2012
@@ -84,10 +84,8 @@ public abstract class StrategyTestCase e
document.add(new StringField("id", data.id, Field.Store.YES));
document.add(new StringField("name", data.name, Field.Store.YES));
Shape shape = ctx.readShape(data.shape);
- for (IndexableField f : strategy.createFields(shape)) {
- if( f != null ) { // null if incompatibleGeometry && ignore
- document.add(f);
- }
+ for (IndexableField f : strategy.createIndexableFields(shape)) {
+ document.add(f);
}
if (storeShape)
document.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java Thu Jul 12 14:07:57 2012
@@ -154,7 +154,7 @@ public class TestRecursivePrefixTreeStra
private Document newDoc(String id, Shape shape) {
Document doc = new Document();
doc.add(new StringField("id", id, Field.Store.YES));
- for (IndexableField f : strategy.createFields(shape)) {
+ for (IndexableField f : strategy.createIndexableFields(shape)) {
doc.add(f);
}
if (storeShape)
Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java?rev=1360688&r1=1360687&r2=1360688&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java Thu Jul 12 14:07:57 2012
@@ -25,6 +25,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
+import org.apache.lucene.index.IndexableField;
import org.apache.lucene.spatial.SpatialTestCase;
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
import org.apache.lucene.spatial.query.SpatialArgsParser;
@@ -45,7 +46,9 @@ public class TestTermQueryPrefixGridStra
Document losAngeles = new Document();
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
- losAngeles.add(prefixGridStrategy.createField(point));
+ for (IndexableField field : prefixGridStrategy.createIndexableFields(point)) {
+ losAngeles.add(field);
+ }
losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
addDocumentsAndCommit(Arrays.asList(losAngeles));