Skip to content

Commit

Permalink
Collapse all implementations of ValueCreatorUtil into single class
Browse files Browse the repository at this point in the history
... Except for Spatial. Special snowflake as usual.
  • Loading branch information
burqen committed Oct 3, 2018
1 parent 9ae7f1b commit 2e20cd6
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 349 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -33,13 +33,16 @@
import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.api.index.IndexProvider; import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.index.schema.config.ConfiguredSpaceFillingCurveSettingsCache; import org.neo4j.kernel.impl.index.schema.config.ConfiguredSpaceFillingCurveSettingsCache;
import org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettingsCache; import org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettingsCache;
import org.neo4j.storageengine.api.schema.StoreIndexDescriptor; import org.neo4j.storageengine.api.schema.StoreIndexDescriptor;
import org.neo4j.values.storable.RandomValues;
import org.neo4j.values.storable.ValueGroup; import org.neo4j.values.storable.ValueGroup;


import static org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory.forLabel;
import static org.neo4j.kernel.impl.index.schema.ValueCreatorUtil.FRACTION_DUPLICATE_NON_UNIQUE;

@RunWith( Parameterized.class ) @RunWith( Parameterized.class )
public class NativeIndexAccessorTest<KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> extends NativeIndexAccessorTests<KEY,VALUE> public class NativeIndexAccessorTest<KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> extends NativeIndexAccessorTests<KEY,VALUE>
{ {
Expand All @@ -49,52 +52,52 @@ public static Collection<Object[]> data()
return Arrays.asList( new Object[][]{ return Arrays.asList( new Object[][]{
{"Number", {"Number",
numberAccessorFactory(), numberAccessorFactory(),
(ValueCreatorUtilFactory) NumberValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.NUMBER ),
(IndexLayoutFactory) NumberLayoutNonUnique::new (IndexLayoutFactory) NumberLayoutNonUnique::new
}, },
{"String", {"String",
stringAccessorFactory(), stringAccessorFactory(),
(ValueCreatorUtilFactory) StringValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.TEXT ),
(IndexLayoutFactory) StringLayout::new (IndexLayoutFactory) StringLayout::new
}, },
{"Date", {"Date",
temporalAccessorFactory( ValueGroup.DATE ), temporalAccessorFactory( ValueGroup.DATE ),
(ValueCreatorUtilFactory) DateValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.DATE ),
(IndexLayoutFactory) DateLayout::new (IndexLayoutFactory) DateLayout::new
}, },
{"DateTime", {"DateTime",
temporalAccessorFactory( ValueGroup.ZONED_DATE_TIME ), temporalAccessorFactory( ValueGroup.ZONED_DATE_TIME ),
(ValueCreatorUtilFactory) DateTimeValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.ZONED_DATE_TIME ),
(IndexLayoutFactory) ZonedDateTimeLayout::new (IndexLayoutFactory) ZonedDateTimeLayout::new
}, },
{"Duration", {"Duration",
temporalAccessorFactory( ValueGroup.DURATION ), temporalAccessorFactory( ValueGroup.DURATION ),
(ValueCreatorUtilFactory) DurationValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.DURATION ),
(IndexLayoutFactory) DurationLayout::new (IndexLayoutFactory) DurationLayout::new
}, },
{"LocalDateTime", {"LocalDateTime",
temporalAccessorFactory( ValueGroup.LOCAL_DATE_TIME ), temporalAccessorFactory( ValueGroup.LOCAL_DATE_TIME ),
(ValueCreatorUtilFactory) LocalDateTimeValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.LOCAL_DATE_TIME ),
(IndexLayoutFactory) LocalDateTimeLayout::new (IndexLayoutFactory) LocalDateTimeLayout::new
}, },
{"LocalTime", {"LocalTime",
temporalAccessorFactory( ValueGroup.LOCAL_TIME ), temporalAccessorFactory( ValueGroup.LOCAL_TIME ),
(ValueCreatorUtilFactory) LocalTimeValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.LOCAL_TIME ),
(IndexLayoutFactory) LocalTimeLayout::new (IndexLayoutFactory) LocalTimeLayout::new
}, },
{"LocalDateTime", {"LocalDateTime",
temporalAccessorFactory( ValueGroup.LOCAL_DATE_TIME ), temporalAccessorFactory( ValueGroup.LOCAL_DATE_TIME ),
(ValueCreatorUtilFactory) LocalDateTimeValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.LOCAL_DATE_TIME ),
(IndexLayoutFactory) LocalDateTimeLayout::new (IndexLayoutFactory) LocalDateTimeLayout::new
}, },
{"Time", {"Time",
temporalAccessorFactory( ValueGroup.ZONED_TIME ), temporalAccessorFactory( ValueGroup.ZONED_TIME ),
(ValueCreatorUtilFactory) TimeValueCreatorUtil::new, RandomValues.typesOfGroup( ValueGroup.ZONED_TIME ),
(IndexLayoutFactory) ZonedTimeLayout::new (IndexLayoutFactory) ZonedTimeLayout::new
}, },
{"Generic", {"Generic",
genericAccessorFactory(), genericAccessorFactory(),
(ValueCreatorUtilFactory) GenericValueCreatorUtil::new, RandomValues.Type.values(),
(IndexLayoutFactory) () -> new GenericLayout( 1, spaceFillingCurveSettings ) (IndexLayoutFactory) () -> new GenericLayout( 1, spaceFillingCurveSettings )
}, },
//{ Spatial has it's own subclass because it need to override some of the test methods } //{ Spatial has it's own subclass because it need to override some of the test methods }
Expand All @@ -106,17 +109,17 @@ public static Collection<Object[]> data()
private static final StandardConfiguration configuration = new StandardConfiguration(); private static final StandardConfiguration configuration = new StandardConfiguration();


private final AccessorFactory<KEY,VALUE> accessorFactory; private final AccessorFactory<KEY,VALUE> accessorFactory;
private final ValueCreatorUtilFactory<KEY,VALUE> valueCreatorUtilFactory; private final RandomValues.Type[] supportedTypes;
private final IndexLayoutFactory<KEY,VALUE> indexLayoutFactory; private final IndexLayoutFactory<KEY,VALUE> indexLayoutFactory;


@SuppressWarnings( "unused" ) @SuppressWarnings( "unused" )
public NativeIndexAccessorTest( String name, public NativeIndexAccessorTest( String name,
AccessorFactory<KEY,VALUE> accessorFactory, AccessorFactory<KEY,VALUE> accessorFactory,
ValueCreatorUtilFactory<KEY,VALUE> valueCreatorUtilFactory, RandomValues.Type[] supportedTypes,
IndexLayoutFactory<KEY,VALUE> indexLayoutFactory ) IndexLayoutFactory<KEY,VALUE> indexLayoutFactory )
{ {
this.accessorFactory = accessorFactory; this.accessorFactory = accessorFactory;
this.valueCreatorUtilFactory = valueCreatorUtilFactory; this.supportedTypes = supportedTypes;
this.indexLayoutFactory = indexLayoutFactory; this.indexLayoutFactory = indexLayoutFactory;
} }


Expand All @@ -129,7 +132,7 @@ NativeIndexAccessor<KEY,VALUE> makeAccessor() throws IOException
@Override @Override
ValueCreatorUtil<KEY,VALUE> createValueCreatorUtil() ValueCreatorUtil<KEY,VALUE> createValueCreatorUtil()
{ {
return valueCreatorUtilFactory.create( TestIndexDescriptorFactory.forLabel( 42, 666 ).withId( 0 ), ValueCreatorUtil.FRACTION_DUPLICATE_NON_UNIQUE ); return new ValueCreatorUtil<>( forLabel( 42, 666 ).withId( 0 ), supportedTypes, FRACTION_DUPLICATE_NON_UNIQUE );
} }


@Override @Override
Expand Down

0 comments on commit 2e20cd6

Please sign in to comment.