@Override protected void changed( IndexEntryUpdate<?> update ) { String encodedValueBefore = LuceneDocumentStructure.encodedStringValuesForSampling( update.beforeValues() ); sampler.exclude( encodedValueBefore ); String encodedValueAfter = LuceneDocumentStructure.encodedStringValuesForSampling( update.values() ); sampler.include( encodedValueAfter ); }
@Test public void changedShouldRetainValues() { Value singleAfter = Values.of( "Hello" ); IndexEntryUpdate<?> singleChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue, singleAfter ); Value[] multiAfter = {Values.of( "Hello" ), Values.of( "Hi" )}; IndexEntryUpdate<?> multiChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue, multiAfter ); assertThat( new Object[]{singleValue}, equalTo( singleChange.beforeValues() ) ); assertThat( new Object[]{singleAfter}, equalTo( singleChange.values() ) ); assertThat( multiValue, equalTo( multiChange.beforeValues() ) ); assertThat( multiAfter, equalTo( multiChange.values() ) ); } }
@Test public void removeShouldThrowIfAskedForChanged() { IndexEntryUpdate<?> single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); thrown.expect( UnsupportedOperationException.class ); single.beforeValues(); }
@Test public void addShouldThrowIfAskedForChanged() { IndexEntryUpdate<?> single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); thrown.expect( UnsupportedOperationException.class ); single.beforeValues(); }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { IndexUpdater to = select( update.values()[0].valueGroup() ); switch ( update.updateMode() ) { case ADDED: case REMOVED: to.process( update ); break; case CHANGED: IndexUpdater from = select( update.beforeValues()[0].valueGroup() ); // There are two cases: // - both before/after go into the same updater --> pass update into that updater if ( from == to ) { from.process( update ); } // - before go into one and after into the other --> REMOVED from one and ADDED into the other else { from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) ); } break; default: throw new IllegalArgumentException( "Unknown update mode" ); } }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { IndexUpdater to = select( ((PointValue)update.values()[0]).getCoordinateReferenceSystem() ); switch ( update.updateMode() ) { case ADDED: case REMOVED: to.process( update ); break; case CHANGED: IndexUpdater from = select( ((PointValue) update.beforeValues()[0]).getCoordinateReferenceSystem() ); // There are two cases: // - both before/after go into the same updater --> pass update into that updater if ( from == to ) { from.process( update ); } // - before go into one and after into the other --> REMOVED from one and ADDED into the other else { from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) ); } break; default: throw new IllegalArgumentException( "Unknown update mode" ); } }
private static <KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> void processChange( KEY treeKey, VALUE treeValue, IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer, ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) throws IndexEntryConflictException { // Remove old entry initializeKeyFromUpdate( treeKey, update.getEntityId(), update.beforeValues() ); writer.remove( treeKey ); // Insert new entry initializeKeyFromUpdate( treeKey, update.getEntityId(), update.values() ); treeValue.from( update.values() ); conflictDetectingValueMerger.controlConflictDetection( treeKey ); writer.merge( treeKey, treeValue, conflictDetectingValueMerger ); conflictDetectingValueMerger.checkConflict( update.values() ); }
PointValue fromValue = (PointValue) update.beforeValues()[0]; IndexUpdater from = select( fromValue.getCoordinateReferenceSystem() ); IndexUpdater to = select( value.getCoordinateReferenceSystem() ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );
IndexUpdater from = select( update.beforeValues()[0].valueGroup() ); IndexUpdater to = select( update.values()[0].valueGroup() ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );
IndexUpdater from = instanceSelector.select( slotSelector.selectSlot( update.beforeValues(), GROUP_OF ) ); IndexUpdater to = instanceSelector.select( slotSelector.selectSlot( update.values(), GROUP_OF ) ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );
case CHANGED: addition = valueCreatorUtil.add( update.getEntityId(), update.values()[0] ); removal = valueCreatorUtil.add( update.getEntityId(), update.beforeValues()[0] ); break; case REMOVED:
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { IndexUpdater to = select( update.values()[0].valueGroup() ); switch ( update.updateMode() ) { case ADDED: case REMOVED: to.process( update ); break; case CHANGED: IndexUpdater from = select( update.beforeValues()[0].valueGroup() ); // There are two cases: // - both before/after go into the same updater --> pass update into that updater if ( from == to ) { from.process( update ); } // - before go into one and after into the other --> REMOVED from one and ADDED into the other else { from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) ); } break; default: throw new IllegalArgumentException( "Unknown update mode" ); } }
@Override public void process( IndexEntryUpdate<?> update ) throws IndexEntryConflictException { IndexUpdater to = select( ((PointValue)update.values()[0]).getCoordinateReferenceSystem() ); switch ( update.updateMode() ) { case ADDED: case REMOVED: to.process( update ); break; case CHANGED: IndexUpdater from = select( ((PointValue) update.beforeValues()[0]).getCoordinateReferenceSystem() ); // There are two cases: // - both before/after go into the same updater --> pass update into that updater if ( from == to ) { from.process( update ); } // - before go into one and after into the other --> REMOVED from one and ADDED into the other else { from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) ); } break; default: throw new IllegalArgumentException( "Unknown update mode" ); } }
private static <KEY extends NativeIndexKey<KEY>, VALUE extends NativeIndexValue> void processChange( KEY treeKey, VALUE treeValue, IndexEntryUpdate<?> update, Writer<KEY,VALUE> writer, ConflictDetectingValueMerger<KEY,VALUE> conflictDetectingValueMerger ) throws IndexEntryConflictException { // Remove old entry initializeKeyFromUpdate( treeKey, update.getEntityId(), update.beforeValues() ); writer.remove( treeKey ); // Insert new entry initializeKeyFromUpdate( treeKey, update.getEntityId(), update.values() ); treeValue.from( update.values() ); conflictDetectingValueMerger.controlConflictDetection( treeKey ); writer.merge( treeKey, treeValue, conflictDetectingValueMerger ); conflictDetectingValueMerger.checkConflict( update.values() ); }
PointValue fromValue = (PointValue) update.beforeValues()[0]; IndexUpdater from = select( fromValue.getCoordinateReferenceSystem() ); IndexUpdater to = select( value.getCoordinateReferenceSystem() ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );
IndexUpdater from = select( update.beforeValues()[0].valueGroup() ); IndexUpdater to = select( update.values()[0].valueGroup() ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );
IndexUpdater from = instanceSelector.select( slotSelector.selectSlot( update.beforeValues(), GROUP_OF ) ); IndexUpdater to = instanceSelector.select( slotSelector.selectSlot( update.values(), GROUP_OF ) ); from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) );