本文整理了Java中co.cask.cdap.api.common.Bytes.toString()
方法的一些代码示例,展示了Bytes.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.toString()
方法的具体详情如下:
包路径:co.cask.cdap.api.common.Bytes
类名称:Bytes
方法名:toString
[英]This method will convert the remaining bytes of a UTF8 encoded byte buffer into a string.
[中]此方法将UTF8编码字节缓冲区的剩余字节转换为字符串。
代码示例来源:origin: caskdata/cdap
@Override
public ResourceAssignment decode(byte[] data) throws IOException {
return GSON.fromJson(Bytes.toString(data), ResourceAssignment.class);
}
};
代码示例来源:origin: caskdata/cdap
@Override
public ResourceRequirement decode(byte[] data) throws IOException {
String json = Bytes.toString(data);
return CoordinationConstants.GSON.fromJson(json, ResourceRequirement.class);
}
};
代码示例来源:origin: cdapio/cdap
@Override
@Nullable
public String getString(byte[] column) {
byte[] val = get(column);
return val == null ? null : Bytes.toString(columns.get(column));
}
代码示例来源:origin: cdapio/cdap
/**
* @throws BufferUnderflowException if there is no String as expected
* @return the next String part in the splitter
*/
public String getString() {
return Bytes.toString(getBytes());
}
代码示例来源:origin: cdapio/cdap
@Override
public String decode(byte[] data) throws IOException {
return Bytes.toString(data);
}
}
代码示例来源:origin: cdapio/cdap
public ReplicationStatusKey(byte[] key) {
ByteBuffer byteBuffer = ByteBuffer.wrap(key);
this.key = key;
this.rowType = Bytes.toString(getBytes(byteBuffer));
this.regionName = Bytes.toString(getBytes(byteBuffer));
this.rsID = new UUID(byteBuffer.getLong(), byteBuffer.getLong());
}
代码示例来源:origin: cdapio/cdap
@Override
protected void map(byte[] key, byte[] value, Context context) throws IOException, InterruptedException {
context.write(Bytes.toString(key), Bytes.toString(value));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public synchronized Integer getServiceInstance(final String serviceName) {
String count = Bytes.toString(table.get(Bytes.toBytes(serviceName)));
return (count != null) ? Integer.valueOf(count) : null;
}
代码示例来源:origin: cdapio/cdap
private Job fromRow(Row row) {
String jobJsonString = Bytes.toString(row.get(COL));
SimpleJob job = GSON.fromJson(jobJsonString, SimpleJob.class);
Long toBeDeletedTime = row.getLong(TO_DELETE_COL);
Long isObsoleteTime = row.getLong(IS_OBSOLETE_COL);
Long timeToSet = toBeDeletedTime == null ? isObsoleteTime :
isObsoleteTime == null ? toBeDeletedTime : new Long(Math.min(isObsoleteTime, toBeDeletedTime));
if (timeToSet != null) {
job.setToBeDeleted(timeToSet);
}
return job;
}
代码示例来源:origin: cdapio/cdap
@Override
public void map(byte[] rowKey, Row row, Context context)
throws IOException, InterruptedException {
context.write(new Text(Bytes.toString(rowKey)),
new Text(Bytes.toString(row.get(ONLY_COLUMN))));
}
}
代码示例来源:origin: caskdata/cdap
@Override
protected TopicMetadata computeNext() {
if (closed || (!iterator.hasNext())) {
return endOfData();
}
Map.Entry<byte[], byte[]> entry = iterator.next();
TopicId topicId = MessagingUtils.toTopicId(entry.getKey());
Map<String, String> properties = GSON.fromJson(Bytes.toString(entry.getValue()), MAP_TYPE);
return new TopicMetadata(topicId, properties);
}
代码示例来源:origin: cdapio/cdap
/**
* Gets the id of the last fetched message that was set the given TMS topic
*
* @param topic the topic to lookup the last message id
* @return the id of the last fetched message for this subscriber on this topic,
* or {@code null} if no message id was stored before
*/
public String retrieveSubscriberState(String topic) {
Row row = table.get(getRowKey(topic));
byte[] messageIdBytes = row.get(COL);
return messageIdBytes == null ? null : Bytes.toString(messageIdBytes);
}
代码示例来源:origin: caskdata/cdap
private DatasetAdminOpResponse getResponse(byte[] body) {
return Objects.firstNonNull(GSON.fromJson(Bytes.toString(body), DatasetAdminOpResponse.class),
new DatasetAdminOpResponse(null, null));
}
}
代码示例来源:origin: cdapio/cdap
@GET
@Path("ping/{key}")
public void ping(HttpServiceRequest request, HttpServiceResponder responder,
@PathParam("key") String key) throws IOException {
responder.sendJson(Bytes.toString(table.read(key)));
}
代码示例来源:origin: cdapio/cdap
@Override
@Nullable
public KerberosPrincipalId getOwner(final NamespacedEntityId entityId) throws IOException {
validate(entityId);
return Transactionals.execute(transactional, context -> {
byte[] principalBytes = getTable(context).get(createRowKey(entityId), COL);
return principalBytes == null ? null : new KerberosPrincipalId(Bytes.toString(principalBytes));
}, IOException.class);
}
代码示例来源:origin: cdapio/cdap
@Override
public void map(byte[] key, byte[] value, Context context) throws IOException, InterruptedException {
LOG.info("Hello " + loadTestClasses());
byte[] realVal = Bytes.toBytes(Bytes.toString(value) + "=map=" + loadTestClasses());
context.write(new BytesWritable(key), new BytesWritable(realVal));
}
}
代码示例来源:origin: cdapio/cdap
@GET
@Path("read/{key}")
public void readDataSet(HttpServiceRequest request, HttpServiceResponder responder,
@PathParam("key") String key) throws IOException {
byte[] value = table.read(key);
if (value == null) {
responder.sendError(404, "Table returned null for value: " + key);
return;
}
responder.sendJson(Bytes.toString(value));
}
}
代码示例来源:origin: cdapio/cdap
@Override
public void apply() {
// the table should not have initialized=true
Assert.assertEquals(expected, Bytes.toString(kvTable.read("initialized")));
}
});
代码示例来源:origin: cdapio/cdap
@Override
public void create() throws IOException {
ColumnFamilyDescriptorBuilder cfdBuilder =
HBaseTableUtil.getColumnFamilyDescriptorBuilder(Bytes.toString(DATA_COLUMN_FAMILY), hConf);
TableDescriptorBuilder tdBuilder = HBaseTableUtil.getTableDescriptorBuilder(tableId, cConf)
.addColumnFamily(cfdBuilder.build());
try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get()) {
ddlExecutor.createTableIfNotExists(tdBuilder.build(), null);
}
}
代码示例来源:origin: caskdata/cdap
@Override
public void apply() throws Exception {
Assert.assertEquals("value1", Bytes.toString(table.get(Bytes.toBytes("key1"),
Bytes.toBytes("column1"))));
}
});
内容来源于网络,如有侵权,请联系作者删除!