Search in sources :

Example 1 with HgkvFileReaderImpl

use of com.baidu.hugegraph.computer.core.store.file.hgkvfile.reader.HgkvFileReaderImpl in project hugegraph-computer by hugegraph.

the class HgkvFileTest method testHgkvFileReader.

@Test
public void testHgkvFileReader() throws Exception {
    // The keys in the data must be ordered
    List<Integer> data = testData();
    String filePath = StoreTestUtil.availablePathById("1");
    File file = StoreTestUtil.mapToHgkvFile(CONFIG, data, filePath);
    KvEntryFileReader reader = new HgkvFileReaderImpl(file.getPath(), false);
    try (EntryIterator iterator = reader.iterator()) {
        int index = 0;
        while (iterator.hasNext()) {
            KvEntry next = iterator.next();
            int key = StoreTestUtil.byteArrayToInt(next.key().bytes());
            Assert.assertEquals(data.get(index).intValue(), key);
            index += 2;
        }
        Assert.assertThrows(NoSuchElementException.class, iterator::next);
    }
}
Also used : KvEntry(com.baidu.hugegraph.computer.core.store.entry.KvEntry) HgkvFileReaderImpl(com.baidu.hugegraph.computer.core.store.file.hgkvfile.reader.HgkvFileReaderImpl) HgkvFile(com.baidu.hugegraph.computer.core.store.file.hgkvfile.HgkvFile) File(java.io.File) Test(org.junit.Test)

Aggregations

KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)1 HgkvFile (com.baidu.hugegraph.computer.core.store.file.hgkvfile.HgkvFile)1 HgkvFileReaderImpl (com.baidu.hugegraph.computer.core.store.file.hgkvfile.reader.HgkvFileReaderImpl)1 File (java.io.File)1 Test (org.junit.Test)1