• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.kylin.common.util.JsonUtil的典型用法代码示例。如果您正苦于以下问题:Java JsonUtil类的具体用法?Java JsonUtil怎么用?Java JsonUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonUtil类属于org.apache.kylin.common.util包,在下文中一共展示了JsonUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getKylinProperties

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public String getKylinProperties() throws IOException {
    String url = baseUrl + "/admin/config";
    HttpGet request = new HttpGet(url);
    HttpResponse response = null;
    try {
        response = client.execute(request);
        String msg = EntityUtils.toString(response.getEntity());
        Map<String, String> map = JsonUtil.readValueAsMap(msg);
        msg = map.get("config");

        if (response.getStatusLine().getStatusCode() != 200)
            throw new IOException("Invalid response " + response.getStatusLine().getStatusCode()
                    + " with cache wipe url " + url + "\n" + msg);
        return msg;
    } finally {
        cleanup(request, response);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:RestClient.java


示例2: testBasics

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testBasics() throws Exception {
    BadQueryHistory history = BadQueryHistoryManager.getInstance(getTestConfig())
            .getBadQueriesForProject("default");
    System.out.println(JsonUtil.writeValueAsIndentString(history));

    NavigableSet<BadQueryEntry> entries = history.getEntries();
    assertEquals(3, entries.size());

    BadQueryEntry entry1 = entries.first();
    assertEquals("Pushdown", entry1.getAdj());
    assertEquals("sandbox.hortonworks.com", entry1.getServer());
    assertEquals("select * from test_kylin_fact limit 10", entry1.getSql());

    entries.pollFirst();
    BadQueryEntry entry2 = entries.first();
    assertTrue(entry2.getStartTime() > entry1.getStartTime());
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:BadQueryHistoryManagerTest.java


示例3: buildDictionary

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public DictionaryInfo buildDictionary(TblColRef col, IReadableTable inpTable, String builderClass) throws IOException {
    if (inpTable.exists() == false)
        return null;

    logger.info("building dictionary for " + col);

    DictionaryInfo dictInfo = createDictionaryInfo(col, inpTable);
    String dupInfo = checkDupByInfo(dictInfo);
    if (dupInfo != null) {
        logger.info("Identical dictionary input " + dictInfo.getInput() + ", reuse existing dictionary at " + dupInfo);
        return getDictionaryInfo(dupInfo);
    }

    logger.info("Building dictionary object " + JsonUtil.writeValueAsString(dictInfo));

    Dictionary<String> dictionary;
    dictionary = buildDictFromReadableTable(inpTable, dictInfo, builderClass, col);
    return trySaveNewDict(dictionary, dictInfo);
}
 
开发者ID:apache,项目名称:kylin,代码行数:20,代码来源:DictionaryManager.java


示例4: setCuboids

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public void setCuboids(Map<Long, Long> cuboids) {
    if (cuboids == null)
        return;
    if (cuboids.isEmpty()) {
        cuboidBytes = null;
        return;
    }

    try {
        String str = JsonUtil.writeValueAsString(cuboids);
        byte[] compressed = CompressionUtils.compress(str.getBytes("UTF-8"));
        cuboidBytes = compressed;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:CubeInstance.java


示例5: dump

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public static void dump(File f) throws IOException {
    if (f.isDirectory()) {
        File[] files = f.listFiles();
        if (files == null) {
            return;
        }
        for (File c : files)
            dump(c);
        return;
    }

    if (f.getName().endsWith(".dict")) {
        DictionaryInfoSerializer ser = new DictionaryInfoSerializer();
        DictionaryInfo dictInfo = ser.deserialize(new DataInputStream(new FileInputStream(f)));

        System.out.println("============================================================================");
        System.out.println("File: " + f.getAbsolutePath());
        System.out.println(new Date(dictInfo.getLastModified()));
        System.out.println(JsonUtil.writeValueAsIndentString(dictInfo));
        dictInfo.getDictionaryObject().dump(System.out);
        System.out.println();
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:24,代码来源:DumpDictionaryCLI.java


示例6: testGoodDesc

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testGoodDesc() throws IOException {
    AggregationGroupRule rule = getAggregationGroupRule();

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (!f.getName().endsWith("json")) {
            continue;
        }
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        desc.init(getTestConfig());
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:AggregationGroupRuleTest.java


示例7: testGoodBecomeBadDesc

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testGoodBecomeBadDesc() throws IOException {
    AggregationGroupRule rule = new AggregationGroupRule() {
        @Override
        protected long getMaxCombinations(CubeDesc cubeDesc) {
            return 2;
        }
    };

    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        System.out.println(f.getName());
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        try {
            desc.init(getTestConfig());
        } catch (Exception e) {
            // Ignore any exception here, validation may fail for bad json
        }
        ValidateContext vContext = new ValidateContext();
        rule.validate(desc, vContext);
        //vContext.print(System.out);
        assertTrue(vContext.getResults().length > 0);
        assertTrue(vContext.getResults()[0].getMessage().startsWith("Aggregation group 1 has too many combinations"));
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:AggregationGroupRuleTest.java


示例8: testCombinationIntOverflow

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testCombinationIntOverflow() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (f.getName().endsWith("bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/ut_cube_desc_combination_int_overflow.json"), CubeDesc.class);

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    try {
        desc.init(getTestConfig());
    } catch (Exception ex) {
        // as it's a failure case, it should throw exception
    }
    rule.validate(desc, vContext);
    assertEquals(1, vContext.getResults().length);
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:AggregationGroupRuleTest.java


示例9: testDictionaryDesc

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
private void testDictionaryDesc(String expectMessage, DictionaryDesc... descs) throws IOException {
    DictionaryRule rule = new DictionaryRule();
    File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_without_slr_left_join_desc.json");
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);

    List<DictionaryDesc> newDicts = Lists.newArrayList(desc.getDictionaries());
    for (DictionaryDesc dictDesc : descs) {
        newDicts.add(dictDesc);
    }
    desc.setDictionaries(newDicts);

    desc.init(config);
    ValidateContext vContext = new ValidateContext();
    rule.validate(desc, vContext);

    if (expectMessage == null) {
        assertTrue(vContext.getResults().length == 0);
    } else {
        assertTrue(vContext.getResults().length == 1);
        String actualMessage = vContext.getResults()[0].getMessage();
        assertTrue(actualMessage.startsWith(expectMessage));
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:24,代码来源:DictionaryRuleTest.java


示例10: updateModelDesc

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@RequestMapping(value = "", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public ModelRequest updateModelDesc(@RequestBody ModelRequest modelRequest) throws JsonProcessingException {
    DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest);
    if (modelDesc == null) {
        return modelRequest;
    }
    try {
        modelDesc = modelService.updateModelAndDesc(modelRequest.getProject(), modelDesc);
    } catch (AccessDeniedException accessDeniedException) {
        throw new ForbiddenException("You don't have right to update this model.");
    } catch (Exception e) {
        logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage());
    }

    if (modelDesc.getError().isEmpty()) {
        modelRequest.setSuccessful(true);
    } else {
        logger.warn("Model " + modelDesc.getName() + " fail to update because " + modelDesc.getError());
        updateRequest(modelRequest, false, omitMessage(modelDesc.getError()));
    }
    String descData = JsonUtil.writeValueAsIndentString(modelDesc);
    modelRequest.setModelDescData(descData);
    return modelRequest;
}
 
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:ModelController.java


示例11: testReadTableDesc

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testReadTableDesc() throws IOException {
    String requestTableData = "{\"name\":\"my_table_name\",\"source_type\":1,\"columns\":[{\"id\":1,\"name\":" +
            "\"amount\",\"datatype\":\"decimal\"},{\"id\":2,\"name\":\"category\",\"datatype\":\"varchar(256)\"}," +
            "{\"id\":3,\"name\":\"order_time\",\"datatype\":\"timestamp\"},{\"id\":4,\"name\":\"device\"," +
            "\"datatype\":\"varchar(256)\"},{\"id\":5,\"name\":\"qty\",\"datatype\":\"int\"},{\"id\":6,\"name\":" +
            "\"user_id\",\"datatype\":\"varchar(256)\"},{\"id\":7,\"name\":\"user_age\",\"datatype\":\"int\"}," +
            "{\"id\":8,\"name\":\"user_gender\",\"datatype\":\"varchar(256)\"},{\"id\":9,\"name\":\"currency\"," +
            "\"datatype\":\"varchar(256)\"},{\"id\":10,\"name\":\"country\",\"datatype\":\"varchar(256)\"}," +
            "{\"id\":11,\"name\":\"year_start\",\"datatype\":\"date\"},{\"id\":12,\"name\":\"quarter_start\"," +
            "\"datatype\":\"date\"},{\"id\":13,\"name\":\"month_start\",\"datatype\":\"date\"},{\"id\":14," +
            "\"name\":\"week_start\",\"datatype\":\"date\"},{\"id\":15,\"name\":\"day_start\",\"datatype\":" +
            "\"date\"},{\"id\":16,\"name\":\"hour_start\",\"datatype\":\"timestamp\"},{\"id\":17,\"name\":" +
            "\"minute_start\",\"datatype\":\"timestamp\"}],\"database\":\"my_database_name\"}";
    TableDesc desc = JsonUtil.readValue(requestTableData, TableDesc.class);
    String[] dbTable = HadoopUtil.parseHiveTableName(desc.getIdentity());
    desc.setName(dbTable[1]);
    desc.setDatabase(dbTable[0]);
    Assert.assertEquals("my_table_name".toUpperCase(), desc.getName());
    Assert.assertEquals("my_database_name".toUpperCase(), desc.getDatabase());
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:StreamingControllerTest.java


示例12: getValue

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Override
/**
 * Event type does not belong to value part, it's for classification
 */
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
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:RecordEvent.java


示例13: saveTableExd

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public void saveTableExd(String tableId, Map<String, String> tableExdProperties) throws IOException {
    if (tableId == null) {
        throw new IllegalArgumentException("tableId couldn't be null");
    }
    TableDesc srcTable = srcTableMap.get(tableId);
    if (srcTable == null) {
        throw new IllegalArgumentException("Couldn't find Source Table with identifier: " + tableId);
    }

    String path = TableDesc.concatExdResourcePath(tableId);

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    JsonUtil.writeValueIndent(os, tableExdProperties);
    os.flush();
    InputStream is = new ByteArrayInputStream(os.toByteArray());
    getStore().putResource(path, is, System.currentTimeMillis());
    os.close();
    is.close();

    srcTableExdMap.putLocal(tableId, tableExdProperties);
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:22,代码来源:MetadataManager.java


示例14: dump

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public static void dump(File f) throws IOException {
    if (f.isDirectory()) {
        for (File c : f.listFiles())
            dump(c);
        return;
    }

    if (f.getName().endsWith(".dict")) {
        DictionaryInfoSerializer ser = new DictionaryInfoSerializer();
        DictionaryInfo dictInfo = ser.deserialize(new DataInputStream(new FileInputStream(f)));

        System.out.println("============================================================================");
        System.out.println("File: " + f.getAbsolutePath());
        System.out.println(new Date(dictInfo.getLastModified()));
        System.out.println(JsonUtil.writeValueAsIndentString(dictInfo));
        dictInfo.getDictionaryObject().dump(System.out);
        System.out.println();
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:20,代码来源:DumpDictionaryCLI.java


示例15: basic

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
@Ignore("hive not ready")
public void basic() throws Exception {
    CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_without_slr_desc");
    TblColRef col = cubeDesc.findColumnRef("DEFAULT.TEST_CATEGORY_GROUPINGS", "META_CATEG_NAME");

    DictionaryInfo info1 = dictMgr.buildDictionary(cubeDesc.getModel(), cubeDesc.getRowkey().getDictionary(col), col, null);
    System.out.println(JsonUtil.writeValueAsIndentString(info1));

    DictionaryInfo info2 = dictMgr.buildDictionary(cubeDesc.getModel(), cubeDesc.getRowkey().getDictionary(col), col, null);
    System.out.println(JsonUtil.writeValueAsIndentString(info2));

    assertTrue(info1.getUuid() == info2.getUuid());

    assertTrue(info1 == dictMgr.getDictionaryInfo(info1.getResourcePath()));
    assertTrue(info2 == dictMgr.getDictionaryInfo(info2.getResourcePath()));

    assertTrue(info1.getDictionaryObject() == info2.getDictionaryObject());

    touchDictValues(info1);
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:22,代码来源:DictionaryManagerTest.java


示例16: execute

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
public void execute(String owner, String output, String inputConfig) throws Exception {
    if (Strings.isNullOrEmpty(owner)) {
        owner = "ADMIN";
    }
    if (!output.endsWith("/")) {
        output += "/";
    }

    Set<SinkTool> sourceToolSet = JsonUtil.readValueWithTyping(
            new BufferedInputStream(new FileInputStream(new File(inputConfig))), HashSet.class);
    run(owner, output, sourceToolSet);
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:SCCreator.java


示例17: convertOldTableExtToNewer

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
private TableExtDesc convertOldTableExtToNewer(String resourceName) {
    ResourceStore store = getStore();
    Map<String, String> attrs = Maps.newHashMap();

    try {
        RawResource res = store.getResource(
                ResourceStore.TABLE_EXD_RESOURCE_ROOT + "/" + resourceName + MetadataConstants.FILE_SURFIX);

        InputStream is = res.inputStream;
        try {
            attrs.putAll(JsonUtil.readValue(is, HashMap.class));
        } finally {
            if (is != null)
                is.close();
        }
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }

    String cardinality = attrs.get(MetadataConstants.TABLE_EXD_CARDINALITY);

    // parse table identity from file name
    String tableIdentity = TableDesc.parseResourcePath(resourceName).getFirst();
    TableExtDesc result = new TableExtDesc();
    result.setIdentity(tableIdentity);
    result.setUuid(UUID.randomUUID().toString());
    result.setLastModified(0);
    result.setCardinality(cardinality);
    return result;
}
 
开发者ID:apache,项目名称:kylin,代码行数:31,代码来源:TableMetadataManager.java


示例18: testGetCopyOf

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testGetCopyOf() throws JsonProcessingException {
    DataModelDesc desc = DataModelManager.getInstance(getTestConfig()).getDataModelDesc("test_kylin_inner_join_model_desc");
    DataModelDesc copyDesc = DataModelDesc.getCopyOf(desc);

    // uuid is different, set to equals for json comparison
    copyDesc.setUuid(desc.getUuid());
    copyDesc.setLastModified(desc.getLastModified());

    String descStr = JsonUtil.writeValueAsIndentString(desc);
    String copyStr = JsonUtil.writeValueAsIndentString(copyDesc);

    assertEquals(descStr, copyStr);
}
 
开发者ID:apache,项目名称:kylin,代码行数:15,代码来源:DataModelDescTest.java


示例19: testPartitionDescCopyOf

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
@Test
public void testPartitionDescCopyOf() throws JsonProcessingException {
    PartitionDesc desc = DataModelManager.getInstance(getTestConfig()).getDataModelDesc("test_kylin_inner_join_model_desc").partitionDesc;
    PartitionDesc copyDesc = PartitionDesc.getCopyOf(desc);

    String descStr = JsonUtil.writeValueAsIndentString(desc);
    String copyStr = JsonUtil.writeValueAsIndentString(copyDesc);

    assertEquals(descStr, copyStr);
}
 
开发者ID:apache,项目名称:kylin,代码行数:11,代码来源:DataModelDescTest.java


示例20: mockUpOldTableExtJson

import org.apache.kylin.common.util.JsonUtil; //导入依赖的package包/类
private void mockUpOldTableExtJson(String tableId, Map<String, String> tableExdProperties) throws IOException {
    String path = TableExtDesc.concatResourcePath(tableId, null);

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    JsonUtil.writeValueIndent(os, tableExdProperties);
    os.flush();
    InputStream is = new ByteArrayInputStream(os.toByteArray());
    getStore().putResource(path, is, System.currentTimeMillis());
    os.close();
    is.close();
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:TableMetadataManagerTest.java



注:本文中的org.apache.kylin.common.util.JsonUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommentsServiceImpl类代码示例发布时间:2022-05-16
下一篇:
Java BrokerStartup类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap