Search in sources :

Example 1 with DelegatingIndexUpdater

use of org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater in project neo4j by neo4j.

the class BlockBasedIndexPopulator method newPopulatingUpdater.

@Override
public IndexUpdater newPopulatingUpdater(CursorContext cursorContext) {
    if (scanCompleted) {
        // Will need the reader from newReader, which a sub-class of this class implements
        return new DelegatingIndexUpdater(super.newPopulatingUpdater(cursorContext)) {

            @Override
            public void process(IndexEntryUpdate<?> update) throws IndexEntryConflictException {
                ValueIndexEntryUpdate<?> valueUpdate = asValueUpdate(update);
                validateUpdate(valueUpdate);
                numberOfIndexUpdatesSinceSample.incrementAndGet();
                super.process(valueUpdate);
            }
        };
    }
    return new IndexUpdater() {

        private volatile boolean closed;

        @Override
        public void process(IndexEntryUpdate<?> update) {
            assertOpen();
            ValueIndexEntryUpdate<?> valueUpdate = asValueUpdate(update);
            try {
                validateUpdate(valueUpdate);
                externalUpdates.add(valueUpdate);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        @Override
        public void close() {
            closed = true;
        }

        private void assertOpen() {
            if (closed) {
                throw new IllegalStateException("Updater has been closed");
            }
        }
    };
}
Also used : IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) DelegatingIndexUpdater(org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) DelegatingIndexUpdater(org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater)

Aggregations

IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 DelegatingIndexUpdater (org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater)1 IndexEntryUpdate (org.neo4j.storageengine.api.IndexEntryUpdate)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1