Search in sources :

Example 1 with UpdateMode

use of org.neo4j.storageengine.api.UpdateMode in project neo4j by neo4j.

the class IndexUpdateStorage method add.

@Override
public void add(IndexEntryUpdate<?> update, PageCursor pageCursor) throws IOException {
    ValueIndexEntryUpdate<?> valueUpdate = (ValueIndexEntryUpdate<?>) update;
    int entrySize = TYPE_SIZE;
    UpdateMode updateMode = valueUpdate.updateMode();
    switch(updateMode) {
        case ADDED:
            initializeKeyAndValueFromUpdate(key1, value, valueUpdate.getEntityId(), valueUpdate.values());
            entrySize += BlockEntry.entrySize(layout, key1, value);
            break;
        case REMOVED:
            initializeKeyFromUpdate(key1, valueUpdate.getEntityId(), valueUpdate.values());
            entrySize += BlockEntry.keySize(layout, key1);
            break;
        case CHANGED:
            initializeKeyFromUpdate(key1, valueUpdate.getEntityId(), valueUpdate.beforeValues());
            initializeKeyAndValueFromUpdate(key2, value, valueUpdate.getEntityId(), valueUpdate.values());
            entrySize += BlockEntry.keySize(layout, key1) + BlockEntry.entrySize(layout, key2, value);
            break;
        default:
            throw new IllegalArgumentException("Unknown update mode " + updateMode);
    }
    prepareWrite(entrySize);
    pageCursor.putByte((byte) updateMode.ordinal());
    IndexUpdateEntry.write(pageCursor, layout, updateMode, key1, key2, value);
}
Also used : UpdateMode(org.neo4j.storageengine.api.UpdateMode) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate)

Aggregations

UpdateMode (org.neo4j.storageengine.api.UpdateMode)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1