本文整理了Java中co.cask.cdap.api.common.Bytes.toBytesBinary()
方法的一些代码示例,展示了Bytes.toBytesBinary()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.toBytesBinary()
方法的具体详情如下:
包路径:co.cask.cdap.api.common.Bytes
类名称:Bytes
方法名:toBytesBinary
暂无
代码示例来源:origin: cdapio/cdap
/**
* Deserialize a list of {@link Split}s encoded by the {@link #encode(Iterable)} method
*
* @param encoded the encoded string produced by the {@link #encode(Iterable)} method
* @param splits a {@link Collection} for storing the decoded splits
* @param classLoader the {@link ClassLoader} for loading the {@link Split} class
* @param <T> type of the {@link Collection}
* @return the same {@link Collection} passed in the arguments
* @throws IOException if failed to deserialize
* @throws ClassNotFoundException if failed to load the {@link Split} class.
*/
public static <T extends Collection<? super Split>> T decode(String encoded, T splits, ClassLoader classLoader)
throws IOException, ClassNotFoundException {
InputStream is = new ByteArrayInputStream(Bytes.toBytesBinary(encoded));
try (DataInputStream in = new DataInputStream(is)) {
while (in.available() > 0) {
splits.add(deserialize(in, classLoader));
}
}
return splits;
}
代码示例来源:origin: co.cask.cdap/cdap-common
@Override
public StreamEvent read(JsonReader in) throws IOException {
long timestamp = -1;
Map<String, String> headers = null;
ByteBuffer body = null;
in.beginObject();
while (in.peek() == JsonToken.NAME) {
String key = in.nextName();
if ("timestamp".equals(key)) {
timestamp = in.nextLong();
} else if ("headers".equals(key)) {
headers = mapTypeAdapter.read(in);
} else if ("body".equals(key)) {
body = ByteBuffer.wrap(Bytes.toBytesBinary(in.nextString()));
} else {
in.skipValue();
}
}
if (timestamp >= 0 && headers != null && body != null) {
in.endObject();
return new StreamEvent(headers, body, timestamp);
}
throw new IOException(String.format("Failed to read StreamEvent. Timestamp: %d, headers: %s, body: %s",
timestamp, headers, body));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public List<InputSplit> getSplits(final JobContext context) throws IOException, InterruptedException {
// Decode splits from Configuration
String splitsConf = context.getConfiguration().get(SPLITS);
if (splitsConf == null) {
throw new IOException("No input splits available from job configuration.");
}
ByteArrayDataInput dataInput = ByteStreams.newDataInput(Bytes.toBytesBinary(splitsConf));
int size = dataInput.readInt();
List<InputSplit> splits = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
DataSetInputSplit inputSplit = new DataSetInputSplit();
inputSplit.readFields(dataInput);
splits.add(inputSplit);
}
return splits;
}
代码示例来源:origin: co.cask.cdap/cdap-app-fabric
@Override
public List<InputSplit> getSplits(final JobContext context) throws IOException, InterruptedException {
// Decode splits from Configuration
String splitsConf = context.getConfiguration().get(SPLITS);
if (splitsConf == null) {
throw new IOException("No input splits available from job configuration.");
}
ByteArrayDataInput dataInput = ByteStreams.newDataInput(Bytes.toBytesBinary(splitsConf));
int size = dataInput.readInt();
List<InputSplit> splits = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
DataSetInputSplit inputSplit = new DataSetInputSplit();
inputSplit.readFields(dataInput);
splits.add(inputSplit);
}
return splits;
}
代码示例来源:origin: cdapio/cdap
return Double.parseDouble(strVal);
case BYTES:
return Bytes.toBytesBinary(strVal);
case STRING:
return strVal;
代码示例来源:origin: co.cask.cdap/cdap-api-common
return Double.parseDouble(strVal);
case BYTES:
return Bytes.toBytesBinary(strVal);
case STRING:
return strVal;
内容来源于网络,如有侵权,请联系作者删除!