Skip to content

Commit

Permalink
Improved on some javadoc and cut down on unnecessary generics
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and burqen committed Feb 15, 2018
1 parent 85cd232 commit 17ec64c
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 44 deletions.
Expand Up @@ -41,6 +41,12 @@
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.SchemaIndexProvider;

/**
* Base class for native indexes on top of {@link GBPTree}.
*
* @param <KEY> type of {@link NativeSchemaKey}
* @param <VALUE> type of {@link NativeSchemaValue}
*/
abstract class NativeSchemaIndexProvider<KEY extends NativeSchemaKey,VALUE extends NativeSchemaValue> extends SchemaIndexProvider
{
protected final PageCache pageCache;
Expand Down
Expand Up @@ -31,14 +31,13 @@
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.storageengine.api.schema.IndexReader;

public class NumberSchemaIndexAccessor<KEY extends NumberSchemaKey, VALUE extends NativeSchemaValue>
extends NativeSchemaIndexAccessor<KEY,VALUE>
public class NumberSchemaIndexAccessor extends NativeSchemaIndexAccessor<NumberSchemaKey,NativeSchemaValue>
{
NumberSchemaIndexAccessor(
PageCache pageCache,
FileSystemAbstraction fs,
File storeFile,
Layout<KEY,VALUE> layout,
Layout<NumberSchemaKey,NativeSchemaValue> layout,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector,
SchemaIndexProvider.Monitor monitor,
IndexDescriptor descriptor,
Expand Down
Expand Up @@ -68,7 +68,7 @@ protected NumberLayoutNonUnique layoutNonUnique()
protected IndexAccessor newIndexAccessor( File storeFile, Layout<NumberSchemaKey,NativeSchemaValue> layout, IndexDescriptor descriptor,
long indexId, IndexSamplingConfig samplingConfig ) throws IOException
{
return new NumberSchemaIndexAccessor<>( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
return new NumberSchemaIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
indexId, samplingConfig );
}

Expand Down
Expand Up @@ -27,7 +27,7 @@
import static org.neo4j.kernel.impl.index.schema.StringSchemaKey.ENTITY_ID_SIZE;

/**
* {@link Layout} for numbers where numbers doesn't need to be unique.
* {@link Layout} for strings.
*/
abstract class StringLayout extends Layout.Adapter<StringSchemaKey,NativeSchemaValue>
{
Expand Down
Expand Up @@ -21,6 +21,9 @@

import org.neo4j.index.internal.gbptree.Layout;

/**
* {@link Layout} for strings that doesn't need to be unique.
*/
public class StringLayoutNonUnique extends StringLayout
{
private static final String IDENTIFIER_NAME = "NUSI";
Expand Down
Expand Up @@ -22,7 +22,7 @@
import org.neo4j.index.internal.gbptree.Layout;

/**
* {@link Layout} for numbers where numbers need to be unique.
* {@link Layout} for strings that need to be unique.
*/
class StringLayoutUnique extends StringLayout
{
Expand Down
Expand Up @@ -26,19 +26,22 @@
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.api.index.IndexAccessor;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.storageengine.api.schema.IndexReader;

public class StringSchemaIndexAccessor<KEY extends StringSchemaKey, VALUE extends NativeSchemaValue>
extends NativeSchemaIndexAccessor<KEY,VALUE>
/**
* {@link IndexAccessor} using {@link StringLayout}, i.e for {@link String} values.
*/
public class StringSchemaIndexAccessor extends NativeSchemaIndexAccessor<StringSchemaKey,NativeSchemaValue>
{
StringSchemaIndexAccessor(
PageCache pageCache,
FileSystemAbstraction fs,
File storeFile,
Layout<KEY,VALUE> layout,
Layout<StringSchemaKey,NativeSchemaValue> layout,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector,
SchemaIndexProvider.Monitor monitor,
IndexDescriptor descriptor,
Expand All @@ -52,6 +55,6 @@ public class StringSchemaIndexAccessor<KEY extends StringSchemaKey, VALUE extend
public IndexReader newReader()
{
assertOpen();
return new StringSchemaIndexReader<>( tree, layout, samplingConfig, descriptor );
return new StringSchemaIndexReader( tree, layout, samplingConfig, descriptor );
}
}
Expand Up @@ -68,7 +68,7 @@ protected StringLayoutNonUnique layoutNonUnique()
protected IndexAccessor newIndexAccessor( File storeFile, Layout<StringSchemaKey,NativeSchemaValue> layout, IndexDescriptor descriptor,
long indexId, IndexSamplingConfig samplingConfig ) throws IOException
{
return new StringSchemaIndexAccessor<>( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
return new StringSchemaIndexAccessor( pageCache, fs, storeFile, layout, recoveryCleanupWorkCollector, monitor, descriptor,
indexId, samplingConfig );
}

Expand Down
Expand Up @@ -30,9 +30,10 @@
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.ValueGroup;

class StringSchemaIndexReader<KEY extends StringSchemaKey, VALUE extends NativeSchemaValue> extends NativeSchemaIndexReader<KEY,VALUE>
class StringSchemaIndexReader extends NativeSchemaIndexReader<StringSchemaKey,NativeSchemaValue>
{
StringSchemaIndexReader( GBPTree<KEY,VALUE> tree, Layout<KEY,VALUE> layout, IndexSamplingConfig samplingConfig, IndexDescriptor descriptor )
StringSchemaIndexReader( GBPTree<StringSchemaKey,NativeSchemaValue> tree, Layout<StringSchemaKey,NativeSchemaValue> layout,
IndexSamplingConfig samplingConfig, IndexDescriptor descriptor )
{
super( tree, layout, samplingConfig, descriptor );
}
Expand All @@ -52,7 +53,7 @@ void validateQuery( IndexOrder indexOrder, IndexQuery[] predicates )
}

@Override
void initializeRangeForQuery( KEY treeKeyFrom, KEY treeKeyTo, IndexQuery[] predicates )
void initializeRangeForQuery( StringSchemaKey treeKeyFrom, StringSchemaKey treeKeyTo, IndexQuery[] predicates )
{
// todo initialize the keys to prepare for seek
IndexQuery predicate = predicates[0];
Expand Down Expand Up @@ -80,7 +81,7 @@ void initializeRangeForQuery( KEY treeKeyFrom, KEY treeKeyTo, IndexQuery[] predi
}
}

private void initFromForRange( StringRangePredicate rangePredicate, KEY treeKeyFrom )
private void initFromForRange( StringRangePredicate rangePredicate, StringSchemaKey treeKeyFrom )
{
Value fromValue = rangePredicate.fromAsValue();
if ( fromValue.valueGroup() == ValueGroup.NO_VALUE )
Expand All @@ -94,7 +95,7 @@ private void initFromForRange( StringRangePredicate rangePredicate, KEY treeKeyF
}
}

private void initToForRange( StringRangePredicate rangePredicate, KEY treeKeyTo )
private void initToForRange( StringRangePredicate rangePredicate, StringSchemaKey treeKeyTo )
{
Value toValue = rangePredicate.toAsValue();
if ( toValue.valueGroup() == ValueGroup.NO_VALUE )
Expand Down
Expand Up @@ -21,6 +21,7 @@

import java.util.Arrays;

import org.neo4j.index.internal.gbptree.GBPTree;
import org.neo4j.string.UTF8;
import org.neo4j.values.storable.TextValue;
import org.neo4j.values.storable.Value;
Expand All @@ -32,12 +33,8 @@
import static org.neo4j.values.storable.UTF8StringValue.codePointByteArrayCompare;

/**
* Includes value and entity id (to be able to handle non-unique values).
* A value can be any {@link Number} and is represented as a {@code long} to store the raw bits and a type
* to say if it's a long, double or float.
*
* Distinction between double and float exists because coersions between each other and long may differ.
* TODO this should be figured out and potentially reduced to long, double types only.
* Includes value and entity id (to be able to handle non-unique values). A value can be any {@link String},
* or rather any string that {@link GBPTree} can handle.
*/
class StringSchemaKey extends ValueWriter.Adapter<RuntimeException> implements NativeSchemaKey
{
Expand Down Expand Up @@ -89,7 +86,6 @@ public void from( long entityId, Value... values )

private TextValue assertValidValue( Value... values )
{
// TODO: support multiple values, right?
if ( values.length > 1 )
{
throw new IllegalArgumentException( "Tried to create composite key with non-composite schema key layout" );
Expand Down Expand Up @@ -118,7 +114,7 @@ public Value asValue()
return bytes == null ? Values.NO_VALUE : Values.utf8Value( bytes );
}

// TODO perhaps merge into parent or something
// TODO perhaps merge these lowest/highest methods into parent
@Override
public void initAsLowest()
{
Expand All @@ -140,11 +136,6 @@ private boolean isHighest()
return entityIdIsSpecialTieBreaker && entityId == Long.MAX_VALUE && bytes == null;
}

private boolean isLowest()
{
return entityIdIsSpecialTieBreaker && entityId == Long.MIN_VALUE && bytes == null;
}

/**
* Compares the value of this key to that of another key.
* This method is expected to be called in scenarios where inconsistent reads may happen (and later retried).
Expand All @@ -170,6 +161,7 @@ int compareValueTo( StringSchemaKey other )
{
return 0;
}

try
{
// TODO change to not throw
Expand Down Expand Up @@ -223,13 +215,12 @@ public String toString()
@Override
public void writeString( String value )
{
// expensiveness
bytes = UTF8.encode( value );
}

@Override
public void writeString( char value )
{
throw new UnsupportedOperationException();
throw new UnsupportedOperationException( "Not supported a.t.m. should it be?" );
}
}
Expand Up @@ -19,7 +19,7 @@
*/
package org.neo4j.kernel.impl.index.schema;

public class NumberNonUniqueSchemaIndexAccessorTest extends NumberSchemaIndexAccessorTest<NumberSchemaKey,NativeSchemaValue>
public class NumberNonUniqueSchemaIndexAccessorTest extends NumberSchemaIndexAccessorTest
{
@Override
protected LayoutTestUtil<NumberSchemaKey,NativeSchemaValue> createLayoutTestUtil()
Expand Down
Expand Up @@ -40,13 +40,12 @@
import static org.junit.Assert.assertTrue;
import static org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.IMMEDIATE;

public abstract class NumberSchemaIndexAccessorTest<KEY extends NumberSchemaKey, VALUE extends NativeSchemaValue>
extends NativeSchemaIndexAccessorTest<KEY,VALUE>
public abstract class NumberSchemaIndexAccessorTest extends NativeSchemaIndexAccessorTest<NumberSchemaKey,NativeSchemaValue>
{
@Override
NativeSchemaIndexAccessor<KEY,VALUE> makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
NumberSchemaIndexAccessor makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
{
return new NumberSchemaIndexAccessor<>( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig );
return new NumberSchemaIndexAccessor( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig );
}

@Test
Expand Down
Expand Up @@ -19,8 +19,7 @@
*/
package org.neo4j.kernel.impl.index.schema;

public class NumberUniqueSchemaIndexAccessorTest
extends NumberSchemaIndexAccessorTest<NumberSchemaKey,NativeSchemaValue>
public class NumberUniqueSchemaIndexAccessorTest extends NumberSchemaIndexAccessorTest
{
@Override
protected LayoutTestUtil<NumberSchemaKey,NativeSchemaValue> createLayoutTestUtil()
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/
package org.neo4j.kernel.impl.index.schema;

public class StringNonUniqueSchemaIndexAccessorTest extends StringSchemaIndexAccessorTest<StringSchemaKey,NativeSchemaValue>
public class StringNonUniqueSchemaIndexAccessorTest extends StringSchemaIndexAccessorTest
{
@Override
protected LayoutTestUtil<StringSchemaKey,NativeSchemaValue> createLayoutTestUtil()
Expand Down
Expand Up @@ -24,13 +24,12 @@

import static org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.IMMEDIATE;

public abstract class StringSchemaIndexAccessorTest<KEY extends StringSchemaKey, VALUE extends NativeSchemaValue>
extends NativeSchemaIndexAccessorTest<KEY,VALUE>
public abstract class StringSchemaIndexAccessorTest extends NativeSchemaIndexAccessorTest<StringSchemaKey,NativeSchemaValue>
{
@Override
NativeSchemaIndexAccessor<KEY,VALUE> makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
StringSchemaIndexAccessor makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
{
return new StringSchemaIndexAccessor<>( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig );
return new StringSchemaIndexAccessor( pageCache, fs, indexFile, layout, IMMEDIATE, monitor, indexDescriptor, indexId, samplingConfig );
}

// TODO test reader unsupported index order
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/
package org.neo4j.kernel.impl.index.schema;

public class StringUniqueSchemaIndexAccessorTest extends StringSchemaIndexAccessorTest<StringSchemaKey,NativeSchemaValue>
public class StringUniqueSchemaIndexAccessorTest extends StringSchemaIndexAccessorTest
{
@Override
protected LayoutTestUtil<StringSchemaKey,NativeSchemaValue> createLayoutTestUtil()
Expand Down

0 comments on commit 17ec64c

Please sign in to comment.