Skip to content

Commit

Permalink
LayoutTestUtil cleanup
Browse files Browse the repository at this point in the history
- Don't rely on KEY being NativeIndexSingleValueKey
- Move implementation of rangeQuery to super class
  • Loading branch information
burqen committed Oct 3, 2018
1 parent 6542550 commit 3a292ea
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 76 deletions.
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.DateValue;
Expand Down Expand Up @@ -62,12 +61,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( DateIndexKey key1, DateIndexKey key2 )
{
Expand Down
Expand Up @@ -26,7 +26,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.DateTimeValue;
Expand Down Expand Up @@ -65,12 +64,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( ZonedDateTimeIndexKey key1, ZonedDateTimeIndexKey key2 )
{
Expand Down
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.DurationValue;
Expand Down Expand Up @@ -63,12 +62,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( DurationIndexKey key1, DurationIndexKey key2 )
{
Expand Down
Expand Up @@ -39,7 +39,7 @@
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;

abstract class LayoutTestUtil<KEY extends NativeIndexSingleValueKey<KEY>, VALUE extends NativeIndexValue>
abstract class LayoutTestUtil<KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue>
{
private static final Comparator<IndexEntryUpdate<IndexDescriptor>> UPDATE_COMPARATOR = ( u1, u2 ) ->
Values.COMPARATOR.compare( u1.values()[0], u2.values()[0] );
Expand All @@ -65,7 +65,10 @@ protected double fractionDuplicates()
return 0.1;
}

abstract IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive );
IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{
return IndexQuery.range( 0, from, fromInclusive, to, toInclusive );
}

abstract int compareIndexedPropertyValue( KEY key1, KEY key2 );

Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.LocalDateTimeValue;
Expand Down Expand Up @@ -62,12 +61,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( LocalDateTimeIndexKey key1, LocalDateTimeIndexKey key2 )
{
Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.LocalTimeValue;
Expand Down Expand Up @@ -62,12 +61,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( LocalTimeIndexKey key1, LocalTimeIndexKey key2 )
{
Expand Down
Expand Up @@ -80,7 +80,7 @@
* <li>{@link NumberIndexReader}</li>
* </ul>
*/
public abstract class NativeIndexAccessorTest<KEY extends NativeIndexSingleValueKey<KEY>, VALUE extends NativeIndexValue>
public abstract class NativeIndexAccessorTest<KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue>
extends NativeIndexTestUtil<KEY,VALUE>
{
NativeIndexAccessor<KEY,VALUE> accessor;
Expand Down
Expand Up @@ -56,7 +56,7 @@
import static org.neo4j.kernel.impl.index.schema.NativeIndexKey.Inclusion.NEUTRAL;
import static org.neo4j.test.rule.PageCacheRule.config;

public abstract class NativeIndexTestUtil<KEY extends NativeIndexSingleValueKey<KEY>,VALUE extends NativeIndexValue>
public abstract class NativeIndexTestUtil<KEY extends NativeIndexKey<KEY>,VALUE extends NativeIndexValue>
{
static final long NON_EXISTENT_ENTITY_ID = 1_000_000_000;

Expand Down Expand Up @@ -135,10 +135,10 @@ private RawCursor<Hit<KEY,VALUE>, IOException> scan( GBPTree<KEY,VALUE> tree ) t
{
KEY lowest = layout.newKey();
lowest.initialize( Long.MIN_VALUE );
lowest.initValueAsLowest( ValueGroup.UNKNOWN );
lowest.initValueAsLowest( 0, ValueGroup.UNKNOWN );
KEY highest = layout.newKey();
highest.initialize( Long.MAX_VALUE );
highest.initValueAsHighest( ValueGroup.UNKNOWN );
highest.initValueAsHighest( 0, ValueGroup.UNKNOWN );
return tree.seek( lowest, highest );
}

Expand Down
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.NumberValue;
Expand Down Expand Up @@ -60,12 +59,6 @@ abstract class NumberLayoutTestUtil extends LayoutTestUtil<NumberIndexKey,Native
super( indexDescriptor.withId( 0 ) );
}

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

@Override
int compareIndexedPropertyValue( NumberIndexKey key1, NumberIndexKey key2 )
{
Expand Down
Expand Up @@ -25,7 +25,6 @@
import java.util.Set;

import org.neo4j.gis.spatial.index.curves.SpaceFillingCurve;
import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
Expand Down Expand Up @@ -79,12 +78,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( SpatialIndexKey key1, SpatialIndexKey key2 )
{
Expand Down
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.RandomValues;
Expand All @@ -43,12 +42,6 @@ abstract class StringLayoutTestUtil extends LayoutTestUtil<StringIndexKey,Native
super( schemaIndexDescriptor );
}

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

@Override
int compareIndexedPropertyValue( StringIndexKey key1, StringIndexKey key2 )
{
Expand Down
Expand Up @@ -26,7 +26,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.RandomValues;
Expand Down Expand Up @@ -65,12 +64,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return someUpdatesWithDuplicateValues();
}

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

@Override
int compareIndexedPropertyValue( ZonedTimeIndexKey key1, ZonedTimeIndexKey key2 )
{
Expand Down
Expand Up @@ -22,7 +22,6 @@
import java.util.List;
import java.util.Set;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.values.storable.RandomValues;
Expand Down Expand Up @@ -51,12 +50,6 @@ IndexEntryUpdate<IndexDescriptor>[] someUpdates()
return delegate.someUpdatesNoDuplicateValues();
}

@Override
IndexQuery rangeQuery( Value from, boolean fromInclusive, Value to, boolean toInclusive )
{
return delegate.rangeQuery( from, fromInclusive, to, toInclusive );
}

@Override
int compareIndexedPropertyValue( KEY key1, KEY key2 )
{
Expand Down

0 comments on commit 3a292ea

Please sign in to comment.