Skip to content

Commit

Permalink
Rename NumberKey/Value to SchemaNumberKey/Value
Browse files Browse the repository at this point in the history
To avoid name conflict with values.NumberValue
  • Loading branch information
burqen authored and tinwelint committed Jun 27, 2017
1 parent e1864ed commit 6e70257
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 86 deletions.
Expand Up @@ -30,7 +30,7 @@
* *
* @param <VALUE> type of values being merged. * @param <VALUE> type of values being merged.
*/ */
class ConflictDetectingValueMerger<KEY extends NumberKey, VALUE extends NumberValue> implements ValueMerger<KEY,VALUE> class ConflictDetectingValueMerger<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> implements ValueMerger<KEY,VALUE>
{ {
private boolean conflict; private boolean conflict;
private long existingNodeId; private long existingNodeId;
Expand Down
Expand Up @@ -37,7 +37,7 @@
* @param <KEY> type of keys in tree. * @param <KEY> type of keys in tree.
* @param <VALUE> type of values in tree. * @param <VALUE> type of values in tree.
*/ */
class FullScanNonUniqueIndexSampler<KEY extends NumberKey, VALUE extends NumberValue> class FullScanNonUniqueIndexSampler<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends NonUniqueIndexSampler.Adapter extends NonUniqueIndexSampler.Adapter
{ {
private final GBPTree<KEY,VALUE> gbpTree; private final GBPTree<KEY,VALUE> gbpTree;
Expand Down
Expand Up @@ -34,7 +34,7 @@
/** /**
* {@link NativeSchemaNumberIndexPopulator} which can accept duplicate values (for different entity ids). * {@link NativeSchemaNumberIndexPopulator} which can accept duplicate values (for different entity ids).
*/ */
class NativeNonUniqueSchemaNumberIndexPopulator<KEY extends NumberKey, VALUE extends NumberValue> class NativeNonUniqueSchemaNumberIndexPopulator<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends NativeSchemaNumberIndexPopulator<KEY,VALUE> extends NativeSchemaNumberIndexPopulator<KEY,VALUE>
{ {
private final IndexSamplingConfig samplingConfig; private final IndexSamplingConfig samplingConfig;
Expand Down
Expand Up @@ -32,7 +32,7 @@
import static org.neo4j.index.internal.gbptree.GBPTree.NO_HEADER_WRITER; import static org.neo4j.index.internal.gbptree.GBPTree.NO_HEADER_WRITER;
import static org.neo4j.index.internal.gbptree.GBPTree.NO_MONITOR; import static org.neo4j.index.internal.gbptree.GBPTree.NO_MONITOR;


class NativeSchemaNumberIndex<KEY extends NumberKey, VALUE extends NumberValue> class NativeSchemaNumberIndex<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
{ {
final PageCache pageCache; final PageCache pageCache;
final File storeFile; final File storeFile;
Expand Down
Expand Up @@ -40,7 +40,7 @@
import static org.neo4j.helpers.collection.Iterators.asResourceIterator; import static org.neo4j.helpers.collection.Iterators.asResourceIterator;
import static org.neo4j.helpers.collection.Iterators.iterator; import static org.neo4j.helpers.collection.Iterators.iterator;


public class NativeSchemaNumberIndexAccessor<KEY extends NumberKey, VALUE extends NumberValue> public class NativeSchemaNumberIndexAccessor<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends NativeSchemaNumberIndex<KEY,VALUE> implements IndexAccessor extends NativeSchemaNumberIndex<KEY,VALUE> implements IndexAccessor
{ {
private final NativeSchemaNumberIndexUpdater<KEY,VALUE> singleUpdater; private final NativeSchemaNumberIndexUpdater<KEY,VALUE> singleUpdater;
Expand Down
Expand Up @@ -40,10 +40,10 @@
/** /**
* {@link IndexPopulator} backed by a {@link GBPTree}. * {@link IndexPopulator} backed by a {@link GBPTree}.
* *
* @param <KEY> type of {@link NumberKey}. * @param <KEY> type of {@link SchemaNumberKey}.
* @param <VALUE> type of {@link NumberValue}. * @param <VALUE> type of {@link SchemaNumberValue}.
*/ */
public abstract class NativeSchemaNumberIndexPopulator<KEY extends NumberKey, VALUE extends NumberValue> public abstract class NativeSchemaNumberIndexPopulator<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends NativeSchemaNumberIndex<KEY,VALUE> implements IndexPopulator extends NativeSchemaNumberIndex<KEY,VALUE> implements IndexPopulator
{ {
static final byte BYTE_ONLINE = 1; static final byte BYTE_ONLINE = 1;
Expand Down
Expand Up @@ -41,7 +41,7 @@
import org.neo4j.values.Value; import org.neo4j.values.Value;
import org.neo4j.values.Values; import org.neo4j.values.Values;


class NativeSchemaNumberIndexReader<KEY extends NumberKey, VALUE extends NumberValue> class NativeSchemaNumberIndexReader<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
implements IndexReader implements IndexReader
{ {
private final GBPTree<KEY,VALUE> tree; private final GBPTree<KEY,VALUE> tree;
Expand Down
Expand Up @@ -28,7 +28,7 @@
import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.values.ValueTuple; import org.neo4j.values.ValueTuple;


class NativeSchemaNumberIndexUpdater<KEY extends NumberKey, VALUE extends NumberValue> class NativeSchemaNumberIndexUpdater<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
implements IndexUpdater implements IndexUpdater
{ {
private final KEY treeKey; private final KEY treeKey;
Expand Down Expand Up @@ -103,7 +103,7 @@ private void assertOpen()
} }
} }


private static <KEY extends NumberKey, VALUE extends NumberValue> void processRemove( KEY treeKey, private static <KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> void processRemove( KEY treeKey,
IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer ) throws IOException IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer ) throws IOException
{ {
// todo Do we need to verify that we actually removed something at all? // todo Do we need to verify that we actually removed something at all?
Expand All @@ -112,7 +112,7 @@ private static <KEY extends NumberKey, VALUE extends NumberValue> void processRe
writer.remove( treeKey ); writer.remove( treeKey );
} }


private static <KEY extends NumberKey, VALUE extends NumberValue> void processChange( KEY treeKey, VALUE treeValue, private static <KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> void processChange( KEY treeKey, VALUE treeValue,
IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer, IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer,
ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger )
throws IOException, IndexEntryConflictException throws IOException, IndexEntryConflictException
Expand All @@ -127,7 +127,7 @@ private static <KEY extends NumberKey, VALUE extends NumberValue> void processCh
assertNoConflict( update, conflictDetectingValueMerger ); assertNoConflict( update, conflictDetectingValueMerger );
} }


static <KEY extends NumberKey, VALUE extends NumberValue> void processAdd( KEY treeKey, VALUE treeValue, static <KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> void processAdd( KEY treeKey, VALUE treeValue,
IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer, IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer,
ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger )
throws IOException, IndexEntryConflictException throws IOException, IndexEntryConflictException
Expand All @@ -138,7 +138,7 @@ static <KEY extends NumberKey, VALUE extends NumberValue> void processAdd( KEY t
assertNoConflict( update, conflictDetectingValueMerger ); assertNoConflict( update, conflictDetectingValueMerger );
} }


private static <KEY extends NumberKey, VALUE extends NumberValue> void assertNoConflict( IndexEntryUpdate<?> update, private static <KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> void assertNoConflict( IndexEntryUpdate<?> update,
ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) throws IndexEntryConflictException ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) throws IndexEntryConflictException
{ {
if ( conflictDetectingValueMerger.wasConflict() ) if ( conflictDetectingValueMerger.wasConflict() )
Expand Down
Expand Up @@ -30,7 +30,7 @@
/** /**
* {@link NativeSchemaNumberIndexPopulator} which can enforces unique values. * {@link NativeSchemaNumberIndexPopulator} which can enforces unique values.
*/ */
class NativeUniqueSchemaNumberIndexPopulator<KEY extends NumberKey, VALUE extends NumberValue> class NativeUniqueSchemaNumberIndexPopulator<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends NativeSchemaNumberIndexPopulator<KEY,VALUE> extends NativeSchemaNumberIndexPopulator<KEY,VALUE>
{ {
private final UniqueIndexSampler sampler; private final UniqueIndexSampler sampler;
Expand Down
Expand Up @@ -28,11 +28,11 @@ public class NonUniqueNumberLayout extends NumberLayout
@Override @Override
public long identifier() public long identifier()
{ {
return Layout.namedIdentifier( IDENTIFIER_NAME, NumberValue.SIZE ); return Layout.namedIdentifier( IDENTIFIER_NAME, SchemaNumberValue.SIZE );
} }


@Override @Override
public int compare( NumberKey o1, NumberKey o2 ) public int compare( SchemaNumberKey o1, SchemaNumberKey o2 )
{ {
int comparison = o1.compareValueTo( o2 ); int comparison = o1.compareValueTo( o2 );
return comparison != 0 ? comparison : Long.compare( o1.entityId, o2.entityId ); return comparison != 0 ? comparison : Long.compare( o1.entityId, o2.entityId );
Expand Down
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.index.internal.gbptree.Hit; import org.neo4j.index.internal.gbptree.Hit;
import org.neo4j.index.internal.gbptree.Layout; import org.neo4j.index.internal.gbptree.Layout;


class NumberAllEntriesReader<KEY extends NumberKey,VALUE extends NumberValue> implements BoundedIterable<Long> class NumberAllEntriesReader<KEY extends SchemaNumberKey,VALUE extends SchemaNumberValue> implements BoundedIterable<Long>
{ {
private final GBPTree<KEY,VALUE> tree; private final GBPTree<KEY,VALUE> tree;
private final Layout<KEY,VALUE> layout; private final Layout<KEY,VALUE> layout;
Expand Down
Expand Up @@ -33,10 +33,10 @@
* The {@link RawCursor seeker} which gets passed in will have to be closed somewhere else because * The {@link RawCursor seeker} which gets passed in will have to be closed somewhere else because
* the {@link PrimitiveLongIterator} is just a plain iterator, no resource. * the {@link PrimitiveLongIterator} is just a plain iterator, no resource.
* *
* @param <KEY> type of {@link NumberKey}. * @param <KEY> type of {@link SchemaNumberKey}.
* @param <VALUE> type of {@link NumberValue}. * @param <VALUE> type of {@link SchemaNumberValue}.
*/ */
public class NumberHitIterator<KEY extends NumberKey, VALUE extends NumberValue> public class NumberHitIterator<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
extends PrimitiveLongCollections.PrimitiveLongBaseIterator extends PrimitiveLongCollections.PrimitiveLongBaseIterator
{ {
private final RawCursor<Hit<KEY,VALUE>,IOException> seeker; private final RawCursor<Hit<KEY,VALUE>,IOException> seeker;
Expand Down
Expand Up @@ -25,17 +25,17 @@
/** /**
* {@link Layout} for numbers where numbers doesn't need to be unique. * {@link Layout} for numbers where numbers doesn't need to be unique.
*/ */
abstract class NumberLayout implements Layout<NumberKey,NumberValue> abstract class NumberLayout implements Layout<SchemaNumberKey,SchemaNumberValue>
{ {
@Override @Override
public NumberKey newKey() public SchemaNumberKey newKey()
{ {
return new NumberKey(); return new SchemaNumberKey();
} }


@Override @Override
public NumberKey copyKey( NumberKey key, public SchemaNumberKey copyKey( SchemaNumberKey key,
NumberKey into ) SchemaNumberKey into )
{ {
into.type = key.type; into.type = key.type;
into.rawValueBits = key.rawValueBits; into.rawValueBits = key.rawValueBits;
Expand All @@ -45,46 +45,46 @@ public NumberKey copyKey( NumberKey key,
} }


@Override @Override
public NumberValue newValue() public SchemaNumberValue newValue()
{ {
return NumberValue.INSTANCE; return SchemaNumberValue.INSTANCE;
} }


@Override @Override
public int keySize() public int keySize()
{ {
return NumberKey.SIZE; return SchemaNumberKey.SIZE;
} }


@Override @Override
public int valueSize() public int valueSize()
{ {
return NumberValue.SIZE; return SchemaNumberValue.SIZE;
} }


@Override @Override
public void writeKey( PageCursor cursor, NumberKey key ) public void writeKey( PageCursor cursor, SchemaNumberKey key )
{ {
cursor.putByte( key.type ); cursor.putByte( key.type );
cursor.putLong( key.rawValueBits ); cursor.putLong( key.rawValueBits );
cursor.putLong( key.entityId ); cursor.putLong( key.entityId );
} }


@Override @Override
public void writeValue( PageCursor cursor, NumberValue value ) public void writeValue( PageCursor cursor, SchemaNumberValue value )
{ {
} }


@Override @Override
public void readKey( PageCursor cursor, NumberKey into ) public void readKey( PageCursor cursor, SchemaNumberKey into )
{ {
into.type = cursor.getByte(); into.type = cursor.getByte();
into.rawValueBits = cursor.getLong(); into.rawValueBits = cursor.getLong();
into.entityId = cursor.getLong(); into.entityId = cursor.getLong();
} }


@Override @Override
public void readValue( PageCursor cursor, NumberValue into ) public void readValue( PageCursor cursor, SchemaNumberValue into )
{ {
} }


Expand Down
Expand Up @@ -22,9 +22,9 @@
import org.neo4j.values.Value; import org.neo4j.values.Value;
import org.neo4j.values.Values; import org.neo4j.values.Values;


import static org.neo4j.kernel.impl.index.schema.NumberKey.TYPE_DOUBLE; import static org.neo4j.kernel.impl.index.schema.SchemaNumberKey.TYPE_DOUBLE;
import static org.neo4j.kernel.impl.index.schema.NumberKey.TYPE_FLOAT; import static org.neo4j.kernel.impl.index.schema.SchemaNumberKey.TYPE_FLOAT;
import static org.neo4j.kernel.impl.index.schema.NumberKey.TYPE_LONG; import static org.neo4j.kernel.impl.index.schema.SchemaNumberKey.TYPE_LONG;


/** /**
* Utilities for converting number values to and from different representations. * Utilities for converting number values to and from different representations.
Expand Down
Expand Up @@ -19,8 +19,8 @@
*/ */
package org.neo4j.kernel.impl.index.schema; package org.neo4j.kernel.impl.index.schema;


import org.neo4j.values.Value;
import org.neo4j.index.internal.gbptree.GBPTree; import org.neo4j.index.internal.gbptree.GBPTree;
import org.neo4j.values.Value;


import static org.neo4j.kernel.impl.index.schema.NumberValueConversion.assertValidSingleNumber; import static org.neo4j.kernel.impl.index.schema.NumberValueConversion.assertValidSingleNumber;


Expand All @@ -32,7 +32,7 @@
* Distinction between double and float exists because coersions between each other and long may differ. * 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. * TODO this should be figured out and potentially reduced to long, double types only.
*/ */
class NumberKey class SchemaNumberKey
{ {
static final int SIZE = static final int SIZE =
Byte.BYTES + /* type of value */ Byte.BYTES + /* type of value */
Expand Down Expand Up @@ -90,10 +90,10 @@ void initAsHighest()
* Compares the value of this key to that of another key. * 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). * This method is expected to be called in scenarios where inconsistent reads may happen (and later retried).
* *
* @param other the {@link NumberKey} to compare to. * @param other the {@link SchemaNumberKey} to compare to.
* @return comparison against the {@code other} {@link NumberKey}. * @return comparison against the {@code other} {@link SchemaNumberKey}.
*/ */
int compareValueTo( NumberKey other ) int compareValueTo( SchemaNumberKey other )
{ {
return type == TYPE_LONG && other.type == TYPE_LONG return type == TYPE_LONG && other.type == TYPE_LONG
// If both are long values then compare them directly, w/o going through double. // If both are long values then compare them directly, w/o going through double.
Expand Down Expand Up @@ -129,7 +129,7 @@ private double doubleValue()
} }


/** /**
* Extracts data from a {@link Number} into state of this {@link NumberKey} instance. * Extracts data from a {@link Number} into state of this {@link SchemaNumberKey} instance.
* *
* @param value actual {@link Number} value. * @param value actual {@link Number} value.
*/ */
Expand Down
Expand Up @@ -25,16 +25,16 @@
/** /**
* Value in a {@link GBPTree} handling numbers suitable for schema indexing. * Value in a {@link GBPTree} handling numbers suitable for schema indexing.
* *
* NOTE: For the time being no data exists in {@link NumberValue}, but since the layout is under development * NOTE: For the time being no data exists in {@link SchemaNumberValue}, but since the layout is under development
* it's very convenient to have this class still exist so that it's very easy to try out different types * it's very convenient to have this class still exist so that it's very easy to try out different types
* of layouts without changing the entire stack of arguments. In the end it may just be that this class * of layouts without changing the entire stack of arguments. In the end it may just be that this class
* will be deleted, but for now it sticks around. * will be deleted, but for now it sticks around.
*/ */
class NumberValue class SchemaNumberValue
{ {
static final int SIZE = 0; static final int SIZE = 0;


static final NumberValue INSTANCE = new NumberValue(); static final SchemaNumberValue INSTANCE = new SchemaNumberValue();


void from( Value[] values ) void from( Value[] values )
{ {
Expand Down
Expand Up @@ -32,11 +32,11 @@ class UniqueNumberLayout extends NumberLayout
public long identifier() public long identifier()
{ {
// todo Is Number.Value.SIZE a good checksum? // todo Is Number.Value.SIZE a good checksum?
return Layout.namedIdentifier( IDENTIFIER_NAME, NumberKey.SIZE ); return Layout.namedIdentifier( IDENTIFIER_NAME, SchemaNumberKey.SIZE );
} }


@Override @Override
public int compare( NumberKey o1, NumberKey o2 ) public int compare( SchemaNumberKey o1, SchemaNumberKey o2 )
{ {
int comparison = o1.compareValueTo( o2 ); int comparison = o1.compareValueTo( o2 );
if ( comparison == 0 ) if ( comparison == 0 )
Expand Down
Expand Up @@ -31,7 +31,7 @@


public class ConflictDetectingValueMergerTest public class ConflictDetectingValueMergerTest
{ {
private final ConflictDetectingValueMerger<NumberKey,NumberValue> detector = new ConflictDetectingValueMerger<>(); private final ConflictDetectingValueMerger<SchemaNumberKey,SchemaNumberValue> detector = new ConflictDetectingValueMerger<>();


@Test @Test
public void shouldReportConflictOnSameValueAndDifferentEntityIds() throws Exception public void shouldReportConflictOnSameValueAndDifferentEntityIds() throws Exception
Expand All @@ -42,11 +42,11 @@ public void shouldReportConflictOnSameValueAndDifferentEntityIds() throws Except
long entityId2 = 20; long entityId2 = 20;


// when // when
NumberValue merged = detector.merge( SchemaNumberValue merged = detector.merge(
key( entityId1, value ), key( entityId1, value ),
key( entityId2, value ), key( entityId2, value ),
NumberValue.INSTANCE, SchemaNumberValue.INSTANCE,
NumberValue.INSTANCE ); SchemaNumberValue.INSTANCE );


// then // then
assertNull( merged ); assertNull( merged );
Expand All @@ -63,20 +63,20 @@ public void shouldNotReportConflictOnSameValueSameEntityId() throws Exception
long entityId = 10; long entityId = 10;


// when // when
NumberValue merged = detector.merge( SchemaNumberValue merged = detector.merge(
key( entityId, value ), key( entityId, value ),
key( entityId, value ), key( entityId, value ),
NumberValue.INSTANCE, SchemaNumberValue.INSTANCE,
NumberValue.INSTANCE ); SchemaNumberValue.INSTANCE );


// then // then
assertNull( merged ); assertNull( merged );
assertFalse( detector.wasConflict() ); assertFalse( detector.wasConflict() );
} }


private static NumberKey key( long entityId, Value... value ) private static SchemaNumberKey key( long entityId, Value... value )
{ {
NumberKey key = new NumberKey(); SchemaNumberKey key = new SchemaNumberKey();
key.from( entityId, value ); key.from( entityId, value );
return key; return key;
} }
Expand Down

0 comments on commit 6e70257

Please sign in to comment.