mirror of https://github.com/apache/lucene.git
LUCENE-4374 Rename TwoDoubles to PointVector
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1388900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a7979cf3f7
commit
e9cffebf96
|
@ -36,13 +36,13 @@ import java.util.Map;
|
|||
*/
|
||||
public class DistanceValueSource extends ValueSource {
|
||||
|
||||
private TwoDoublesStrategy strategy;
|
||||
private PointVectorStrategy strategy;
|
||||
private final Point from;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public DistanceValueSource(TwoDoublesStrategy strategy, Point from) {
|
||||
public DistanceValueSource(PointVectorStrategy strategy, Point from) {
|
||||
this.strategy = strategy;
|
||||
this.from = from;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.apache.lucene.spatial.util.ValueSourceFilter;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class TwoDoublesStrategy extends SpatialStrategy {
|
||||
public class PointVectorStrategy extends SpatialStrategy {
|
||||
|
||||
public static final String SUFFIX_X = "__x";
|
||||
public static final String SUFFIX_Y = "__y";
|
||||
|
@ -65,7 +65,7 @@ public class TwoDoublesStrategy extends SpatialStrategy {
|
|||
|
||||
public int precisionStep = 8; // same as solr default
|
||||
|
||||
public TwoDoublesStrategy(SpatialContext ctx, String fieldNamePrefix) {
|
||||
public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix) {
|
||||
super(ctx, fieldNamePrefix);
|
||||
this.fieldNameX = fieldNamePrefix+SUFFIX_X;
|
||||
this.fieldNameY = fieldNamePrefix+SUFFIX_Y;
|
|
@ -29,7 +29,7 @@ import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
|
|||
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
||||
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
||||
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||
import org.apache.lucene.spatial.vector.TwoDoublesStrategy;
|
||||
import org.apache.lucene.spatial.vector.PointVectorStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -54,7 +54,7 @@ public class DistanceStrategyTest extends StrategyTestCase {
|
|||
strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
|
||||
ctorArgs.add(new Object[]{new Param(strategy)});
|
||||
|
||||
strategy = new TwoDoublesStrategy(ctx, "twodoubles");
|
||||
strategy = new PointVectorStrategy(ctx, "pointvector");
|
||||
ctorArgs.add(new Object[]{new Param(strategy)});
|
||||
|
||||
strategy = new BBoxStrategy(ctx, "bbox");
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
|||
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||
import org.apache.lucene.spatial.query.SpatialArgs;
|
||||
import org.apache.lucene.spatial.query.SpatialOperation;
|
||||
import org.apache.lucene.spatial.vector.TwoDoublesStrategy;
|
||||
import org.apache.lucene.spatial.vector.PointVectorStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -68,7 +68,7 @@ public class PortedSolr3Test extends StrategyTestCase {
|
|||
strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
|
||||
ctorArgs.add(new Object[]{new Param(strategy)});
|
||||
|
||||
strategy = new TwoDoublesStrategy(ctx, "twodoubles");
|
||||
strategy = new PointVectorStrategy(ctx, "pointvector");
|
||||
ctorArgs.add(new Object[]{new Param(strategy)});
|
||||
|
||||
return ctorArgs;
|
||||
|
|
|
@ -30,14 +30,14 @@ import org.junit.Test;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestTwoDoublesStrategy extends StrategyTestCase {
|
||||
public class TestPointVectorStrategy extends StrategyTestCase {
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.ctx = SpatialContext.GEO;
|
||||
this.strategy = new TwoDoublesStrategy(ctx, getClass().getSimpleName());
|
||||
this.strategy = new PointVectorStrategy(ctx, getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
|
@ -561,7 +561,7 @@ org.apache.lucene.spatial.prefix.TestRecursivePrefixTreeStrategy=3329,4032,3419,
|
|||
org.apache.lucene.spatial.prefix.TestSpatialPrefixField=36,285,194,52,200,213,199,280,201,233,195,81,202,289,209,35,249,225
|
||||
org.apache.lucene.spatial.prefix.TestTermQueryPrefixGridStrategy=381,94,60,568,93,81,60,98,77,94,262,506,127,82,82,422,84,108
|
||||
org.apache.lucene.spatial.prefix.tree.SpatialPrefixTreeTest=239,52,50,201,72,41,59,56,58,50,75,243,50,58,75,285,66,59
|
||||
org.apache.lucene.spatial.vector.TestTwoDoublesStrategy=3717,3129,2399,2794,3135,3154,2813,3657,2500,3682,3621,3363,3430,2567,3481,2450,3663,3450
|
||||
org.apache.lucene.spatial.vector.TestPointVectorStrategy=3717,3129,2399,2794,3135,3154,2813,3657,2500,3682,3621,3363,3430,2567,3481,2450,3663,3450
|
||||
org.apache.lucene.store.TestBufferedIndexInput=1663,1777,1692,2301,2365,1896,2247,3707,1837,2544,1663,1823,2109,2229,1991,2361,1768,2452
|
||||
org.apache.lucene.store.TestByteArrayDataInput=29,52,205,56,65,39,49,23,57,40,48,38,29,33,56,29,56,31
|
||||
org.apache.lucene.store.TestCopyBytes=265,380,414,338,340,339,428,647,315,399,291,232,398,468,730,1265,514,323
|
||||
|
|
|
@ -17,14 +17,14 @@ package org.apache.solr.schema;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.spatial.vector.TwoDoublesStrategy;
|
||||
import org.apache.lucene.spatial.vector.PointVectorStrategy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class SpatialTwoDoublesFieldType extends AbstractSpatialFieldType<TwoDoublesStrategy> implements SchemaAware {
|
||||
public class SpatialPointVectorFieldType extends AbstractSpatialFieldType<PointVectorStrategy> implements SchemaAware {
|
||||
|
||||
protected String numberFieldName = "tdouble";//in example schema defaults to non-zero precision step -- a good choice
|
||||
private int precisionStep;
|
||||
|
@ -58,8 +58,8 @@ public class SpatialTwoDoublesFieldType extends AbstractSpatialFieldType<TwoDoub
|
|||
for( SchemaField sf : schema.getFields().values() ) {
|
||||
if( sf.getType() == this ) {
|
||||
String name = sf.getName();
|
||||
newFields.add(new SchemaField(name + TwoDoublesStrategy.SUFFIX_X, fieldType, p, null));
|
||||
newFields.add(new SchemaField(name + TwoDoublesStrategy.SUFFIX_Y, fieldType, p, null));
|
||||
newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_X, fieldType, p, null));
|
||||
newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_Y, fieldType, p, null));
|
||||
}
|
||||
}
|
||||
for (SchemaField newField : newFields) {
|
||||
|
@ -68,8 +68,8 @@ public class SpatialTwoDoublesFieldType extends AbstractSpatialFieldType<TwoDoub
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TwoDoublesStrategy newSpatialStrategy(String fieldName) {
|
||||
TwoDoublesStrategy strategy = new TwoDoublesStrategy(ctx, fieldName);
|
||||
protected PointVectorStrategy newSpatialStrategy(String fieldName) {
|
||||
PointVectorStrategy strategy = new PointVectorStrategy(ctx, fieldName);
|
||||
strategy.setPrecisionStep(precisionStep);
|
||||
return strategy;
|
||||
}
|
|
@ -41,7 +41,7 @@
|
|||
<fieldType name="stqpt_u" class="solr.SpatialTermQueryPrefixTreeFieldType"
|
||||
geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000" units="degrees"/>
|
||||
|
||||
<fieldType name="twodoubles" class="solr.SpatialTwoDoublesFieldType"
|
||||
<fieldType name="pointVector" class="solr.SpatialPointVectorFieldType"
|
||||
numberType="tdouble" units="degrees"/>
|
||||
|
||||
</types>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<field name="srpt_geohash" type="srpt_geohash" multiValued="true" />
|
||||
<field name="srpt_quad" type="srpt_quad" multiValued="true" />
|
||||
<field name="stqpt_geohash" type="stqpt_geohash" multiValued="true" />
|
||||
<field name="twodoubles" type="twodoubles" />
|
||||
<field name="pointvector" type="pointvector" />
|
||||
|
||||
</fields>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
|||
@ParametersFactory
|
||||
public static Iterable<Object[]> parameters() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{"srpt_geohash"}, {"srpt_quad"}, {"stqpt_geohash"}, {"twodoubles"}
|
||||
{"srpt_geohash"}, {"srpt_quad"}, {"stqpt_geohash"}, {"pointvector"}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
|||
|
||||
@Test
|
||||
public void testSortMultiVal() throws Exception {
|
||||
RandomizedTest.assumeFalse("Multivalue not supported for this field", fieldName.equals("twodoubles"));
|
||||
RandomizedTest.assumeFalse("Multivalue not supported for this field", fieldName.equals("pointvector"));
|
||||
|
||||
assertU(adoc("id", "100", fieldName, "1,2"));//1 point
|
||||
assertU(adoc("id", "101", fieldName, "4,-1", fieldName, "3,5"));//2 points, 2nd is pretty close to query point
|
||||
|
|
Loading…
Reference in New Issue