Search in sources :

Example 1 with ValueType

use of com.baidu.hugegraph.computer.core.graph.value.ValueType in project hugegraph-computer by hugegraph.

the class DefaultProperties method read.

@Override
public void read(RandomAccessInput in) throws IOException {
    this.keyValues.clear();
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        String key = in.readUTF();
        ValueType valueType = SerialEnum.fromCode(ValueType.class, in.readByte());
        Value value = this.graphFactory.createValue(valueType);
        value.read(in);
        this.keyValues.put(key, value);
    }
}
Also used : ValueType(com.baidu.hugegraph.computer.core.graph.value.ValueType) Value(com.baidu.hugegraph.computer.core.graph.value.Value)

Example 2 with ValueType

use of com.baidu.hugegraph.computer.core.graph.value.ValueType in project hugegraph-computer by hugegraph.

the class MockMasterComputation method registerAggregatorWithError.

private void registerAggregatorWithError(MasterContext context) {
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.registerAggregator("", MockIntAggregator.class);
    }, e -> {
        Assert.assertContains("registered aggregator name can't be empty", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.registerAggregator(null, MockIntAggregator.class);
    }, e -> {
        Assert.assertContains("registered aggregator name can't be null", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.registerAggregator("", ValueType.INT, IntValueSumCombiner.class);
    }, e -> {
        Assert.assertContains("registered aggregator name can't be empty", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.registerAggregator(null, ValueType.INT, IntValueSumCombiner.class);
    }, e -> {
        Assert.assertContains("registered aggregator name can't be null", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.registerAggregator(AGGR_INT_UNSTABLE, ValueType.INT, null);
    }, e -> {
        Assert.assertContains("combiner of aggregator can't be null", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        ValueType type = null;
        context.registerAggregator(AGGR_INT_UNSTABLE, type, IntValueSumCombiner.class);
    }, e -> {
        Assert.assertContains("value type of aggregator can't be null", e.getMessage());
    });
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        IntValue value = null;
        context.registerAggregator(AGGR_INT_UNSTABLE, value, IntValueSumCombiner.class);
    }, e -> {
        Assert.assertContains("The aggregator default value can't be null", e.getMessage());
    });
    // Not applied now, can get it through aggregatedValue() after inited()
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        context.aggregatedValue(AGGR_INT_UNSTABLE, new IntValue(Integer.MAX_VALUE));
    }, e -> {
        Assert.assertContains("Can't get aggregator 'aggr_int_unstable", e.getMessage());
    });
}
Also used : ValueType(com.baidu.hugegraph.computer.core.graph.value.ValueType) IntValue(com.baidu.hugegraph.computer.core.graph.value.IntValue)

Aggregations

ValueType (com.baidu.hugegraph.computer.core.graph.value.ValueType)2 IntValue (com.baidu.hugegraph.computer.core.graph.value.IntValue)1 Value (com.baidu.hugegraph.computer.core.graph.value.Value)1