Search in sources :

Example 1 with CountsKeyType

use of org.neo4j.kernel.impl.store.counts.keys.CountsKeyType in project neo4j by neo4j.

the class CountsSnapshotDeserializer method deserialize.

public static CountsSnapshot deserialize(ReadableClosableChannel channel) throws IOException {
    long txid = channel.getLong();
    int size = channel.getInt();
    Map<CountsKey, long[]> map = new ConcurrentHashMap<>(size);
    CountsKey key;
    long[] value;
    for (int i = 0; i < size; i++) {
        CountsKeyType type = value(channel.get());
        switch(type) {
            case ENTITY_NODE:
                key = nodeKey(channel.getInt());
                value = new long[] { channel.getLong() };
                map.put(key, value);
                break;
            case ENTITY_RELATIONSHIP:
                int startLabelId = channel.getInt();
                int typeId = channel.getInt();
                int endLabelId = channel.getInt();
                key = relationshipKey(startLabelId, typeId, endLabelId);
                value = new long[] { channel.getLong() };
                map.put(key, value);
                break;
            case INDEX_SAMPLE:
                key = indexSampleKey(channel.getLong());
                value = new long[] { channel.getLong(), channel.getLong() };
                map.put(key, value);
                break;
            case INDEX_STATISTICS:
                key = indexStatisticsKey(channel.getLong());
                value = new long[] { channel.getLong(), channel.getLong() };
                map.put(key, value);
                break;
            case EMPTY:
                throw new IllegalArgumentException("CountsKey of type EMPTY cannot be deserialized.");
            default:
                throw new IllegalArgumentException("The read CountsKey has an unknown type.");
        }
    }
    return new CountsSnapshot(txid, map);
}
Also used : CountsKeyType(org.neo4j.kernel.impl.store.counts.keys.CountsKeyType) CountsKey(org.neo4j.kernel.impl.store.counts.keys.CountsKey) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountsKey (org.neo4j.kernel.impl.store.counts.keys.CountsKey)1 CountsKeyType (org.neo4j.kernel.impl.store.counts.keys.CountsKeyType)1