Search in sources :

Example 1 with NO_MONITOR

use of org.neo4j.index.internal.gbptree.GBPTree.NO_MONITOR in project neo4j by neo4j.

the class GBPTreeTest method shouldPutHeaderDataInCheckPoint.

@Test
public void shouldPutHeaderDataInCheckPoint() throws Exception {
    // GIVEN
    byte[] expectedHeader = new byte[12];
    ThreadLocalRandom.current().nextBytes(expectedHeader);
    index = createIndex(256);
    index.close(cursor -> cursor.putBytes(expectedHeader));
    // WHEN
    byte[] readHeader = new byte[expectedHeader.length];
    AtomicInteger length = new AtomicInteger();
    index = createIndex(256, NO_MONITOR, (cursor, len) -> {
        length.set(len);
        cursor.getBytes(readHeader);
    });
    // THEN
    assertEquals(expectedHeader.length, length.get());
    assertArrayEquals(expectedHeader, readHeader);
}
Also used : Primitive(org.neo4j.collection.primitive.Primitive) Arrays(java.util.Arrays) PageCursor(org.neo4j.io.pagecache.PageCursor) PagedFile(org.neo4j.io.pagecache.PagedFile) IOLimiter(org.neo4j.io.pagecache.IOLimiter) NO_HEADER(org.neo4j.index.internal.gbptree.GBPTree.NO_HEADER) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RandomRule(org.neo4j.test.rule.RandomRule) MutableLong(org.apache.commons.lang3.mutable.MutableLong) PageCacheRule(org.neo4j.test.rule.PageCacheRule) After(org.junit.After) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) PageCache(org.neo4j.io.pagecache.PageCache) ThrowingRunnable.throwing(org.neo4j.index.internal.gbptree.ThrowingRunnable.throwing) Barrier(org.neo4j.test.Barrier) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PrimitiveLongCollections(org.neo4j.collection.primitive.PrimitiveLongCollections) Monitor(org.neo4j.index.internal.gbptree.GBPTree.Monitor) TestDirectory(org.neo4j.test.rule.TestDirectory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) RuleChain(org.junit.rules.RuleChain) List(java.util.List) Rule(org.junit.Rule) DefaultFileSystemRule(org.neo4j.test.rule.fs.DefaultFileSystemRule) NO_MONITOR(org.neo4j.index.internal.gbptree.GBPTree.NO_MONITOR) Assert.assertFalse(org.junit.Assert.assertFalse) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet) RawCursor(org.neo4j.cursor.RawCursor) RuleChain.outerRule(org.junit.rules.RuleChain.outerRule) PageCacheRule.config(org.neo4j.test.rule.PageCacheRule.config) Assert.assertEquals(org.junit.Assert.assertEquals) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 After (org.junit.After)1 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 RuleChain (org.junit.rules.RuleChain)1