Skip to content

Commit

Permalink
Adds LAYOUT generic type parameter to NativeIndexProvider
Browse files Browse the repository at this point in the history
so that a cast can be avoided in GenericNativeIndexProvider
  • Loading branch information
tinwelint committed Sep 5, 2018
1 parent d1b0388 commit 6f63cae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Expand Up @@ -102,7 +102,7 @@
* We COULD allow this query and do filter during scan instead and take the extra cost into account when planning queries. * We COULD allow this query and do filter during scan instead and take the extra cost into account when planning queries.
* As of writing this, there is no such filtering implementation. * As of writing this, there is no such filtering implementation.
*/ */
public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue> public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue,GenericLayout>
{ {
public static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10; public static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10;
public static final String KEY = SCHEMA_INDEX.providerName(); public static final String KEY = SCHEMA_INDEX.providerName();
Expand Down Expand Up @@ -145,7 +145,7 @@ public GenericNativeIndexProvider( int priority, IndexDirectoryStructure.Factory
} }


@Override @Override
IndexLayout<CompositeGenericKey,NativeIndexValue> layout( StoreIndexDescriptor descriptor, File storeFile ) GenericLayout layout( StoreIndexDescriptor descriptor, File storeFile )
{ {
try try
{ {
Expand All @@ -168,19 +168,19 @@ IndexLayout<CompositeGenericKey,NativeIndexValue> layout( StoreIndexDescriptor d
} }


@Override @Override
protected IndexPopulator newIndexPopulator( File storeFile, IndexLayout<CompositeGenericKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexPopulator newIndexPopulator( File storeFile, GenericLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) IndexSamplingConfig samplingConfig )
{ {
return new GenericNativeIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig, return new GenericNativeIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig,
((GenericLayout) layout).getSpaceFillingCurveSettings(), configuration ); layout.getSpaceFillingCurveSettings(), configuration );
} }


@Override @Override
protected IndexAccessor newIndexAccessor( File storeFile, IndexLayout<CompositeGenericKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexAccessor newIndexAccessor( File storeFile, GenericLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) throws IOException IndexSamplingConfig samplingConfig ) throws IOException
{ {
return new GenericNativeIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, samplingConfig, return new GenericNativeIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, samplingConfig,
((GenericLayout) layout).getSpaceFillingCurveSettings(), configuration ); layout.getSpaceFillingCurveSettings(), configuration );
} }


@Override @Override
Expand Down
Expand Up @@ -42,8 +42,10 @@
* *
* @param <KEY> type of {@link NativeIndexSingleValueKey} * @param <KEY> type of {@link NativeIndexSingleValueKey}
* @param <VALUE> type of {@link NativeIndexValue} * @param <VALUE> type of {@link NativeIndexValue}
* @param <LAYOUT> type of {@link IndexLayout}
*/ */
abstract class NativeIndexProvider<KEY extends NativeIndexKey<KEY>,VALUE extends NativeIndexValue> extends IndexProvider abstract class NativeIndexProvider<KEY extends NativeIndexKey<KEY>,VALUE extends NativeIndexValue,LAYOUT extends IndexLayout<KEY,VALUE>>
extends IndexProvider
{ {
protected final PageCache pageCache; protected final PageCache pageCache;
protected final FileSystemAbstraction fs; protected final FileSystemAbstraction fs;
Expand All @@ -62,7 +64,7 @@ protected NativeIndexProvider( IndexProviderDescriptor descriptor, int priority,
this.readOnly = readOnly; this.readOnly = readOnly;
} }


abstract IndexLayout<KEY,VALUE> layout( StoreIndexDescriptor descriptor, File storeFile ); abstract LAYOUT layout( StoreIndexDescriptor descriptor, File storeFile );


@Override @Override
public IndexPopulator getPopulator( StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) public IndexPopulator getPopulator( StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig )
Expand All @@ -76,7 +78,7 @@ public IndexPopulator getPopulator( StoreIndexDescriptor descriptor, IndexSampli
return newIndexPopulator( storeFile, layout( descriptor, storeFile ), descriptor, samplingConfig ); return newIndexPopulator( storeFile, layout( descriptor, storeFile ), descriptor, samplingConfig );
} }


protected abstract IndexPopulator newIndexPopulator( File storeFile, IndexLayout<KEY,VALUE> layout, StoreIndexDescriptor descriptor, protected abstract IndexPopulator newIndexPopulator( File storeFile, LAYOUT layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ); IndexSamplingConfig samplingConfig );


@Override @Override
Expand All @@ -86,7 +88,7 @@ public IndexAccessor getOnlineAccessor( StoreIndexDescriptor descriptor, IndexSa
return newIndexAccessor( storeFile, layout( descriptor, storeFile ), descriptor, samplingConfig ); return newIndexAccessor( storeFile, layout( descriptor, storeFile ), descriptor, samplingConfig );
} }


