Skip to content

Commit

Permalink
Variable name change layoutUtil -> valueCreatorUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Oct 3, 2018
1 parent 093dff9 commit 6e801ca
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 60 deletions.
Expand Up @@ -157,7 +157,7 @@ public void shouldIndexChange() throws Exception
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleType(); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleType();
processAll( updates ); processAll( updates );
Iterator<IndexEntryUpdate<IndexDescriptor>> generator = filter( skipExisting( updates ), layoutUtil.randomUpdateGenerator( random ) ); Iterator<IndexEntryUpdate<IndexDescriptor>> generator = filter( skipExisting( updates ), valueCreatorUtil.randomUpdateGenerator( random ) );


for ( int i = 0; i < updates.length; i++ ) for ( int i = 0; i < updates.length; i++ )
{ {
Expand Down Expand Up @@ -200,7 +200,7 @@ public void shouldHandleRandomUpdates() throws Exception
{ {
// given // given
Set<IndexEntryUpdate<IndexDescriptor>> expectedData = new HashSet<>(); Set<IndexEntryUpdate<IndexDescriptor>> expectedData = new HashSet<>();
Iterator<IndexEntryUpdate<IndexDescriptor>> newDataGenerator = layoutUtil.randomUpdateGenerator( random ); Iterator<IndexEntryUpdate<IndexDescriptor>> newDataGenerator = valueCreatorUtil.randomUpdateGenerator( random );


// when // when
int rounds = 50; int rounds = 50;
Expand Down Expand Up @@ -229,8 +229,8 @@ public void shouldReturnZeroCountForEmptyIndex()
try ( IndexReader reader = accessor.newReader() ) try ( IndexReader reader = accessor.newReader() )
{ {
// when // when
IndexEntryUpdate<IndexDescriptor> update = layoutUtil.randomUpdateGenerator( random ).next(); IndexEntryUpdate<IndexDescriptor> update = valueCreatorUtil.randomUpdateGenerator( random ).next();
long count = reader.countIndexedNodes( 123, layoutUtil.indexDescriptor.properties(), update.values()[0] ); long count = reader.countIndexedNodes( 123, valueCreatorUtil.indexDescriptor.properties(), update.values()[0] );


// then // then
assertEquals( 0, count ); assertEquals( 0, count );
Expand All @@ -249,15 +249,15 @@ public void shouldReturnCountOneForExistingData() throws Exception
{ {
for ( IndexEntryUpdate<IndexDescriptor> update : updates ) for ( IndexEntryUpdate<IndexDescriptor> update : updates )
{ {
long count = reader.countIndexedNodes( update.getEntityId(), layoutUtil.indexDescriptor.properties(), update.values() ); long count = reader.countIndexedNodes( update.getEntityId(), valueCreatorUtil.indexDescriptor.properties(), update.values() );


// then // then
assertEquals( 1, count ); assertEquals( 1, count );
} }


// and when // and when
Iterator<IndexEntryUpdate<IndexDescriptor>> generator = filter( skipExisting( updates ), layoutUtil.randomUpdateGenerator( random ) ); Iterator<IndexEntryUpdate<IndexDescriptor>> generator = filter( skipExisting( updates ), valueCreatorUtil.randomUpdateGenerator( random ) );
long count = reader.countIndexedNodes( 123, layoutUtil.indexDescriptor.properties(), generator.next().values()[0] ); long count = reader.countIndexedNodes( 123, valueCreatorUtil.indexDescriptor.properties(), generator.next().values()[0] );


// then // then
assertEquals( 0, count ); assertEquals( 0, count );
Expand All @@ -276,7 +276,7 @@ public void shouldReturnCountZeroForMismatchingData() throws Exception


for ( IndexEntryUpdate<IndexDescriptor> update : updates ) for ( IndexEntryUpdate<IndexDescriptor> update : updates )
{ {
int[] propKeys = layoutUtil.indexDescriptor.properties(); int[] propKeys = valueCreatorUtil.indexDescriptor.properties();
long countWithMismatchingData = reader.countIndexedNodes( update.getEntityId() + 1, propKeys, update.values() ); long countWithMismatchingData = reader.countIndexedNodes( update.getEntityId() + 1, propKeys, update.values() );
long countWithNonExistentEntityId = reader.countIndexedNodes( NON_EXISTENT_ENTITY_ID, propKeys, update.values() ); long countWithNonExistentEntityId = reader.countIndexedNodes( NON_EXISTENT_ENTITY_ID, propKeys, update.values() );
long countWithNonExistentValue = reader.countIndexedNodes( update.getEntityId(), propKeys, generateUniqueValue( updates ) ); long countWithNonExistentValue = reader.countIndexedNodes( update.getEntityId(), propKeys, generateUniqueValue( updates ) );
Expand Down Expand Up @@ -352,12 +352,12 @@ public void shouldReturnMatchingEntriesForRangePredicateWithInclusiveStartAndExc
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() ); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() );
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();
LongIterator result = query( reader, LongIterator result = query( reader,
layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[updates.length - 1] ), false ) ); valueCreatorUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[updates.length - 1] ), false ) );
assertEntityIdHits( extractEntityIds( Arrays.copyOf( updates, updates.length - 1 ), alwaysTrue() ), result ); assertEntityIdHits( extractEntityIds( Arrays.copyOf( updates, updates.length - 1 ), alwaysTrue() ), result );
} }


Expand All @@ -373,12 +373,12 @@ void shouldReturnMatchingEntriesForRangePredicateWithInclusiveStartAndInclusiveE
throws IndexEntryConflictException, IndexNotApplicableKernelException throws IndexEntryConflictException, IndexNotApplicableKernelException
{ {
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();
LongIterator result = query( reader, LongIterator result = query( reader,
layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[updates.length - 1] ), true ) ); valueCreatorUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[updates.length - 1] ), true ) );
assertEntityIdHits( extractEntityIds( updates, alwaysTrue() ), result ); assertEntityIdHits( extractEntityIds( updates, alwaysTrue() ), result );
} }


