本文整理了Java中org.apache.kylin.common.util.Dictionary.readFields()
方法的一些代码示例,展示了Dictionary.readFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dictionary.readFields()
方法的具体详情如下:
包路径:org.apache.kylin.common.util.Dictionary
类名称:Dictionary
方法名:readFields
[英]Deserialize the fields of this object from in
.
For efficiency, implementations should attempt to re-use storage in the existing object where possible.
[中]从in
反序列化此对象的字段。
为了提高效率,实现应尽可能重复使用现有对象中的存储。
代码示例来源:origin: apache/kylin
public static Dictionary<?> deserialize(InputStream inputStream) {
try {
final DataInputStream dataInputStream = new DataInputStream(inputStream);
final String type = dataInputStream.readUTF();
final Dictionary<?> dictionary = ClassUtil.forName(type, Dictionary.class).getDeclaredConstructor().newInstance();
dictionary.readFields(dataInputStream);
return dictionary;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/kylin
@Override
public DictionaryInfo deserialize(DataInputStream in) throws IOException {
String json = in.readUTF();
DictionaryInfo obj = JsonUtil.readValue(json, DictionaryInfo.class);
if (infoOnly == false) {
Dictionary<String> dict;
try {
dict = (Dictionary<String>) ClassUtil.forName(obj.getDictionaryClass(), Dictionary.class).getDeclaredConstructor().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
dict.readFields(in);
obj.setDictionaryObject(dict);
}
return obj;
}
代码示例来源:origin: apache/kylin
shrunkenDict.readFields(dis);
代码示例来源:origin: apache/kylin
dict.readFields(in);
代码示例来源:origin: apache/kylin
private void readWriteTest(Dictionary<String> dict) throws Exception {
final String path = "src/test/resources/dict/tmp_dict";
File f = new File(path);
f.deleteOnExit();
f.createNewFile();
String dictClassName = dict.getClass().getName();
DataOutputStream out = new DataOutputStream(new FileOutputStream(f));
out.writeUTF(dictClassName);
dict.write(out);
out.close();
//read dict
DataInputStream in = null;
Dictionary<String> dict2 = null;
try {
File f2 = new File(path);
in = new DataInputStream(new FileInputStream(f2));
String dictClassName2 = in.readUTF();
dict2 = (Dictionary<String>) ClassUtil.newInstance(dictClassName2);
dict2.readFields(in);
} finally {
if (in != null) {
in.close();
}
}
assertTrue(dict.equals(dict2));
}
}
代码示例来源:origin: apache/kylin
String dictClassName = is.readUTF();
Dictionary<String> dict = (Dictionary<String>) ClassUtil.newInstance(dictClassName);
dict.readFields(is);
logger.info("DictionaryProvider read dict from file: " + dictFile);
return dict;
代码示例来源:origin: apache/kylin
dShrunkenDict.readFields(dis);
代码示例来源:origin: org.apache.kylin/kylin-core-dictionary
public static Dictionary<?> deserialize(InputStream inputStream) {
try {
final DataInputStream dataInputStream = new DataInputStream(inputStream);
final String type = dataInputStream.readUTF();
final Dictionary<?> dictionary = ClassUtil.forName(type, Dictionary.class).getDeclaredConstructor().newInstance();
dictionary.readFields(dataInputStream);
return dictionary;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.kylin/kylin-dictionary
@Override
public DictionaryInfo deserialize(DataInputStream in) throws IOException {
String json = in.readUTF();
DictionaryInfo obj = JsonUtil.readValue(json, DictionaryInfo.class);
if (infoOnly == false) {
Dictionary<?> dict;
try {
dict = (Dictionary<?>) ClassUtil.forName(obj.getDictionaryClass(), Dictionary.class).newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
dict.readFields(in);
obj.setDictionaryObject(dict);
}
return obj;
}
代码示例来源:origin: org.apache.kylin/kylin-core-dictionary
@Override
public DictionaryInfo deserialize(DataInputStream in) throws IOException {
String json = in.readUTF();
DictionaryInfo obj = JsonUtil.readValue(json, DictionaryInfo.class);
if (infoOnly == false) {
Dictionary<String> dict;
try {
dict = (Dictionary<String>) ClassUtil.forName(obj.getDictionaryClass(), Dictionary.class).getDeclaredConstructor().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
dict.readFields(in);
obj.setDictionaryObject(dict);
}
return obj;
}
代码示例来源:origin: org.apache.kylin/kylin-dictionary
dict.readFields(in);
代码示例来源:origin: org.apache.kylin/kylin-engine-mr
shrunkenDict.readFields(dis);
代码示例来源:origin: org.apache.kylin/kylin-core-dictionary
dict.readFields(in);
代码示例来源:origin: org.apache.kylin/kylin-engine-mr
String dictClassName = is.readUTF();
Dictionary<String> dict = (Dictionary<String>) ClassUtil.newInstance(dictClassName);
dict.readFields(is);
logger.info("DictionaryProvider read dict from file: " + dictFile);
return dict;
内容来源于网络,如有侵权,请联系作者删除!