本文整理匯總了Java中com.google.protobuf.CodedOutputStream.writeUInt32NoTag方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.writeUInt32NoTag方法的具體用法?Java CodedOutputStream.writeUInt32NoTag怎麽用?Java CodedOutputStream.writeUInt32NoTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.protobuf.CodedOutputStream
的用法示例。
在下文中一共展示了CodedOutputStream.writeUInt32NoTag方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeToList
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
* write list to {@link CodedOutputStream} object.
*
* @param out target output stream to write
* @param order field order
* @param type field type
* @param list target list object to be serialized
* @param packed the packed
* @throws IOException Signals that an I/O exception has occurred.
*/
public static void writeToList(CodedOutputStream out, int order, FieldType type, List list, boolean packed)
throws IOException {
if (list == null || list.isEmpty()) {
return;
}
if (packed) {
out.writeUInt32NoTag(makeTag(order, WireFormat.WIRETYPE_LENGTH_DELIMITED));
out.writeUInt32NoTag(computeListSize(order, list, type, false, null, packed, true));
}
for (Object object : list) {
writeObject(out, order, type, object, true, !packed);
}
}
示例2: savePreprocessedBlock
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private void savePreprocessedBlock(BlockContext context, List<RtbImpression> impressions) throws IOException {
try (OutputStream os = context.createOutputStream(PREPROCESS)) {
CodedOutputStream cos = CodedOutputStream.newInstance(os);
for (RtbImpression impression : impressions) {
if (impression == null) continue;;
byte[] bytes = impression.toByteArray();
cos.writeUInt32NoTag(bytes.length);
cos.writeRawBytes(bytes);
}
cos.flush();
}
}
示例3: serializeTo
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
* Serializes the provided key and value as though they were wrapped by a {@link MapEntryLite} to the output stream.
* This helper method avoids allocation of a {@link MapEntryLite} built with a key and value and is called from
* generated code directly.
*
* @param output the output
* @param fieldNumber the field number
* @param key the key
* @param value the value
* @throws IOException Signals that an I/O exception has occurred.
*/
public void serializeTo(CodedOutputStream output, int fieldNumber, K key, V value) throws IOException {
output.writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
output.writeUInt32NoTag(computeSerializedSize(metadata, key, value));
writeTo(output, metadata, key, value);
}