Java Code Examples for org.apache.kylin.common.util.JsonUtil#writeValue()

The following examples show how to use org.apache.kylin.common.util.JsonUtil#writeValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SCCreatorTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteSinkToolsJson() throws Exception {
    Map<String, String> cubeDescOverrideProperties = Maps.newHashMap();
    cubeDescOverrideProperties.put("kylin.cube.algorithm", "INMEM");

    MetricsSinkDesc metricsSinkDesc = new MetricsSinkDesc();
    metricsSinkDesc.setCubeDescOverrideProperties(cubeDescOverrideProperties);
    List<MetricsSinkDesc> metricsSinkDescList = Lists.newArrayList();

    String outputPath = "src/test/resources/SCSinkTools.json";
    JsonUtil.writeValue(new FileOutputStream(outputPath), metricsSinkDescList);

    List<MetricsSinkDesc> sinkToolSet = readSinkToolsJson(outputPath);
    for (MetricsSinkDesc entry : sinkToolSet) {
        Map<String, String> props = entry.getCubeDescOverrideProperties();
        for (String key : cubeDescOverrideProperties.keySet()) {
            assertEquals(props.get(key), cubeDescOverrideProperties.get(key));
        }
    }
}
 
Example 2
Source File: SCCreatorTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteSinkToolsJson() throws Exception {
    Map<String, String> cubeDescOverrideProperties = Maps.newHashMap();
    cubeDescOverrideProperties.put("kylin.cube.algorithm", "INMEM");

    MetricsSinkDesc metricsSinkDesc = new MetricsSinkDesc();
    metricsSinkDesc.setCubeDescOverrideProperties(cubeDescOverrideProperties);
    List<MetricsSinkDesc> metricsSinkDescList = Lists.newArrayList();
    metricsSinkDescList.add(metricsSinkDesc);

    String outputPath = "src/test/resources/SCSinkTools.json";
    JsonUtil.writeValue(new FileOutputStream(outputPath), metricsSinkDescList);

    List<MetricsSinkDesc> sinkToolSet = readSinkToolsJson(outputPath);
    for (MetricsSinkDesc entry : sinkToolSet) {
        Map<String, String> props = entry.getCubeDescOverrideProperties();
        for (String key : cubeDescOverrideProperties.keySet()) {
            assertEquals(props.get(key), cubeDescOverrideProperties.get(key));
        }
    }
}
 
Example 3
Source File: RecordEvent.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Event type does not belong to value part, it's for classification
 */
@Override
public byte[] getValue() {
    try {
        ByteArrayOutputStream baos = _localBaos.get();
        if (baos == null) {
            baos = new ByteArrayOutputStream();
            _localBaos.set(baos);
        }
        baos.reset();
        JsonUtil.writeValue(baos, getValueRaw());
        return baos.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);//in mem, should not happen
    }
}
 
Example 4
Source File: JsonSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T obj, DataOutputStream out) throws IOException {
    if (compact)
        JsonUtil.writeValue(out, obj);
    else
        JsonUtil.writeValueIndent(out, obj);
}
 
Example 5
Source File: JsonSerializer.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T obj, DataOutputStream out) throws IOException {
    if (compact)
        JsonUtil.writeValue(out, obj);
    else
        JsonUtil.writeValueIndent(out, obj);
}