use of org.neo4j.kernel.impl.store.CountsOracle in project neo4j by neo4j.
the class CountsTrackerTest method shouldStoreCounts.
@Test
public void shouldStoreCounts() throws Exception {
// given
CountsOracle oracle = someData();
// when
try (Lifespan life = new Lifespan()) {
CountsTracker tracker = life.add(newTracker());
oracle.update(tracker, 2);
tracker.rotate(2);
}
// then
try (Lifespan life = new Lifespan()) {
oracle.verify(life.add(newTracker()));
}
}
use of org.neo4j.kernel.impl.store.CountsOracle in project neo4j by neo4j.
the class CountsTrackerTest method shouldBeAbleToWriteDataToCountsTracker.
@Test
@Resources.Life(STARTED)
public void shouldBeAbleToWriteDataToCountsTracker() throws Exception {
// given
CountsTracker tracker = resourceManager.managed(newTracker());
long indexId = 0;
CountsOracle oracle = new CountsOracle();
{
CountsOracle.Node a = oracle.node(1);
CountsOracle.Node b = oracle.node(1);
oracle.relationship(a, 1, b);
oracle.indexSampling(indexId, 2, 2);
oracle.indexUpdatesAndSize(indexId, 10, 2);
}
// when
oracle.update(tracker, 2);
// then
oracle.verify(tracker);
// when
tracker.rotate(2);
// then
oracle.verify(tracker);
// when
try (CountsAccessor.IndexStatsUpdater updater = tracker.updateIndexCounts()) {
updater.incrementIndexUpdates(indexId, 2);
}
// then
oracle.indexUpdatesAndSize(indexId, 12, 2);
oracle.verify(tracker);
// when
tracker.rotate(2);
// then
oracle.verify(tracker);
}
use of org.neo4j.kernel.impl.store.CountsOracle in project neo4j by neo4j.
the class CountsTrackerTest method someData.
private CountsOracle someData() {
CountsOracle oracle = new CountsOracle();
CountsOracle.Node n0 = oracle.node(0, 1);
CountsOracle.Node n1 = oracle.node(0, 3);
CountsOracle.Node n2 = oracle.node(2, 3);
CountsOracle.Node n3 = oracle.node(2);
oracle.relationship(n0, 1, n2);
oracle.relationship(n1, 1, n3);
oracle.relationship(n1, 1, n2);
oracle.relationship(n0, 1, n3);
long indexId = 2;
oracle.indexUpdatesAndSize(indexId, 0L, 50L);
oracle.indexSampling(indexId, 25L, 50L);
return oracle;
}
use of org.neo4j.kernel.impl.store.CountsOracle in project neo4j by neo4j.
the class CountsTrackerTest method shouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation.
@Test
public void shouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation() throws Exception {
// given
CountsOracle oracle = someData();
final int firstTransaction = 2, secondTransaction = 3;
try (Lifespan life = new Lifespan()) {
CountsTracker tracker = life.add(newTracker());
oracle.update(tracker, firstTransaction);
tracker.rotate(firstTransaction);
}
// when
final CountsOracle delta = new CountsOracle();
{
CountsOracle.Node n1 = delta.node(1);
// Label 4 has not been used before...
CountsOracle.Node n2 = delta.node(1, 4);
delta.relationship(n1, 1, n2);
// relationshipType 2 has not been used before...
delta.relationship(n2, 2, n1);
}
delta.update(oracle);
try (Lifespan life = new Lifespan()) {
final Barrier.Control barrier = new Barrier.Control();
CountsTracker tracker = life.add(new CountsTracker(resourceManager.logProvider(), resourceManager.fileSystem(), resourceManager.pageCache(), Config.empty(), resourceManager.testPath()) {
@Override
protected boolean include(CountsKey countsKey, ReadableBuffer value) {
barrier.reached();
return super.include(countsKey, value);
}
});
Future<Void> task = threading.execute((ThrowingFunction<CountsTracker, Void, RuntimeException>) t -> {
try {
delta.update(t, secondTransaction);
t.rotate(secondTransaction);
} catch (IOException e) {
throw new AssertionError(e);
}
return null;
}, tracker);
// then
barrier.await();
oracle.verify(tracker);
barrier.release();
task.get();
oracle.verify(tracker);
}
}
use of org.neo4j.kernel.impl.store.CountsOracle in project neo4j by neo4j.
the class CountsTrackerTest method shouldUpdateCountsOnExistingStore.
@Test
public void shouldUpdateCountsOnExistingStore() throws Exception {
// given
CountsOracle oracle = someData();
int firstTx = 2, secondTx = 3;
try (Lifespan life = new Lifespan()) {
CountsTracker tracker = life.add(newTracker());
oracle.update(tracker, firstTx);
tracker.rotate(firstTx);
oracle.verify(tracker);
// when
CountsOracle delta = new CountsOracle();
{
CountsOracle.Node n1 = delta.node(1);
// Label 4 has not been used before...
CountsOracle.Node n2 = delta.node(1, 4);
delta.relationship(n1, 1, n2);
// relationshipType 2 has not been used before...
delta.relationship(n2, 2, n1);
}
delta.update(tracker, secondTx);
delta.update(oracle);
// then
oracle.verify(tracker);
// when
tracker.rotate(secondTx);
}
// then
try (Lifespan life = new Lifespan()) {
oracle.verify(life.add(newTracker()));
}
}
Aggregations