Expand All @@ -388,12 +388,12 @@ public void shouldReturnMatchingEntriesForRangePredicateWithExclusiveStartAndExc
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() ); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() );
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();
LongIterator result = query( reader, LongIterator result = query( reader,
layoutUtil.rangeQuery( valueOf( updates[0] ), false, valueOf( updates[updates.length - 1] ), false ) ); valueCreatorUtil.rangeQuery( valueOf( updates[0] ), false, valueOf( updates[updates.length - 1] ), false ) );
assertEntityIdHits( extractEntityIds( Arrays.copyOfRange( updates, 1, updates.length - 1 ), alwaysTrue() ), result ); assertEntityIdHits( extractEntityIds( Arrays.copyOfRange( updates, 1, updates.length - 1 ), alwaysTrue() ), result );
} }


Expand All @@ -403,12 +403,12 @@ public void shouldReturnMatchingEntriesForRangePredicateWithExclusiveStartAndInc
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() ); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() );
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();
LongIterator result = query( reader, LongIterator result = query( reader,
layoutUtil.rangeQuery( valueOf( updates[0] ), false, valueOf( updates[updates.length - 1] ), true ) ); valueCreatorUtil.rangeQuery( valueOf( updates[0] ), false, valueOf( updates[updates.length - 1] ), true ) );
assertEntityIdHits( extractEntityIds( Arrays.copyOfRange( updates, 1, updates.length ), alwaysTrue() ), result ); assertEntityIdHits( extractEntityIds( Arrays.copyOfRange( updates, 1, updates.length ), alwaysTrue() ), result );
} }


Expand All @@ -417,13 +417,13 @@ public void shouldReturnNoEntriesForRangePredicateOutsideAnyMatch() throws Excep
{ {
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() ); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );
processAll( updates[0], updates[1], updates[updates.length - 1], updates[updates.length - 2] ); processAll( updates[0], updates[1], updates[updates.length - 1], updates[updates.length - 2] );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();
LongIterator result = query( reader, LongIterator result = query( reader,
layoutUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[updates.length - 3] ), true ) ); valueCreatorUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[updates.length - 3] ), true ) );
assertEntityIdHits( EMPTY_LONG_ARRAY, result ); assertEntityIdHits( EMPTY_LONG_ARRAY, result );
} }


Expand All @@ -438,13 +438,13 @@ public void mustHandleNestedQueries() throws Exception
void mustHandleNestedQueries( IndexEntryUpdate<IndexDescriptor>[] updates ) throws IndexEntryConflictException, IndexNotApplicableKernelException void mustHandleNestedQueries( IndexEntryUpdate<IndexDescriptor>[] updates ) throws IndexEntryConflictException, IndexNotApplicableKernelException
{ {
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();


IndexQuery outerQuery = layoutUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[3] ), true ); IndexQuery outerQuery = valueCreatorUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[3] ), true );
IndexQuery innerQuery = layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[1] ), true ); IndexQuery innerQuery = valueCreatorUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[1] ), true );


