Search in sources :

Example 6 with Config

use of com.baidu.hugegraph.computer.core.config.Config in project hugegraph-computer by hugegraph.

the class SenderIntegrateTest method initMaster.

private MasterService initMaster(String[] args) {
    Config config = ComputerContextUtil.initContext(ComputerContextUtil.convertToMap(args));
    MasterService service = new MasterService();
    service.init(config);
    return service;
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) MasterService(com.baidu.hugegraph.computer.core.master.MasterService)

Example 7 with Config

use of com.baidu.hugegraph.computer.core.config.Config in project hugegraph-computer by hugegraph.

the class SorterTest method testMergeKvInputs.

@Test
public void testMergeKvInputs() throws Exception {
    Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.HGKV_MAX_FILE_SIZE, "32", ComputerOptions.HGKV_DATABLOCK_SIZE, "16", ComputerOptions.HGKV_MERGE_FILES_NUM, "3", ComputerOptions.TRANSPORT_RECV_FILE_MODE, "false");
    this.testMergeKvInputs(config);
    config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.HGKV_MAX_FILE_SIZE, "32", ComputerOptions.HGKV_DATABLOCK_SIZE, "16", ComputerOptions.HGKV_MERGE_FILES_NUM, "3", ComputerOptions.TRANSPORT_RECV_FILE_MODE, "true");
    this.testMergeKvInputs(config);
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) Test(org.junit.Test)

Example 8 with Config

use of com.baidu.hugegraph.computer.core.config.Config in project hugegraph-computer by hugegraph.

the class SorterTest method testSortKvBuffers.

@Test
public void testSortKvBuffers() throws Exception {
    Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.HGKV_MAX_FILE_SIZE, "32", ComputerOptions.HGKV_DATABLOCK_SIZE, "16", ComputerOptions.HGKV_MERGE_FILES_NUM, "3", ComputerOptions.TRANSPORT_RECV_FILE_MODE, "false");
    List<Integer> map1 = ImmutableList.of(2, 3, 2, 1, 5, 2, 6, 9, 6, 2);
    List<Integer> map2 = ImmutableList.of(1, 3, 1, 1, 3, 2, 6, 9, 8, 2);
    String path = StoreTestUtil.availablePathById("1");
    // Merge 4 sorted input
    List<RandomAccessInput> inputs = ImmutableList.of(SorterTestUtil.inputFromKvMap(map1), SorterTestUtil.inputFromKvMap(map2), SorterTestUtil.inputFromKvMap(map1), SorterTestUtil.inputFromKvMap(map2));
    Sorter sorter = SorterTestUtil.createSorter(config);
    PointerCombiner combiner = SorterTestUtil.createPointerCombiner(IntValue::new, new IntValueSumCombiner());
    sorter.mergeBuffers(inputs, new CombineKvOuterSortFlusher(combiner), path, false);
    // Assert merge result from target hgkvDir
    KvEntryFileReader reader = new HgkvDirReaderImpl(path, false);
    EntryIterator iter = reader.iterator();
    SorterTestUtil.assertKvEntry(iter.next(), 1, 8);
    SorterTestUtil.assertKvEntry(iter.next(), 2, 8);
    SorterTestUtil.assertKvEntry(iter.next(), 3, 4);
    SorterTestUtil.assertKvEntry(iter.next(), 5, 4);
    SorterTestUtil.assertKvEntry(iter.next(), 6, 40);
    SorterTestUtil.assertKvEntry(iter.next(), 8, 4);
    Assert.assertFalse(iter.hasNext());
}
Also used : IntValueSumCombiner(com.baidu.hugegraph.computer.core.combiner.IntValueSumCombiner) CombineKvOuterSortFlusher(com.baidu.hugegraph.computer.core.sort.flusher.CombineKvOuterSortFlusher) Config(com.baidu.hugegraph.computer.core.config.Config) EntryIterator(com.baidu.hugegraph.computer.core.store.EntryIterator) PointerCombiner(com.baidu.hugegraph.computer.core.combiner.PointerCombiner) KvEntryFileReader(com.baidu.hugegraph.computer.core.store.KvEntryFileReader) RandomAccessInput(com.baidu.hugegraph.computer.core.io.RandomAccessInput) HgkvDirReaderImpl(com.baidu.hugegraph.computer.core.store.file.hgkvfile.reader.HgkvDirReaderImpl) Sorter(com.baidu.hugegraph.computer.core.sort.Sorter) IntValue(com.baidu.hugegraph.computer.core.graph.value.IntValue) Test(org.junit.Test)

Example 9 with Config

use of com.baidu.hugegraph.computer.core.config.Config in project hugegraph-computer by hugegraph.

the class SorterTest method testSortSubKvBuffer.

