本文整理了Java中org.apache.hbase.thirdparty.com.google.protobuf.ByteString
类的一些代码示例,展示了ByteString
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString
类的具体详情如下:
包路径:org.apache.hbase.thirdparty.com.google.protobuf.ByteString
类名称:ByteString
暂无
代码示例来源:origin: apache/hbase
@Override
public byte[] uncompress(ByteString data, Enum dictIndex) {
return data.toByteArray();
}
}
代码示例来源:origin: apache/hbase
public ByteString toByteString() {
// We need this copy to create the ByteString as the byte[] 'buf' is not immutable. We reuse
// them.
return ByteString.copyFrom(this.buf, 0, this.count);
}
代码示例来源:origin: apache/hbase
/**
* <code>required string algorithm = 1;</code>
*/
public org.apache.hbase.thirdparty.com.google.protobuf.ByteString
getAlgorithmBytes() {
java.lang.Object ref = algorithm_;
if (ref instanceof java.lang.String) {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString b =
org.apache.hbase.thirdparty.com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
algorithm_ = b;
return b;
} else {
return (org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: apache/hbase
/**
* <code>optional string backup_id = 1;</code>
*/
public java.lang.String getBackupId() {
java.lang.Object ref = backupId_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString bs =
(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
backupId_ = s;
}
return s;
}
}
/**
代码示例来源:origin: apache/hbase
private static Key getUnwrapKey(Configuration conf, String subject,
EncryptionProtos.WrappedKey wrappedKey, Cipher cipher) throws IOException, KeyException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] iv = wrappedKey.hasIv() ? wrappedKey.getIv().toByteArray() : null;
Encryption.decryptWithSubjectKey(out, wrappedKey.getData().newInput(),
wrappedKey.getLength(), subject, conf, cipher, iv);
byte[] keyBytes = out.toByteArray();
if (wrappedKey.hasHash()) {
if (!Bytes.equals(wrappedKey.getHash().toByteArray(), Encryption.hash128(keyBytes))) {
throw new KeyException("Key was not successfully unwrapped");
}
}
return new SecretKeySpec(keyBytes, wrappedKey.getAlgorithm());
}
代码示例来源:origin: apache/hbase
@Override
protected void deserializeStateData(ProcedureStateSerializer serializer)
throws IOException {
BytesValue bytesValue = serializer.deserialize(BytesValue.class);
ByteString dataString = bytesValue.getValue();
if (dataString.isEmpty()) {
data = null;
} else {
data = dataString.toByteArray();
}
}
代码示例来源:origin: apache/hbase
/**
* Get TableCF in TableCFs, if not exist, return null.
* */
public static ReplicationProtos.TableCF getTableCF(ReplicationProtos.TableCF[] tableCFs,
String table) {
for (int i = 0, n = tableCFs.length; i < n; i++) {
ReplicationProtos.TableCF tableCF = tableCFs[i];
if (tableCF.getTableName().getQualifier().toStringUtf8().equals(table)) {
return tableCF;
}
}
return null;
}
代码示例来源:origin: apache/hbase
/**
* This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding
* buffers when working with ByteStrings
* @param builder current message builder
* @param bs ByteString containing the
* @throws IOException
*/
public static void mergeFrom(Message.Builder builder, ByteString bs) throws IOException {
final CodedInputStream codedInput = bs.newCodedInput();
codedInput.setSizeLimit(bs.size());
builder.mergeFrom(codedInput);
codedInput.checkLastTagWas(0);
}
代码示例来源:origin: apache/hbase
public static Message getResponse(
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse
result,
com.google.protobuf.Message responsePrototype)
throws IOException {
Message response;
if (result.getValue().hasValue()) {
Message.Builder builder = responsePrototype.newBuilderForType();
builder.mergeFrom(result.getValue().getValue().newInput());
response = builder.build();
} else {
response = responsePrototype.getDefaultInstanceForType();
}
if (LOG.isTraceEnabled()) {
LOG.trace("Master Result is value=" + response);
}
return response;
}
代码示例来源:origin: apache/hbase
/**
* <code>optional string failed_message = 6;</code>
*/
public java.lang.String getFailedMessage() {
java.lang.Object ref = failedMessage_;
if (!(ref instanceof java.lang.String)) {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString bs =
(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
failedMessage_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
代码示例来源:origin: apache/hbase
private Map<String, List<SnapshotRegionManifest.StoreFile>> getRegionHFileReferences(
final SnapshotRegionManifest manifest) {
Map<String, List<SnapshotRegionManifest.StoreFile>> familyMap =
new HashMap<>(manifest.getFamilyFilesCount());
for (SnapshotRegionManifest.FamilyFiles familyFiles: manifest.getFamilyFilesList()) {
familyMap.put(familyFiles.getFamilyName().toStringUtf8(),
new ArrayList<>(familyFiles.getStoreFilesList()));
}
return familyMap;
}
代码示例来源:origin: apache/hbase
public static byte [] toBytes(ByteString bs) {
return bs.toByteArray();
}
代码示例来源:origin: apache/hbase
private ByteString getByteString(byte[] bytes) {
// return singleton to reduce object allocation
return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
}
代码示例来源:origin: apache/hbase
/**
* <code>required string algorithm = 1;</code>
*/
public java.lang.String getAlgorithm() {
java.lang.Object ref = algorithm_;
if (!(ref instanceof java.lang.String)) {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString bs =
(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
algorithm_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
代码示例来源:origin: apache/hbase
/**
* <code>required string peer_id = 1;</code>
*/
public org.apache.hbase.thirdparty.com.google.protobuf.ByteString
getPeerIdBytes() {
java.lang.Object ref = peerId_;
if (ref instanceof java.lang.String) {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString b =
org.apache.hbase.thirdparty.com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
peerId_ = b;
return b;
} else {
return (org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
}
}
代码示例来源:origin: apache/hbase
/**
* Converts a user permission proto to a client user permission object.
* @param proto the protobuf UserPermission
* @return the converted UserPermission
*/
public static UserPermission toUserPermission(AccessControlProtos.UserPermission proto) {
return new UserPermission(proto.getUser().toStringUtf8(), toPermission(proto.getPermission()));
}
代码示例来源:origin: apache/hbase
private static String getStringForByteString(ByteString bs) {
return Bytes.toStringBinary(bs.toByteArray());
}
代码示例来源:origin: apache/hbase
@Override
public ByteString compress(byte[] data, Enum dictIndex) throws IOException {
writeCompressed(data, dictIndex);
// We need this copy to create the ByteString as the byte[] 'buf' is not immutable. We reuse
// them.
ByteString result = ByteString.copyFrom(this.buf, 0, this.count);
reset(); // Only resets the count - we reuse the byte array.
return result;
}
代码示例来源:origin: apache/hbase
/**
* <code>optional string remoteWALDir = 12;</code>
*/
public java.lang.String getRemoteWALDir() {
java.lang.Object ref = remoteWALDir_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString bs =
(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
remoteWALDir_ = s;
}
return s;
}
}
/**
代码示例来源:origin: apache/hbase
/**
* <code>required string peer_id = 1;</code>
*/
public org.apache.hbase.thirdparty.com.google.protobuf.ByteString
getPeerIdBytes() {
java.lang.Object ref = peerId_;
if (ref instanceof java.lang.String) {
org.apache.hbase.thirdparty.com.google.protobuf.ByteString b =
org.apache.hbase.thirdparty.com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
peerId_ = b;
return b;
} else {
return (org.apache.hbase.thirdparty.com.google.protobuf.ByteString) ref;
}
}
内容来源于网络,如有侵权,请联系作者删除!