use of org.neo4j.kernel.impl.store.counts.keys.CountsKey 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.CountsKey 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.CountsKey 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.CountsKey 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.CountsKey in project neo4j by neo4j.
the class CountsRotationTest method allRecords.
private Collection<Pair<? extends CountsKey, Long>> allRecords(CountsVisitor.Visitable store) {
final Collection<Pair<? extends CountsKey, Long>> records = new ArrayList<>();
store.accept(new CountsVisitor() {
@Override
public void visitNodeCount(int labelId, long count) {
records.add(Pair.of(CountsKeyFactory.nodeKey(labelId), count));
}
@Override
public void visitRelationshipCount(int startLabelId, int typeId, int endLabelId, long count) {
records.add(Pair.of(CountsKeyFactory.relationshipKey(startLabelId, typeId, endLabelId), count));
}
@Override
public void visitIndexStatistics(long indexId, long updates, long size) {
records.add(Pair.of(CountsKeyFactory.indexStatisticsKey(indexId), size));
}
@Override
public void visitIndexSample(long indexId, long unique, long size) {
records.add(Pair.of(CountsKeyFactory.indexSampleKey(indexId), size));
}
});
return records;
}
Aggregations