Search in sources :

Example 31 with Config

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

the class InputSplitDataTest method setup.

@BeforeClass
public static void setup() {
    Config config = context().config();
    masterInputManager = new MockMasterInputManager();
    masterInputManager.init(config);
    MockRpcClient rpcClient = new MockRpcClient(masterInputManager.handler());
    workerInputManager = new MockWorkerInputManager(rpcClient);
    workerInputManager.init(config);
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) BeforeClass(org.junit.BeforeClass)

Example 32 with Config

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

the class HashPartitionerTest method testDist.

@Test
public void testDist() {
    int workerCount = 2;
    int partitionCount = 10;
    Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_WORKERS_COUNT, Integer.toString(workerCount), ComputerOptions.JOB_PARTITIONS_COUNT, Integer.toString(partitionCount));
    Partitioner partitioner = config.createObject(ComputerOptions.WORKER_PARTITIONER);
    partitioner.init(config);
    int[] partitionStat = new int[partitionCount];
    int[] workerStat = new int[workerCount];
    Random random = new Random();
    int hashTimes = 1024;
    for (int i = 0; i < hashTimes; i++) {
        int partitionId = partitioner.partitionId(BytesId.of(random.nextLong()));
        partitionStat[partitionId]++;
        int workerId = partitioner.workerId(partitionId);
        workerStat[--workerId]++;
    }
    LOG.info("Partition distribution: {}", Arrays.toString(partitionStat));
    LOG.info("Worker distribution: {}", Arrays.toString(workerStat));
    Assert.assertEquals(hashTimes, Arrays.stream(partitionStat).sum());
    Assert.assertEquals(hashTimes, Arrays.stream(workerStat).sum());
}
Also used : Random(java.util.Random) Config(com.baidu.hugegraph.computer.core.config.Config) Test(org.junit.Test)

Example 33 with Config

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

the class SortManager method createMessageCombiner.

private PointerCombiner createMessageCombiner() {
    Config config = this.context.config();
    Combiner<Value> valueCombiner = config.createObject(ComputerOptions.WORKER_COMBINER_CLASS, false);
    if (valueCombiner == null) {
        return null;
    }
    return new MessageValueCombiner(this.context);
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) Value(com.baidu.hugegraph.computer.core.graph.value.Value) MessageValueCombiner(com.baidu.hugegraph.computer.core.combiner.MessageValueCombiner)

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