private static IndexEntryUpdate<SchemaDescriptor> add( long nodeId, SchemaDescriptor schema, Value value1, Value value2 ) { return IndexEntryUpdate.add( nodeId, schema, value1, value2 ); } }
protected IndexEntryUpdate<IndexDescriptor> add( long nodeId, Value value ) { return IndexEntryUpdate.add( nodeId, indexDescriptor, value ); }
private long addPointsToLists( List<Value> pointValues, List<IndexEntryUpdate<?>> updates, long nodeId, PointValue... values ) { for ( PointValue value : values ) { pointValues.add( value ); updates.add( IndexEntryUpdate.add( nodeId++, descriptor, value ) ); } return nodeId; }
public static IndexEntryUpdate<SchemaDescriptor> add( long nodeId, SchemaDescriptor schema, Object... objects ) { return IndexEntryUpdate.add( nodeId, schema, toValues( objects ) ); }
List<IndexEntryUpdate<?>> updates( List<NodeAndValue> values, long nodeIdOffset ) { List<IndexEntryUpdate<?>> updates = new ArrayList<>(); values.forEach( entry -> updates.add( IndexEntryUpdate.add( nodeIdOffset + entry.nodeId, descriptor.schema(), entry.value ) ) ); return updates; }
List<? extends IndexEntryUpdate<?>> batch() { int n = randomValues.nextInt( maxBatchSize ) + 1; List<IndexEntryUpdate<?>> updates = new ArrayList<>( n ); for ( int i = 0; i < n; i++ ) { updates.add( add( nextEntityId++, descriptor, valueGenerator.apply( randomValues ) ) ); } return updates; } }
private IndexEntryUpdate<IndexDescriptor> simpleUpdate() { return IndexEntryUpdate.add( 0, indexDescriptor, of( 0 ) ); }
@Override public Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator() { List<IndexEntryUpdate<SchemaDescriptor>> updates = new ArrayList<>(); for ( long nodeId : nodeIds ) { updates.add( IndexEntryUpdate.add( nodeId, index.schema(), Values.of( 1 ) ) ); } return updates.iterator(); }
@Test public void addShouldRetainValues() { IndexEntryUpdate<?> single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); IndexEntryUpdate<?> multi = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); assertThat( single, not( equalTo( multi ) ) ); assertThat( single.values(), equalTo( new Object[]{singleValue} ) ); assertThat( multi.values(), equalTo( multiValue ) ); }
@Test public void indexEntryUpdatesShouldBeEqual() { IndexEntryUpdate<?> a = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); IndexEntryUpdate<?> b = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); assertThat( a, equalTo( b ) ); assertThat( a.hashCode(), equalTo( b.hashCode() ) ); }
private IndexEntryUpdate<?> add( long nodeId, Object value ) { return IndexEntryUpdate.add( nodeId, descriptor.schema(), Values.of( value ) ); } }
private IndexEntryUpdate<LabelSchemaDescriptor> someUpdate() { return IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 0, 0 ), Values.numberValue( 0 ) ); } }
private IndexEntryUpdate<?> add( long nodeId, Object value ) { return IndexEntryUpdate.add( nodeId, descriptor.schema(), Values.of( value ) ); }
private IndexEntryUpdate<SchemaDescriptor> add( long nodeId, Object propertyValue ) { return IndexEntryUpdate.add( nodeId, index.schema(), Values.of( propertyValue ) ); }
@Test public void shouldGenerateUpdateWhenAddingOneTokenForNonSchemaIndex() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ).withTokensAfter( label ).build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, nonSchemaIndex, values123 ) ) ); }
@Test public void shouldGenerateUpdateWhenAddingMultipleTokensForNonSchemaIndex() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ).withTokensAfter( allLabels ).build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, nonSchemaIndex, values123 ) ) ); }
@Test public void addShouldThrowIfAskedForChanged() { IndexEntryUpdate<?> single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); thrown.expect( UnsupportedOperationException.class ); single.beforeValues(); }
private IndexEntryUpdate<SchemaDescriptor> add( long nodeId, Object propertyValue, int labelId ) { LabelSchemaDescriptor schema = forLabel( labelId, index.schema().getPropertyId() ); return IndexEntryUpdate.add( nodeId, schema, Values.of( propertyValue ) ); }
@Test public void shouldGenerateUpdateForLabelAdditionWithExistingProperty() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ).withTokensAfter( label ).build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader( property1 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ) ) ); }