long[] expectedOuter = new long[]{entityIdOf( updates[2] ), entityIdOf( updates[3] )}; long[] expectedOuter = new long[]{entityIdOf( updates[2] ), entityIdOf( updates[3] )};
long[] expectedInner = new long[]{entityIdOf( updates[0] ), entityIdOf( updates[1] )}; long[] expectedInner = new long[]{entityIdOf( updates[0] ), entityIdOf( updates[1] )};
Expand Down Expand Up @@ -472,14 +472,14 @@ void mustHandleMultipleNestedQueries( IndexEntryUpdate<IndexDescriptor>[] update
throws IndexEntryConflictException, IndexNotApplicableKernelException throws IndexEntryConflictException, IndexNotApplicableKernelException
{ {
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );


// when // when
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();


IndexQuery query1 = layoutUtil.rangeQuery( valueOf( updates[4] ), true, valueOf( updates[5] ), true ); IndexQuery query1 = valueCreatorUtil.rangeQuery( valueOf( updates[4] ), true, valueOf( updates[5] ), true );
IndexQuery query2 = layoutUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[3] ), true ); IndexQuery query2 = valueCreatorUtil.rangeQuery( valueOf( updates[2] ), true, valueOf( updates[3] ), true );
IndexQuery query3 = layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[1] ), true ); IndexQuery query3 = valueCreatorUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[1] ), true );


long[] expected1 = new long[]{entityIdOf( updates[4] ), entityIdOf( updates[5] )}; long[] expected1 = new long[]{entityIdOf( updates[4] ), entityIdOf( updates[5] )};
long[] expected2 = new long[]{entityIdOf( updates[2] ), entityIdOf( updates[3] )}; long[] expected2 = new long[]{entityIdOf( updates[2] ), entityIdOf( updates[3] )};
Expand Down Expand Up @@ -710,13 +710,13 @@ public void shouldNotSeeFilteredEntries() throws Exception
// given // given
IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() ); IndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates( supportedTypesExcludingNonOrderable() );
processAll( updates ); processAll( updates );
layoutUtil.sort( updates ); valueCreatorUtil.sort( updates );
IndexReader reader = accessor.newReader(); IndexReader reader = accessor.newReader();


// when // when
NodeValueIterator iter = new NodeValueIterator(); NodeValueIterator iter = new NodeValueIterator();
IndexQuery.ExactPredicate filter = IndexQuery.exact( 0, valueOf( updates[1]) ); IndexQuery.ExactPredicate filter = IndexQuery.exact( 0, valueOf( updates[1]) );
IndexQuery rangeQuery = layoutUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[2] ), true ); IndexQuery rangeQuery = valueCreatorUtil.rangeQuery( valueOf( updates[0] ), true, valueOf( updates[2] ), true );
IndexProgressor.NodeValueClient filterClient = filterClient( iter, filter ); IndexProgressor.NodeValueClient filterClient = filterClient( iter, filter );
reader.query( filterClient, IndexOrder.NONE, false, rangeQuery ); reader.query( filterClient, IndexOrder.NONE, false, rangeQuery );


Expand All @@ -733,7 +733,7 @@ public void shouldNotSeeFilteredEntries() throws Exception
// // given // // given
// IndexEntryUpdate<IndexDescriptor>[] someUpdates = someUpdates(); // IndexEntryUpdate<IndexDescriptor>[] someUpdates = someUpdates();
// processAll( someUpdates ); // processAll( someUpdates );
// Value[] expectedValues = layoutUtil.extractValuesFromUpdates( someUpdates ); // Value[] expectedValues = valueCreatorUtil.extractValuesFromUpdates( someUpdates );
// //
// // when // // when
// IndexReader reader = accessor.newReader(); // IndexReader reader = accessor.newReader();
Expand Down Expand Up @@ -788,7 +788,7 @@ public void shouldNotSeeFilteredEntries() throws Exception


private Value generateUniqueValue( IndexEntryUpdate<IndexDescriptor>[] updates ) private Value generateUniqueValue( IndexEntryUpdate<IndexDescriptor>[] updates )
{ {
return filter( skipExisting( updates ), layoutUtil.randomUpdateGenerator( random ) ).next().values()[0]; return filter( skipExisting( updates ), valueCreatorUtil.randomUpdateGenerator( random ) ).next().values()[0];
} }


