Skip to content

Commit

Permalink
Fix all the review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
sherfert committed Apr 10, 2018
1 parent eb36473 commit 5e59d1f
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 46 deletions.
Expand Up @@ -70,9 +70,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (DateValue) from, fromInclusive, (DateValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -74,9 +74,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (DateTimeValue) from, fromInclusive, (DateTimeValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -38,8 +38,8 @@ public class DurationLayoutTestUtil extends LayoutTestUtil<DurationSchemaKey, Na
{ {
private static final DurationValue[] ALL_EXTREME_VALUES = new DurationValue[] private static final DurationValue[] ALL_EXTREME_VALUES = new DurationValue[]
{ {
DurationValue.duration( -999999999L * 12, 0, 0, 0), DurationValue.duration( -999999999L * 12 * 2, 0, 0, 0),
DurationValue.duration( 999999999L * 12, 0, 0, 0), DurationValue.duration( 999999999L * 12 * 2, 0, 0, 0),
DurationValue.duration( 0, -999999999L * 12 * 28, 0, 0), DurationValue.duration( 0, -999999999L * 12 * 28, 0, 0),
DurationValue.duration( 0, 999999999L * 12 * 28, 0, 0), DurationValue.duration( 0, 999999999L * 12 * 28, 0, 0),
DurationValue.duration( 0, 0, Long.MIN_VALUE, 0), DurationValue.duration( 0, 0, Long.MIN_VALUE, 0),
Expand Down Expand Up @@ -74,9 +74,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (DurationValue) from, fromInclusive, (DurationValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -32,7 +32,7 @@ public class DurationUniqueSchemaIndexAccessorTest extends NativeSchemaIndexAcce
@Override @Override
NativeSchemaIndexAccessor<DurationSchemaKey,NativeSchemaValue> makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException NativeSchemaIndexAccessor<DurationSchemaKey,NativeSchemaValue> makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
{ {
TemporalIndexFiles.FileLayout<DurationSchemaKey> fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.LOCAL_DATE_TIME ); TemporalIndexFiles.FileLayout<DurationSchemaKey> fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.DURATION );
return new TemporalIndexAccessor.PartAccessor<>( pageCache, fs, fileLayout, IMMEDIATE, monitor, schemaIndexDescriptor, indexId, samplingConfig ); return new TemporalIndexAccessor.PartAccessor<>( pageCache, fs, fileLayout, IMMEDIATE, monitor, schemaIndexDescriptor, indexId, samplingConfig );
} }


Expand Down
Expand Up @@ -59,7 +59,7 @@ protected double fractionDuplicates()
return 0.1; return 0.1;
} }


abstract IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ); abstract IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive );


abstract int compareIndexedPropertyValue( KEY key1, KEY key2 ); abstract int compareIndexedPropertyValue( KEY key1, KEY key2 );


Expand Down
Expand Up @@ -71,9 +71,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (LocalDateTimeValue) from, fromInclusive, (LocalDateTimeValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -72,9 +72,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (LocalTimeValue) from, fromInclusive, (LocalTimeValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -697,7 +697,7 @@ public void shouldNotSeeFilteredEntries() throws Exception


// when // when
NodeValueIterator iter = new NodeValueIterator(); NodeValueIterator iter = new NodeValueIterator();
IndexQuery.ExactPredicate filter = IndexQuery.exact( 0, updates[1].values()[0].asObjectCopy() ); IndexQuery.ExactPredicate filter = IndexQuery.exact( 0, valueOf( updates[1]) );
IndexQuery rangeQuery = layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[2] ), true ); IndexQuery rangeQuery = layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[2] ), true );
IndexProgressor.NodeValueClient filterClient = filterClient( iter, filter ); IndexProgressor.NodeValueClient filterClient = filterClient( iter, filter );
reader.query( filterClient, IndexOrder.NONE, rangeQuery ); reader.query( filterClient, IndexOrder.NONE, rangeQuery );
Expand Down Expand Up @@ -728,7 +728,7 @@ private static Predicate<IndexEntryUpdate<SchemaIndexDescriptor>> skipExisting(
}; };
} }


