本文整理了Java中com.google.protobuf.ByteString.concat()
方法的一些代码示例,展示了ByteString.concat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.concat()
方法的具体详情如下:
包路径:com.google.protobuf.ByteString
类名称:ByteString
方法名:concat
[英]Concatenate the given ByteString to this one. Short concatenations, of total size smaller than ByteString#CONCATENATE_BY_COPY_SIZE, are produced by copying the underlying bytes (as per Rope.java, BAP95. In general, the concatenate involves no copying.
[中]将给定的ByteString连接到此ByteString。总大小小于ByteString#CONCATENATE _BY _COPY _size的短连接是通过复制底层字节(根据Rope.java,BAP95)生成的。通常,连接不涉及复制。
代码示例来源:origin: googleapis/google-cloud-java
/** {@inheritDoc} */
@Override
public void cellValue(ByteString value) {
this.value = this.value.concat(value);
}
代码示例来源:origin: com.google.protobuf/protobuf-java
private static ByteString balancedConcat(Iterator<ByteString> iterator, int length) {
if (length < 1) {
throw new IllegalArgumentException(String.format("length (%s) must be >= 1", length));
}
ByteString result;
if (length == 1) {
result = iterator.next();
} else {
int halfLength = length >>> 1;
ByteString left = balancedConcat(iterator, halfLength);
ByteString right = balancedConcat(iterator, length - halfLength);
result = left.concat(right);
}
return result;
}
代码示例来源:origin: osmandapp/Osmand
private static ByteString balancedConcat(Iterator<ByteString> iterator,
int length) {
assert length >= 1;
ByteString result;
if (length == 1) {
result = iterator.next();
} else {
int halfLength = length >>> 1;
ByteString left = balancedConcat(iterator, halfLength);
ByteString right = balancedConcat(iterator, length - halfLength);
result = left.concat(right);
}
return result;
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void lengthTest() {
ByteString a = ByteString.copyFromUtf8("a");
ByteString a_ = ByteString.copyFromUtf8("b").concat(ByteString.copyFrom(new byte[] {0}));
Truth.assertThat(ByteStringComparator.INSTANCE.compare(a, a_)).isEqualTo(-1);
Truth.assertThat(ByteStringComparator.INSTANCE.compare(a_, a)).isEqualTo(1);
}
}
代码示例来源:origin: com.google.protobuf/protobuf-java
setByteString(this.delayedBytes.concat(input.readBytes()), this.extensionRegistry);
return;
代码示例来源:origin: line/armeria
/**
* Generates a payload of desired type and size. Reads compressableBuffer or
* uncompressableBuffer as a circular buffer.
*/
private ByteString generatePayload(ByteString dataBuffer, int offset, int size) {
ByteString payload = ByteString.EMPTY;
// This offset would never pass the array boundary.
int begin = offset;
int end = 0;
int bytesLeft = size;
while (bytesLeft > 0) {
end = Math.min(begin + bytesLeft, dataBuffer.size());
// ByteString.substring returns the substring from begin, inclusive, to end, exclusive.
payload = payload.concat(dataBuffer.substring(begin, end));
bytesLeft -= (end - begin);
begin = end % dataBuffer.size();
}
return payload;
}
代码示例来源:origin: googleapis/google-cloud-java
public static ByteStringRange prefix(ByteString prefix) {
if (prefix.isEmpty()) {
return unbounded();
}
int offset = prefix.size() - 1;
int curByte = 0xFF;
while (offset >= 0) {
curByte = prefix.byteAt(offset) & 0xFF;
if (curByte != 0xFF) {
break;
}
offset--;
}
if (offset < 0) {
// We got an 0xFFFF... (only FFs) stopRow value which is
// the last possible prefix before the end of the table.
// So set it to stop at the 'end of the table'
return unbounded().startClosed(prefix);
}
ByteString endPrefix = offset == 0 ? ByteString.EMPTY : prefix.substring(0, offset);
ByteString endSuffix = UnsafeByteOperations.unsafeWrap(new byte[] {(byte) (curByte + 1)});
ByteString end = endPrefix.concat(endSuffix);
ByteStringRange range = ByteStringRange.unbounded().startClosed(prefix);
if (!end.isEmpty()) {
range.endOpen(end);
}
return range;
}
代码示例来源:origin: com.google.protobuf/protobuf-java
this.delayedBytes = this.delayedBytes.concat(other.delayedBytes);
return;
代码示例来源:origin: hyperledger/fabric-sdk-java
public ByteString signByteStrings(ByteString... bs) throws CryptoException, InvalidArgumentException {
if (bs == null) {
return null;
}
if (bs.length == 0) {
return null;
}
if (bs.length == 1 && bs[0] == null) {
return null;
}
ByteString f = bs[0];
for (int i = 1; i < bs.length; ++i) {
f = f.concat(bs[i]);
}
return ByteString.copyFrom(sign(f.toByteArray()));
}
代码示例来源:origin: hyperledger/fabric-sdk-java
public ByteString[] signByteStrings(User[] users, ByteString... bs) throws CryptoException, InvalidArgumentException {
if (bs == null) {
return null;
}
if (bs.length == 0) {
return null;
}
if (bs.length == 1 && bs[0] == null) {
return null;
}
ByteString f = bs[0];
for (int i = 1; i < bs.length; ++i) {
f = f.concat(bs[i]);
}
final byte[] signbytes = f.toByteArray();
ByteString[] ret = new ByteString[users.length];
int i = -1;
for (User user : users) {
// Get the signing identity from the user
SigningIdentity signingIdentity = IdentityFactory.getSigningIdentity(cryptoPrimitives, user);
// generate signature
ret[++i] = ByteString.copyFrom(signingIdentity.sign(signbytes));
}
return ret;
}
代码示例来源:origin: hyperledger/fabric-sdk-java
public TransactionContext(Channel channel, User user, CryptoSuite cryptoPrimitives) {
this.user = user;
this.channel = channel;
//TODO clean up when public classes are interfaces.
this.verify = !"".equals(channel.getName()); //if name is not blank not system channel and need verify.
// this.txID = transactionID;
this.cryptoPrimitives = cryptoPrimitives;
// Get the signing identity from the user
this.signingIdentity = IdentityFactory.getSigningIdentity(cryptoPrimitives, user);
// Serialize signingIdentity
this.identity = signingIdentity.createSerializedIdentity();
ByteString no = getNonce();
ByteString comp = no.concat(identity.toByteString());
byte[] txh = cryptoPrimitives.hash(comp.toByteArray());
// txID = Hex.encodeHexString(txh);
txID = new String(Utils.toHexString(txh));
toString = "TransactionContext{ txID: " + txID + ", mspid: " + user.getMspId() + ", user: " + user.getName() + "}";
}
代码示例来源:origin: hyperledger/fabric-sdk-java
Identities.SerializedIdentity endorser = Identities.SerializedIdentity
.parseFrom(endorsement.getEndorser());
ByteString plainText = proposalResponse.getPayload().concat(endorsement.getEndorser());
代码示例来源:origin: com.google.cloud/google-cloud-bigtable
/** {@inheritDoc} */
@Override
public void cellValue(ByteString value) {
this.value = this.value.concat(value);
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
public void merge(LazyFieldLite value) {
if (value.containsDefaultInstance()) {
return;
}
if (bytes == null) {
this.bytes = value.bytes;
} else {
this.bytes.concat(value.toByteString());
}
isDirty = false;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
public Builder mergeFrom(protobuf_unittest.NestedExtensionLite.MyNestedExtensionLite other) {
if (other == protobuf_unittest.NestedExtensionLite.MyNestedExtensionLite.getDefaultInstance()) return this;
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
public Builder mergeFrom(com.google.protobuf.UnittestLite.TestAllExtensionsLite other) {
if (other == com.google.protobuf.UnittestLite.TestAllExtensionsLite.getDefaultInstance()) return this;
this.mergeExtensionFields(other);
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
public Builder mergeFrom(protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar other) {
if (other == protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar.getDefaultInstance()) return this;
if (other.hasName()) {
bitField0_ |= 0x00000001;
name_ = other.name_;
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
public Builder mergeFrom(com.google.protobuf.UnittestLite.ForeignMessageLite other) {
if (other == com.google.protobuf.UnittestLite.ForeignMessageLite.getDefaultInstance()) return this;
if (other.hasC()) {
setC(other.getC());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
public Builder mergeFrom(com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup other) {
if (other == com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup.getDefaultInstance()) return this;
if (other.hasA()) {
setA(other.getA());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
代码示例来源:origin: OpenNMS/opennms
public Builder mergeFrom(LspMon.lsp_monitor_data_event other) {
if (other == LspMon.lsp_monitor_data_event.getDefaultInstance()) return this;
if (other.hasEventIdentifier()) {
setEventIdentifier(other.getEventIdentifier());
}
if (other.hasSubcode()) {
setSubcode(other.getSubcode());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
}
内容来源于网络,如有侵权,请联系作者删除!