private static Predicate<IndexEntryUpdate<IndexDescriptor>> skipExisting( IndexEntryUpdate<IndexDescriptor>[] existing ) private static Predicate<IndexEntryUpdate<IndexDescriptor>> skipExisting( IndexEntryUpdate<IndexDescriptor>[] existing )
Expand Down Expand Up @@ -896,14 +896,14 @@ private void applyUpdatesToExpectedData( Set<IndexEntryUpdate<IndexDescriptor>>
switch ( update.updateMode() ) switch ( update.updateMode() )
{ {
case ADDED: case ADDED:
addition = layoutUtil.add( update.getEntityId(), update.values()[0] ); addition = valueCreatorUtil.add( update.getEntityId(), update.values()[0] );
break; break;
case CHANGED: case CHANGED:
addition = layoutUtil.add( update.getEntityId(), update.values()[0] ); addition = valueCreatorUtil.add( update.getEntityId(), update.values()[0] );
removal = layoutUtil.add( update.getEntityId(), update.beforeValues()[0] ); removal = valueCreatorUtil.add( update.getEntityId(), update.beforeValues()[0] );
break; break;
case REMOVED: case REMOVED:
removal = layoutUtil.add( update.getEntityId(), update.values()[0] ); removal = valueCreatorUtil.add( update.getEntityId(), update.values()[0] );
break; break;
default: default:
throw new IllegalArgumentException( update.updateMode().name() ); throw new IllegalArgumentException( update.updateMode().name() );
Expand Down Expand Up @@ -995,13 +995,13 @@ private IndexEntryUpdate<IndexDescriptor> simpleUpdate()


private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleType() private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleType()
{ {
RandomValues.Type type = randomValues.among( layoutUtil.supportedTypes() ); RandomValues.Type type = randomValues.among( valueCreatorUtil.supportedTypes() );
return someUpdatesOfTypes( true, type ); return someUpdatesOfTypes( true, type );
} }


private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleTypeNoDuplicates() private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleTypeNoDuplicates()
{ {
return someUpdatesSingleTypeNoDuplicates( layoutUtil.supportedTypes() ); return someUpdatesSingleTypeNoDuplicates( valueCreatorUtil.supportedTypes() );
} }


private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleTypeNoDuplicates( RandomValues.Type[] types ) private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleTypeNoDuplicates( RandomValues.Type[] types )
Expand All @@ -1018,7 +1018,7 @@ private IndexEntryUpdate<IndexDescriptor>[] someUpdatesSingleTypeNoDuplicates( R


IndexEntryUpdate<IndexDescriptor>[] someUpdates() IndexEntryUpdate<IndexDescriptor>[] someUpdates()
{ {
return someUpdatesOfTypes( true, layoutUtil.supportedTypes() ); return someUpdatesOfTypes( true, valueCreatorUtil.supportedTypes() );
} }


private IndexEntryUpdate<IndexDescriptor>[] someUpdatesOfTypes( boolean allowDuplicates, RandomValues.Type... types ) private IndexEntryUpdate<IndexDescriptor>[] someUpdatesOfTypes( boolean allowDuplicates, RandomValues.Type... types )
Expand All @@ -1037,12 +1037,12 @@ private IndexEntryUpdate<IndexDescriptor>[] someUpdatesOfTypes( boolean allowDup
values[i++] = value; values[i++] = value;
} }
} }
return layoutUtil.generateAddUpdatesFor( values ); return valueCreatorUtil.generateAddUpdatesFor( values );
} }


private RandomValues.Type[] supportedTypesExcludingNonOrderable() private RandomValues.Type[] supportedTypesExcludingNonOrderable()
{ {
return RandomValues.excluding( layoutUtil.supportedTypes(), return RandomValues.excluding( valueCreatorUtil.supportedTypes(),
t -> t.valueGroup == ValueGroup.GEOMETRY || t -> t.valueGroup == ValueGroup.GEOMETRY ||
t.valueGroup == ValueGroup.GEOMETRY_ARRAY || t.valueGroup == ValueGroup.GEOMETRY_ARRAY ||
t == RandomValues.Type.STRING || t == RandomValues.Type.STRING ||
Expand Down

0 comments on commit 6e801ca

Please sign in to comment.