private Object valueOf( IndexEntryUpdate<SchemaIndexDescriptor> update ) private Value valueOf( IndexEntryUpdate<SchemaIndexDescriptor> update )
{ {
return update.values()[0]; return update.values()[0];
} }
Expand Down
Expand Up @@ -62,9 +62,9 @@ abstract class NumberLayoutTestUtil extends LayoutTestUtil<NumberSchemaKey,Nativ
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (NumberValue) from, fromInclusive, (NumberValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -42,10 +42,4 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
{ {
return someUpdatesWithDuplicateValues(); return someUpdatesWithDuplicateValues();
} }

@Override
protected double fractionDuplicates()
{
return 0.1;
}
} }
Expand Up @@ -85,9 +85,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (PointValue) from , fromInclusive, (PointValue) to, toInclusive ); return IndexQuery.range( 0, from , fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class SpatialNonUniqueSchemaIndexPopulatorTest extends NativeNonUniqueSch
@Override @Override
NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig ) NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{ {
fileLayout = new SpatialIndexFiles.SpatialFileLayout( CoordinateReferenceSystem.WGS84, settings, super.getIndexFile() ); fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, schemaIndexDescriptor, indexId, samplingConfig, return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, schemaIndexDescriptor, indexId, samplingConfig,
new StandardConfiguration() ); new StandardConfiguration() );
} }
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class SpatialUniqueSchemaIndexPopulatorTest extends NativeUniqueSchemaInd
@Override @Override
NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig ) NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{ {
fileLayout = new SpatialIndexFiles.SpatialFileLayout( CoordinateReferenceSystem.WGS84, settings, super.getIndexFile() ); fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, schemaIndexDescriptor, indexId, samplingConfig, return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, schemaIndexDescriptor, indexId, samplingConfig,
new StandardConfiguration() ); new StandardConfiguration() );
} }
Expand Down
Expand Up @@ -45,9 +45,9 @@ abstract class StringLayoutTestUtil extends LayoutTestUtil<StringSchemaKey,Nativ
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (TextValue) from, fromInclusive, (TextValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -42,10 +42,4 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
{ {
return someUpdatesWithDuplicateValues(); return someUpdatesWithDuplicateValues();
} }

@Override
protected double fractionDuplicates()
{
return 0.1;
}
} }
Expand Up @@ -46,6 +46,6 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
@Override @Override
protected double fractionDuplicates() protected double fractionDuplicates()
{ {
return 0; return 0.0;
} }
} }
Expand Up @@ -75,9 +75,9 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return IndexQuery.range( 0, (TimeValue) from, fromInclusive, (TimeValue) to, toInclusive ); return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
} }


@Override @Override
Expand Down
Expand Up @@ -53,7 +53,7 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdates()
} }


@Override @Override
IndexQuery rangeQuery( Object from, boolean fromInclusive, Object to, boolean toInclusive ) IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{ {
return delegate.rangeQuery( from, fromInclusive, to, toInclusive ); return delegate.rangeQuery( from, fromInclusive, to, toInclusive );
} }
Expand Down Expand Up @@ -85,6 +85,6 @@ IndexEntryUpdate<SchemaIndexDescriptor>[] someUpdatesWithDuplicateValues()
@Override @Override
protected double fractionDuplicates() protected double fractionDuplicates()
{ {
return 0; return 0.0;
} }
} }
Expand Up @@ -23,7 +23,7 @@


public class Envelope public class Envelope
{ {
private static final double MAXIMAL_ENVELOPE_SIDE_RATIO = 1000_000_000; static final double MAXIMAL_ENVELOPE_SIDE_RATIO = 1000_000_000;


protected final double[] min; protected final double[] min;
protected final double[] max; protected final double[] max;
Expand Down
Expand Up @@ -121,9 +121,11 @@ public void testWithSideRatioNotTooSmall2D()
assertArrayEquals( expectedTo, envelope.max, 0 ); assertArrayEquals( expectedTo, envelope.max, 0 );


// Expected to change // Expected to change
to = new double[] {100, 0.1}; final double bigValue = 100;
final double smallValue = 0.000000000000000001;
to = new double[] {bigValue, smallValue};
Envelope envelope2 = new Envelope( from, to ).withSideRatioNotTooSmall(); Envelope envelope2 = new Envelope( from, to ).withSideRatioNotTooSmall();
double[] expectedTo2 = new double[] {100, 1}; double[] expectedTo2 = new double[] {bigValue, bigValue / Envelope.MAXIMAL_ENVELOPE_SIDE_RATIO};
assertArrayEquals( expectedFrom, envelope2.min , 0); assertArrayEquals( expectedFrom, envelope2.min , 0);
assertArrayEquals( expectedTo2, envelope2.max, 0.00001 ); assertArrayEquals( expectedTo2, envelope2.max, 0.00001 );
} }
Expand All @@ -143,9 +145,11 @@ public void testWithSideRatioNotTooSmall4D()
assertArrayEquals( expectedTo, envelope.max, 0 ); assertArrayEquals( expectedTo, envelope.max, 0 );


// Expected to change // Expected to change
to = new double[] {100, 0.1, 12, 0.01}; final double bigValue = 107;
final double smallValue = 0.00000000000000000123;
to = new double[] {bigValue, smallValue, 12, smallValue * 0.1};
Envelope envelope2 = new Envelope( from, to ).withSideRatioNotTooSmall(); Envelope envelope2 = new Envelope( from, to ).withSideRatioNotTooSmall();
double[] expectedTo2 = new double[] {100, 1, 12, 1}; double[] expectedTo2 = new double[] {bigValue, bigValue / Envelope.MAXIMAL_ENVELOPE_SIDE_RATIO, 12, bigValue / Envelope.MAXIMAL_ENVELOPE_SIDE_RATIO};
assertArrayEquals( expectedFrom, envelope2.min , 0); assertArrayEquals( expectedFrom, envelope2.min , 0);
assertArrayEquals( expectedTo2, envelope2.max, 0.00001 ); assertArrayEquals( expectedTo2, envelope2.max, 0.00001 );
} }
Expand Down

0 comments on commit 5e59d1f

Please sign in to comment.