@Test
public void testSortSubKvBuffer() throws Exception {
    Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.INPUT_MAX_EDGES_IN_ONE_VERTEX, "2");
    /*
         * Assert result
         * key 1 subKv 3 1, 5 1
         * key 2 subKv 5 1, 8 2
         * key 2 subKv 9 1
         * key 3 subKv 2 2, 3 1
         * key 3 subKv 4 1
         */
    BytesInput input = this.sortedSubKvBuffer(config);
    EntryIterator iter = new KvEntriesInput(input, true);
    SorterTestUtil.assertSubKvByKv(iter.next(), 1, 3, 1, 5, 1);
    SorterTestUtil.assertSubKvByKv(iter.next(), 2, 5, 1, 8, 2);
    SorterTestUtil.assertSubKvByKv(iter.next(), 2, 9, 1);
    SorterTestUtil.assertSubKvByKv(iter.next(), 3, 2, 2, 3, 1);
    SorterTestUtil.assertSubKvByKv(iter.next(), 3, 4, 1);
    iter.close();
}
Also used : BytesInput(com.baidu.hugegraph.computer.core.io.BytesInput) Config(com.baidu.hugegraph.computer.core.config.Config) KvEntriesInput(com.baidu.hugegraph.computer.core.store.buffer.KvEntriesInput) EntryIterator(com.baidu.hugegraph.computer.core.store.EntryIterator) Test(org.junit.Test)

Example 10 with Config

use of com.baidu.hugegraph.computer.core.config.Config in project hugegraph-computer by hugegraph.

the class SorterTest method testSortKvBuffer.

@Test
public void testSortKvBuffer() throws Exception {
    Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.HGKV_MAX_FILE_SIZE, "32", ComputerOptions.HGKV_DATABLOCK_SIZE, "16", ComputerOptions.HGKV_MERGE_FILES_NUM, "3");
    List<Integer> map = ImmutableList.of(2, 3, 1, 23, 6, 2, 5, 9, 2, 2, 6, 1, 1, 20);
    BytesInput input = SorterTestUtil.inputFromKvMap(map);
    BytesOutput output = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    Sorter sorter = SorterTestUtil.createSorter(config);
    PointerCombiner combiner = SorterTestUtil.createPointerCombiner(IntValue::new, new IntValueSumCombiner());
    sorter.sortBuffer(input, new CombineKvInnerSortFlusher(output, combiner), false);
    BytesInput resultInput = EntriesUtil.inputFromOutput(output);
    KvEntriesInput iter = new KvEntriesInput(resultInput);
    SorterTestUtil.assertKvEntry(iter.next(), 1, 43);
    SorterTestUtil.assertKvEntry(iter.next(), 2, 5);
    SorterTestUtil.assertKvEntry(iter.next(), 5, 9);
    SorterTestUtil.assertKvEntry(iter.next(), 6, 3);
    iter.close();
}
Also used : IntValueSumCombiner(com.baidu.hugegraph.computer.core.combiner.IntValueSumCombiner) BytesInput(com.baidu.hugegraph.computer.core.io.BytesInput) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput) Config(com.baidu.hugegraph.computer.core.config.Config) Sorter(com.baidu.hugegraph.computer.core.sort.Sorter) KvEntriesInput(com.baidu.hugegraph.computer.core.store.buffer.KvEntriesInput) PointerCombiner(com.baidu.hugegraph.computer.core.combiner.PointerCombiner) IntValue(com.baidu.hugegraph.computer.core.graph.value.IntValue) CombineKvInnerSortFlusher(com.baidu.hugegraph.computer.core.sort.flusher.CombineKvInnerSortFlusher) Test(org.junit.Test)

Aggregations

Config (com.baidu.hugegraph.computer.core.config.Config)33 Test (org.junit.Test)25 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)6 File (java.io.File)6 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)5 BytesOutput (com.baidu.hugegraph.computer.core.io.BytesOutput)5 IntValueSumCombiner (com.baidu.hugegraph.computer.core.combiner.IntValueSumCombiner)4 PointerCombiner (com.baidu.hugegraph.computer.core.combiner.PointerCombiner)4 IntValue (com.baidu.hugegraph.computer.core.graph.value.IntValue)4 MasterService (com.baidu.hugegraph.computer.core.master.MasterService)4 Sorter (com.baidu.hugegraph.computer.core.sort.Sorter)4 GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)3 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)3 Id (com.baidu.hugegraph.computer.core.graph.id.Id)3 RandomAccessInput (com.baidu.hugegraph.computer.core.io.RandomAccessInput)3 CombineKvOuterSortFlusher (com.baidu.hugegraph.computer.core.sort.flusher.CombineKvOuterSortFlusher)3 RecvSortManager (com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager)3 SortManager (com.baidu.hugegraph.computer.core.sort.sorting.SortManager)3 InlinePointer (com.baidu.hugegraph.computer.core.store.entry.InlinePointer)3 Pointer (com.baidu.hugegraph.computer.core.store.entry.Pointer)3