Skip to content

Commit

Permalink
RangePredicate is generic
Browse files Browse the repository at this point in the history
  • Loading branch information
klaren committed Mar 22, 2018
1 parent 17af4bf commit 136f028
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 68 deletions.
Expand Up @@ -70,7 +70,7 @@ public static ExactPredicate exact( int propertyKeyId, Object value )
* @param toInclusive the upper bound is inclusive if true.
* @return an {@link IndexQuery} instance to be used for querying an index.
*/
public static RangePredicate range( int propertyKeyId,
public static RangePredicate<?> range( int propertyKeyId,
Number from, boolean fromInclusive,
Number to, boolean toInclusive )
{
Expand All @@ -79,7 +79,7 @@ public static RangePredicate range( int propertyKeyId,
to == null ? null : Values.numberValue( to ), toInclusive );
}

public static RangePredicate range( int propertyKeyId,
public static RangePredicate<?> range( int propertyKeyId,
String from, boolean fromInclusive,
String to, boolean toInclusive )
{
Expand All @@ -88,7 +88,7 @@ public static RangePredicate range( int propertyKeyId,
to == null ? null : Values.stringValue( to ), toInclusive );
}

public static <VALUE extends Value> RangePredicate range( int propertyKeyId,
public static <VALUE extends Value> RangePredicate<?> range( int propertyKeyId,
VALUE from, boolean fromInclusive,
VALUE to, boolean toInclusive )
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public static <VALUE extends Value> RangePredicate range( int propertyKeyId,
/**
* Create IndexQuery for retrieving all indexed entries of the given value group.
*/
public static RangePredicate range( int propertyKeyId, ValueGroup valueGroup )
public static RangePredicate<?> range( int propertyKeyId, ValueGroup valueGroup )
{
if ( valueGroup == ValueGroup.GEOMETRY )
{
Expand All @@ -137,7 +137,7 @@ public static RangePredicate range( int propertyKeyId, ValueGroup valueGroup )
* Create IndexQuery for retrieving all indexed entries with spatial value of the given
* coordinate reference system.
*/
public static RangePredicate range( int propertyKeyId, CoordinateReferenceSystem crs )
public static RangePredicate<?> range( int propertyKeyId, CoordinateReferenceSystem crs )
{
return new GeometryRangePredicate( propertyKeyId, crs, null, true, null, true );
}
Expand Down Expand Up @@ -510,8 +510,7 @@ public IndexQueryType type()
@Override
public boolean acceptsValue( Value value )
{
return value != null && Values.isTextValue( value ) &&
((TextValue)value).stringValue().startsWith( prefix );
return Values.isTextValue( value ) && ((TextValue) value).stringValue().startsWith( prefix );
}

public String prefix()
Expand Down Expand Up @@ -539,7 +538,7 @@ public IndexQueryType type()
@Override
public boolean acceptsValue( Value value )
{
return value != null && Values.isTextValue( value ) && ((String)value.asObject()).contains( contains );
return Values.isTextValue( value ) && ((String) value.asObject()).contains( contains );
}

public String contains()
Expand Down Expand Up @@ -567,7 +566,7 @@ public IndexQueryType type()
@Override
public boolean acceptsValue( Value value )
{
return value != null && Values.isTextValue( value ) && ((String)value.asObject()).endsWith( suffix );
return Values.isTextValue( value ) && ((String) value.asObject()).endsWith( suffix );
}

public String suffix()
Expand Down
Expand Up @@ -97,15 +97,15 @@ public void testExact_ComparingBigDoublesAndLongs()
@Test
public void testNumRange_FalseForIrrelevant()
{
RangePredicate p = IndexQuery.range( propId, 11, true, 13, true );
RangePredicate<?> p = IndexQuery.range( propId, 11, true, 13, true );

assertFalseForOtherThings( p );
}

@Test
public void testNumRange_InclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, 11, true, 13, true );
RangePredicate<?> p = IndexQuery.range( propId, 11, true, 13, true );

assertFalse( test( p, 10 ) );
assertTrue( test( p, 11 ) );
Expand All @@ -117,7 +117,7 @@ public void testNumRange_InclusiveLowerInclusiveUpper()
@Test
public void testNumRange_ExclusiveLowerExclusiveLower()
{
RangePredicate p = IndexQuery.range( propId, 11, false, 13, false );
RangePredicate<?> p = IndexQuery.range( propId, 11, false, 13, false );

assertFalse( test( p, 11 ) );
assertTrue( test( p, 12 ) );
Expand All @@ -127,7 +127,7 @@ public void testNumRange_ExclusiveLowerExclusiveLower()
@Test
public void testNumRange_InclusiveLowerExclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, 11, true, 13, false );
RangePredicate<?> p = IndexQuery.range( propId, 11, true, 13, false );

assertFalse( test( p, 10 ) );
assertTrue( test( p, 11 ) );
Expand All @@ -138,7 +138,7 @@ public void testNumRange_InclusiveLowerExclusiveUpper()
@Test
public void testNumRange_ExclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, 11, false, 13, true );
RangePredicate<?> p = IndexQuery.range( propId, 11, false, 13, true );

assertFalse( test( p, 11 ) );
assertTrue( test( p, 12 ) );
Expand All @@ -149,7 +149,7 @@ public void testNumRange_ExclusiveLowerInclusiveUpper()
@Test
public void testNumRange_LowerNullValue()
{
RangePredicate p = IndexQuery.range( propId, null, true, 13, true );
RangePredicate<?> p = IndexQuery.range( propId, null, true, 13, true );

assertTrue( test( p, 10 ) );
assertTrue( test( p, 11 ) );
Expand All @@ -161,7 +161,7 @@ public void testNumRange_LowerNullValue()
@Test
public void testNumRange_UpperNullValue()
{
RangePredicate p = IndexQuery.range( propId, 11, true, null, true );
RangePredicate<?> p = IndexQuery.range( propId, 11, true, null, true );

assertFalse( test( p, 10 ) );
assertTrue( test( p, 11 ) );
Expand All @@ -173,7 +173,7 @@ public void testNumRange_UpperNullValue()
@Test
public void testNumRange_ComparingBigDoublesAndLongs()
{
RangePredicate p = IndexQuery.range( propId, 9007199254740993L, true, null, true );
RangePredicate<?> p = IndexQuery.range( propId, 9007199254740993L, true, null, true );

assertFalse( test( p, 9007199254740992D ) );
}
Expand All @@ -183,15 +183,15 @@ public void testNumRange_ComparingBigDoublesAndLongs()
@Test
public void testStringRange_FalseForIrrelevant()
{
RangePredicate p = IndexQuery.range( propId, "bbb", true, "bee", true );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", true, "bee", true );

assertFalseForOtherThings( p );
}

@Test
public void testStringRange_InclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, "bbb", true, "bee", true );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", true, "bee", true );

assertFalse( test( p, "bba" ) );
assertTrue( test( p, "bbb" ) );
Expand All @@ -203,7 +203,7 @@ public void testStringRange_InclusiveLowerInclusiveUpper()
@Test
public void testStringRange_ExclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, "bbb", false, "bee", true );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", false, "bee", true );

assertFalse( test( p, "bbb" ) );
assertTrue( test( p, "bbba" ) );
Expand All @@ -214,7 +214,7 @@ public void testStringRange_ExclusiveLowerInclusiveUpper()
@Test
public void testStringRange_InclusiveLowerExclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, "bbb", true, "bee", false );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", true, "bee", false );

assertFalse( test( p, "bba" ) );
assertTrue( test( p, "bbb" ) );
Expand All @@ -225,7 +225,7 @@ public void testStringRange_InclusiveLowerExclusiveUpper()
@Test
public void testStringRange_ExclusiveLowerExclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, "bbb", false, "bee", false );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", false, "bee", false );

assertFalse( test( p, "bbb" ) );
assertTrue( test( p, "bbba" ) );
Expand All @@ -236,7 +236,7 @@ public void testStringRange_ExclusiveLowerExclusiveUpper()
@Test
public void testStringRange_UpperUnbounded()
{
RangePredicate p = IndexQuery.range( propId, "bbb", false, null, false );
RangePredicate<?> p = IndexQuery.range( propId, "bbb", false, null, false );

assertFalse( test( p, "bbb" ) );
assertTrue( test( p, "bbba" ) );
Expand All @@ -246,7 +246,7 @@ public void testStringRange_UpperUnbounded()
@Test
public void testStringRange_LowerUnbounded()
{
RangePredicate p = IndexQuery.range( propId, null, false, "bee", false );
RangePredicate<?> p = IndexQuery.range( propId, null, false, "bee", false );

assertTrue( test( p, "" ) );
assertTrue( test( p, "bed" ) );
Expand Down Expand Up @@ -274,15 +274,15 @@ public void testStringRange_LowerUnbounded()
@Test
public void testGeometryRange_FalseForIrrelevant()
{
RangePredicate p = IndexQuery.range( propId, gps2, true, gps5, true );
RangePredicate<?> p = IndexQuery.range( propId, gps2, true, gps5, true );

assertFalseForOtherThings( p );
}

@Test
public void testGeometryRange_InclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, gps2, true, gps5, true );
RangePredicate<?> p = IndexQuery.range( propId, gps2, true, gps5, true );

assertFalse( test( p, gps1 ) );
assertTrue( test( p, gps2 ) );
Expand All @@ -298,7 +298,7 @@ public void testGeometryRange_InclusiveLowerInclusiveUpper()
@Test
public void testGeometryRange_ExclusiveLowerInclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, gps2, false, gps5, true );
RangePredicate<?> p = IndexQuery.range( propId, gps2, false, gps5, true );

assertFalse( test( p, gps2 ) );
assertTrue( test( p, gps3 ) );
Expand All @@ -313,7 +313,7 @@ public void testGeometryRange_ExclusiveLowerInclusiveUpper()
@Test
public void testGeometryRange_InclusiveLowerExclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, gps2, true, gps5, false );
RangePredicate<?> p = IndexQuery.range( propId, gps2, true, gps5, false );

assertFalse( test( p, gps1 ) );
assertTrue( test( p, gps2 ) );
Expand All @@ -328,7 +328,7 @@ public void testGeometryRange_InclusiveLowerExclusiveUpper()
@Test
public void testGeometryRange_ExclusiveLowerExclusiveUpper()
{
RangePredicate p = IndexQuery.range( propId, gps2, false, gps5, false );
RangePredicate<?> p = IndexQuery.range( propId, gps2, false, gps5, false );

assertFalse( test( p, gps2 ) );
assertTrue( test( p, gps3 ) );
Expand All @@ -343,7 +343,7 @@ public void testGeometryRange_ExclusiveLowerExclusiveUpper()
@Test
public void testGeometryRange_UpperUnbounded()
{
RangePredicate p = IndexQuery.range( propId, gps2, false, null, false );
RangePredicate<?> p = IndexQuery.range( propId, gps2, false, null, false );

assertFalse( test( p, gps2 ) );
assertTrue( test( p, gps3 ) );
Expand All @@ -357,7 +357,7 @@ public void testGeometryRange_UpperUnbounded()
@Test
public void testGeometryRange_LowerUnbounded()
{
RangePredicate p = IndexQuery.range( propId, null, false, gps5, false );
RangePredicate<?> p = IndexQuery.range( propId, null, false, gps5, false );

assertTrue( test( p, gps1 ) );
assertTrue( test( p, gps3 ) );
Expand All @@ -371,7 +371,7 @@ public void testGeometryRange_LowerUnbounded()
@Test
public void testGeometryRange_Cartesian()
{
RangePredicate p = IndexQuery.range( propId, car1, false, car2, true );
RangePredicate<?> p = IndexQuery.range( propId, car1, false, car2, true );

assertFalse( test( p, gps1 ) );
assertFalse( test( p, gps3 ) );
Expand All @@ -387,7 +387,7 @@ public void testGeometryRange_Cartesian()
@Test
public void testGeometryRange_Cartesian3D()
{
RangePredicate p = IndexQuery.range( propId, car3, true, car4, true );
RangePredicate<?> p = IndexQuery.range( propId, car3, true, car4, true );

assertFalse( test( p, gps1 ) );
assertFalse( test( p, gps3 ) );
Expand All @@ -403,7 +403,7 @@ public void testGeometryRange_Cartesian3D()
@Test
public void testGeometryRange_WGS84_3D()
{
RangePredicate p = IndexQuery.range( propId, gps1_3d, true, gps2_3d, true );
RangePredicate<?> p = IndexQuery.range( propId, gps1_3d, true, gps2_3d, true );

assertFalse( test( p, gps1 ) );
assertFalse( test( p, gps3 ) );
Expand All @@ -419,7 +419,7 @@ public void testGeometryRange_WGS84_3D()
@Test
public void testDateRange()
{
RangePredicate p = IndexQuery.range( propId, DateValue.date( 2014, 7, 7 ), true, DateValue.date( 2017,3, 7 ), false );
RangePredicate<?> p = IndexQuery.range( propId, DateValue.date( 2014, 7, 7 ), true, DateValue.date( 2017,3, 7 ), false );

assertFalse( test( p, DateValue.date( 2014, 6, 8 ) ) );
assertTrue( test( p, DateValue.date( 2014, 7, 7 ) ) );
Expand All @@ -433,7 +433,7 @@ public void testDateRange()
@Test
public void testValueGroupRange()
{
RangePredicate p = IndexQuery.range( propId, ValueGroup.DATE );
RangePredicate<?> p = IndexQuery.range( propId, ValueGroup.DATE );

assertTrue( test( p, DateValue.date( -4000, 1, 31 ) ) );
assertTrue( test( p, DateValue.date( 2018, 3, 7 ) ) );
Expand All @@ -445,7 +445,7 @@ public void testValueGroupRange()
@Test
public void testCRSRange()
{
RangePredicate p = IndexQuery.range( propId, CoordinateReferenceSystem.WGS84 );
RangePredicate<?> p = IndexQuery.range( propId, CoordinateReferenceSystem.WGS84 );

assertTrue( test( p, gps2 ) );
assertFalse( test( p, DateValue.date( -4000, 1, 31 ) ) );
Expand Down
Expand Up @@ -868,7 +868,7 @@ public PrimitiveLongResourceIterator indexQuery( KernelStatement state, SchemaIn

case range:
assertSinglePredicate( predicates );
IndexQuery.RangePredicate rangePred = (IndexQuery.RangePredicate) firstPredicate;
IndexQuery.RangePredicate<?> rangePred = (IndexQuery.RangePredicate<?>) firstPredicate;
return filterIndexStateChangesForRangeSeek( state, index, rangePred.valueGroup(),
rangePred.fromValue(), rangePred.fromInclusive(),
rangePred.toValue(), rangePred.toInclusive(),
Expand Down
Expand Up @@ -32,7 +32,8 @@

class NumberSchemaIndexReader<VALUE extends NativeSchemaValue> extends NativeSchemaIndexReader<NumberSchemaKey,VALUE>
{
NumberSchemaIndexReader( GBPTree<NumberSchemaKey,VALUE> tree, Layout<NumberSchemaKey,VALUE> layout, IndexSamplingConfig samplingConfig, SchemaIndexDescriptor descriptor )
NumberSchemaIndexReader( GBPTree<NumberSchemaKey,VALUE> tree, Layout<NumberSchemaKey,VALUE> layout,
IndexSamplingConfig samplingConfig, SchemaIndexDescriptor descriptor )
{
super( tree, layout, samplingConfig, descriptor );
}
Expand Down Expand Up @@ -64,7 +65,7 @@ boolean initializeRangeForQuery( NumberSchemaKey treeKeyFrom, NumberSchemaKey tr
treeKeyTo.from( Long.MAX_VALUE, exactPredicate.value() );
break;
case range:
RangePredicate rangePredicate = (RangePredicate) predicate;
RangePredicate<?> rangePredicate = (RangePredicate<?>) predicate;
initFromForRange( rangePredicate, treeKeyFrom );
initToForRange( rangePredicate, treeKeyTo );
break;
Expand All @@ -74,7 +75,7 @@ boolean initializeRangeForQuery( NumberSchemaKey treeKeyFrom, NumberSchemaKey tr
return false;
}

private void initToForRange( RangePredicate rangePredicate, NumberSchemaKey treeKeyTo )
private void initToForRange( RangePredicate<?> rangePredicate, NumberSchemaKey treeKeyTo )
{
Value toValue = rangePredicate.toValue();
if ( toValue == Values.NO_VALUE )
Expand All @@ -88,7 +89,7 @@ private void initToForRange( RangePredicate rangePredicate, NumberSchemaKey tree
}
}

private void initFromForRange( RangePredicate rangePredicate, NumberSchemaKey treeKeyFrom )
private void initFromForRange( RangePredicate<?> rangePredicate, NumberSchemaKey treeKeyFrom )
{
Value fromValue = rangePredicate.fromValue();
if ( fromValue == Values.NO_VALUE )
Expand Down
Expand Up @@ -26,16 +26,16 @@
import org.neo4j.index.internal.gbptree.Hit;
import org.neo4j.values.storable.Value;

class SpatialHitIndexProgressor<KEY extends NativeSchemaKey<KEY>, VALUE extends NativeSchemaValue> extends NativeHitIndexProgressor<KEY, VALUE>
class SpatialHitIndexProgressor<VALUE extends NativeSchemaValue> extends NativeHitIndexProgressor<SpatialSchemaKey, VALUE>
{
SpatialHitIndexProgressor( RawCursor<Hit<KEY,VALUE>,IOException> seeker, NodeValueClient client,
Collection<RawCursor<Hit<KEY,VALUE>,IOException>> toRemoveFromOnClose )
SpatialHitIndexProgressor( RawCursor<Hit<SpatialSchemaKey,VALUE>,IOException> seeker, NodeValueClient client,
Collection<RawCursor<Hit<SpatialSchemaKey,VALUE>,IOException>> toRemoveFromOnClose )
{
super( seeker, client, toRemoveFromOnClose );
}

@Override
Value[] extractValues( KEY key )
Value[] extractValues( SpatialSchemaKey key )
{
return null;
}
Expand Down

0 comments on commit 136f028

Please sign in to comment.