本文整理汇总了Java中org.apache.kylin.common.util.JsonUtil.readValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtil.readValue方法的具体用法?Java JsonUtil.readValue怎么用?Java JsonUtil.readValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.common.util.JsonUtil
的用法示例。
在下文中一共展示了JsonUtil.readValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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"));
}
}
示例4: 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());
}
示例5: deserialize
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Override
public SnapshotTable deserialize(DataInputStream in) throws IOException {
String json = in.readUTF();
SnapshotTable obj = JsonUtil.readValue(json, SnapshotTable.class);
if (infoOnly == false)
obj.readData(in);
return obj;
}
示例6: getCuboids
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
public Map<Long, Long> getCuboids() {
if (cuboidBytes == null)
return null;
byte[] uncompressed;
try {
uncompressed = CompressionUtils.decompress(cuboidBytes);
String str = new String(uncompressed, "UTF-8");
TypeReference<Map<Long, Long>> typeRef = new TypeReference<Map<Long, Long>>() {
};
Map<Long, Long> cuboids = JsonUtil.readValue(str, typeRef);
return cuboids.isEmpty() ? null : cuboids;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例7: getCuboidsRecommend
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
public Set<Long> getCuboidsRecommend() {
if (cuboidBytesRecommend == null)
return null;
byte[] uncompressed;
try {
uncompressed = CompressionUtils.decompress(cuboidBytesRecommend);
String str = new String(uncompressed, "UTF-8");
TypeReference<Set<Long>> typeRef = new TypeReference<Set<Long>>() {
};
Set<Long> cuboids = JsonUtil.readValue(str, typeRef);
return cuboids.isEmpty() ? null : cuboids;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例8: testGoodDesc2
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testGoodDesc2() throws IOException {
ValidateContext vContext = new ValidateContext();
CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };
IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
rule.validate(desc, vContext);
//vContext.print(System.out);
assertEquals(1, vContext.getResults().length);
}
示例9: testBadDesc1
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testBadDesc1() throws IOException {
ValidateContext vContext = new ValidateContext();
CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);
desc.getAggregationGroups().get(0).setIncludes(temp);
IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
rule.validate(desc, vContext);
//vContext.print(System.out);
assertEquals(1, vContext.getResults().length);
assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
}
示例10: testBadDesc2
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testBadDesc2() throws IOException {
ValidateContext vContext = new ValidateContext();
CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
rule.validate(desc, vContext);
//vContext.print(System.out);
assertEquals(2, vContext.getResults().length);
assertEquals("Aggregation group 1 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
}
示例11: testGoodDesc
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testGoodDesc() throws IOException {
DictionaryRule rule = new DictionaryRule();
for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
if (!f.getName().endsWith("json")) {
continue;
}
CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
desc.init(config);
ValidateContext vContext = new ValidateContext();
rule.validate(desc, vContext);
assertTrue(vContext.getResults().length == 0);
}
}
示例12: deserializeProjectDesc
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
private ProjectInstance deserializeProjectDesc(ProjectRequest projectRequest) {
ProjectInstance projectDesc = null;
try {
logger.debug("Saving project " + projectRequest.getProjectDescData());
projectDesc = JsonUtil.readValue(projectRequest.getProjectDescData(), ProjectInstance.class);
} catch (Exception e) {
logger.error("Failed to deal with the request.", e);
throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e);
}
return projectDesc;
}
示例13: deserialize
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
public T deserialize(byte[] value) throws JsonParseException, JsonMappingException, IOException {
if (null == value) {
return null;
}
return JsonUtil.readValue(value, type);
}
示例14: testSerialize
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testSerialize() throws Exception {
CubeDesc desc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC);
String str = JsonUtil.writeValueAsIndentString(desc);
//System.out.println(str);
@SuppressWarnings("unused")
CubeDesc desc2 = JsonUtil.readValue(str, CubeDesc.class);
}
示例15: testGoodDesc
import org.apache.kylin.common.util.JsonUtil; //导入方法依赖的package包/类
@Test
public void testGoodDesc() throws IOException {
for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
ValidateContext vContext = new ValidateContext();
IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
rule.validate(desc, vContext);
vContext.print(System.out);
assertTrue(vContext.getResults().length == 0);
}
}