protected abstract IndexAccessor newIndexAccessor( File storeFile, IndexLayout<KEY,VALUE> layout, StoreIndexDescriptor descriptor, protected abstract IndexAccessor newIndexAccessor( File storeFile, LAYOUT layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) throws IOException; IndexSamplingConfig samplingConfig ) throws IOException;


@Override @Override
Expand Down
Expand Up @@ -40,7 +40,7 @@
/** /**
* Schema index provider for native indexes backed by e.g. {@link GBPTree}. * Schema index provider for native indexes backed by e.g. {@link GBPTree}.
*/ */
public class NumberIndexProvider extends NativeIndexProvider<NumberIndexKey,NativeIndexValue> public class NumberIndexProvider extends NativeIndexProvider<NumberIndexKey,NativeIndexValue,NumberLayout>
{ {
public static final String KEY = "native"; public static final String KEY = "native";
public static final IndexProviderDescriptor NATIVE_PROVIDER_DESCRIPTOR = new IndexProviderDescriptor( KEY, "1.0" ); public static final IndexProviderDescriptor NATIVE_PROVIDER_DESCRIPTOR = new IndexProviderDescriptor( KEY, "1.0" );
Expand All @@ -54,7 +54,7 @@ public NumberIndexProvider( PageCache pageCache, FileSystemAbstraction fs,
} }


@Override @Override
IndexLayout<NumberIndexKey,NativeIndexValue> layout( StoreIndexDescriptor descriptor, File storeFile ) NumberLayout layout( StoreIndexDescriptor descriptor, File storeFile )
{ {
// split like this due to legacy reasons, there are old stores out there with these different identifiers // split like this due to legacy reasons, there are old stores out there with these different identifiers
switch ( descriptor.type() ) switch ( descriptor.type() )
Expand All @@ -69,14 +69,14 @@ IndexLayout<NumberIndexKey,NativeIndexValue> layout( StoreIndexDescriptor descri
} }


@Override @Override
protected IndexPopulator newIndexPopulator( File storeFile, IndexLayout<NumberIndexKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexPopulator newIndexPopulator( File storeFile, NumberLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) IndexSamplingConfig samplingConfig )
{ {
return new NumberIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig ); return new NumberIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig );
} }


@Override @Override
protected IndexAccessor newIndexAccessor( File storeFile, IndexLayout<NumberIndexKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexAccessor newIndexAccessor( File storeFile, NumberLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) throws IOException IndexSamplingConfig samplingConfig ) throws IOException
{ {
return new NumberIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, return new NumberIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
Expand Down
Expand Up @@ -41,7 +41,7 @@
/** /**
* Schema index provider for native indexes backed by e.g. {@link GBPTree}. * Schema index provider for native indexes backed by e.g. {@link GBPTree}.
*/ */
public class StringIndexProvider extends NativeIndexProvider<StringIndexKey,NativeIndexValue> public class StringIndexProvider extends NativeIndexProvider<StringIndexKey,NativeIndexValue,StringLayout>
{ {
public static final String KEY = "string"; public static final String KEY = "string";
static final IndexCapability CAPABILITY = new StringIndexCapability(); static final IndexCapability CAPABILITY = new StringIndexCapability();
Expand All @@ -55,20 +55,20 @@ public StringIndexProvider( PageCache pageCache, FileSystemAbstraction fs,
} }


@Override @Override
IndexLayout<StringIndexKey,NativeIndexValue> layout( StoreIndexDescriptor descriptor, File storeFile ) StringLayout layout( StoreIndexDescriptor descriptor, File storeFile )
{ {
return new StringLayout(); return new StringLayout();
} }


@Override @Override
protected IndexPopulator newIndexPopulator( File storeFile, IndexLayout<StringIndexKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexPopulator newIndexPopulator( File storeFile, StringLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) IndexSamplingConfig samplingConfig )
{ {
return new StringIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig ); return new StringIndexPopulator( pageCache, fs, storeFile, layout, monitor, descriptor, samplingConfig );
} }


@Override @Override
protected IndexAccessor newIndexAccessor( File storeFile, IndexLayout<StringIndexKey,NativeIndexValue> layout, StoreIndexDescriptor descriptor, protected IndexAccessor newIndexAccessor( File storeFile, StringLayout layout, StoreIndexDescriptor descriptor,
IndexSamplingConfig samplingConfig ) throws IOException IndexSamplingConfig samplingConfig ) throws IOException
{ {
return new StringIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, samplingConfig ); return new StringIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor, samplingConfig );
Expand Down

0 comments on commit 6f63cae

Please sign in to comment.