use of org.neo4j.kernel.impl.store.counts.keys.NodeKey in project neo4j by neo4j.
the class InMemoryCountsStoreTest method restoreFromSnapshot.
@Test
public void restoreFromSnapshot() {
//GIVEN
InMemoryCountsStore countStore = new InMemoryCountsStore();
Map<CountsKey, long[]> update = new HashMap<>();
NodeKey keyA = CountsKeyFactory.nodeKey(1);
NodeKey keyB = CountsKeyFactory.nodeKey(2);
NodeKey keyC = CountsKeyFactory.nodeKey(3);
update.put(keyA, new long[] { 1 });
countStore.updateAll(1, update);
update.clear();
update.put(keyB, new long[] { 1 });
countStore.updateAll(2, update);
update.clear();
update.put(keyC, new long[] { 1 });
countStore.updateAll(3, update);
//WHEN
CountsSnapshot countsSnapshot = countStore.snapshot(3);
long beforeTxId = countsSnapshot.getTxId();
Assert.assertEquals(3, beforeTxId);
countStore = new InMemoryCountsStore(countsSnapshot);
//THEN
CountsSnapshot secondCountsSnapshot = countStore.snapshot(3);
Assert.assertEquals(3, secondCountsSnapshot.getTxId());
update.put(keyC, new long[] { 1 });
countStore.updateAll(4, update);
CountsSnapshot thirdCountsSnapshot = countStore.snapshot(4);
Assert.assertEquals(4, thirdCountsSnapshot.getTxId());
}
use of org.neo4j.kernel.impl.store.counts.keys.NodeKey in project neo4j by neo4j.
the class InMemoryCountsStoreTest method getExpectedValue.
@Test
public void getExpectedValue() {
//GIVEN
InMemoryCountsStore countStore = new InMemoryCountsStore();
Map<CountsKey, long[]> update = new HashMap<>();
NodeKey key = CountsKeyFactory.nodeKey(1);
update.put(key, new long[] { 1 });
//WHEN
countStore.updateAll(1, update);
//THEN
Assert.assertEquals(countStore.get(key)[0], 1);
}
use of org.neo4j.kernel.impl.store.counts.keys.NodeKey in project neo4j by neo4j.
the class InMemoryCountsStoreTest method getNullKeyResultsInNPE.
@Test(expected = NullPointerException.class)
public void getNullKeyResultsInNPE() {
//GIVEN
InMemoryCountsStore countStore = new InMemoryCountsStore();
Map<CountsKey, long[]> update = new HashMap<>();
NodeKey key = CountsKeyFactory.nodeKey(1);
update.put(key, new long[] { 1 });
//WHEN
countStore.updateAll(1, update);
//THEN throws
countStore.get(null);
}
use of org.neo4j.kernel.impl.store.counts.keys.NodeKey in project neo4j by neo4j.
the class InMemoryCountsStoreTest method neverSetKeyReturnsNull.
@Test
public void neverSetKeyReturnsNull() {
//GIVEN
InMemoryCountsStore countStore = new InMemoryCountsStore();
Map<CountsKey, long[]> update = new HashMap<>();
NodeKey key = CountsKeyFactory.nodeKey(1);
update.put(key, new long[] { 1 });
//WHEN
countStore.updateAll(1, update);
//THEN
Assert.assertNull(countStore.get(CountsKeyFactory.relationshipKey(1, 1, 1)));
}
use of org.neo4j.kernel.impl.store.counts.keys.NodeKey in project neo4j by neo4j.
the class InMemoryCountsStoreSnapshotDeserializerTest method correctlyDeserializeEntityNode.
@Test
public void correctlyDeserializeEntityNode() throws IOException {
//GIVEN
serializedBytes = ByteBuffer.allocate(1000);
InMemoryClosableChannel logChannel = new InMemoryClosableChannel(serializedBytes.array(), false);
writeSimpleHeader(logChannel);
logChannel.put(ENTITY_NODE.code);
logChannel.putInt(1);
logChannel.putLong(1);
//WHEN
NodeKey expectedNode = CountsKeyFactory.nodeKey(1);
CountsSnapshot countsSnapshot = deserialize(logChannel);
//THEN
assertNotNull(countsSnapshot.getMap().get(expectedNode));
assertArrayEquals(new long[] { 1 }, countsSnapshot.getMap().get(expectedNode));
}
Aggregations