本文整理汇总了Java中com.google.protobuf.GeneratedMessage.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于com.google.protobuf.GeneratedMessage包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public FileFragmentProto serialize(FileFragment fragment) {
FileFragmentProto.Builder builder = FileFragmentProto.newBuilder();
builder.setId(fragment.inputSourceId);
builder.setStartOffset(fragment.startKey);
builder.setLength(fragment.length);
builder.setPath(fragment.getPath().toString());
if(fragment.getDiskIds() != null) {
List<Integer> idList = new ArrayList<>();
for(int eachId: fragment.getDiskIds()) {
idList.add(eachId);
}
builder.addAllDiskIds(idList);
}
if(fragment.hostNames != null) {
builder.addAllHosts(fragment.hostNames);
}
return builder.build();
}
示例2: readRecord
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void readRecord(long fromInstanceId, long toInstanceId, ReadRecordCallback<Builder<? extends Builder>> readCallback) throws IOException,
UnsupportedChecksumAlgorithm, FileDamageException {
long tempInstanceId = fromInstanceId;
DataChunk endChunk = null;
while (true) {
DataChunk chunk = fileIndexer.findDataChunk(tempInstanceId);
if (chunk != null) {
ReadResult r = chunk.readRecord(tempInstanceId, toInstanceId, readCallback);
tempInstanceId = r.getMaxSuccessInstanceId() + 1;
if (chunk == endChunk) {
break;
}
endChunk = chunk;
} else {
break;
}
}
}
示例3: newInstance
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder<?> newInstance(byte msgId) {
Method builder = builders.get(Integer.valueOf(msgId));
if (builder == null) return null;
try {
return (Builder<?>) builder.invoke(null);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException ("Unable to create new builder instance for msgId " + msgId, e);
}
}
示例4: read
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public void read(long instanceId, Builder<? extends Builder> b) {
if (b instanceof SuccessfulRecord.Builder) {
sortedReadCallback.read(instanceId, (SuccessfulRecord.Builder)b);
} else {
try {
out.writeVoteRecord(instanceId, (InstanceVoteRecord) b.build(), null);
}catch (Throwable e) {
logger.error("upgrade error", e);
isError = true;
}
}
}
示例5: initRead
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public ReadResult initRead(long startInstanceId, ReadRecordCallback<Builder<? extends Builder>> readCallback) throws IOException,
UnsupportedChecksumAlgorithm {
if (logger.isDebugEnabled()) {
logger.debug(String.format("initRead from:%s file:%s", startInstanceId, file.getAbsoluteFile()));
}
ReadResult r = readRecord(startInstanceId, Long.MAX_VALUE, readCallback);
used = r.pos;
if (this.maxVoteInstanceId < r.maxVoteInstanceId) {
this.maxVoteInstanceId = r.maxVoteInstanceId;
}
this.successfullInstanceId = r.maxSuccessInstanceId;
return r;
}
示例6: writeSuccess
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
public void writeSuccess(long instanceId, SuccessfulRecord.Builder successRecord, Record record,Callable<Object> realEvent) throws IOException, ChunkFullException {
if (successfullInstanceId >= instanceId) {
//the success has written and give up write,
return;
} else if (successfullInstanceId + 1 == instanceId) {
checkBufferout();
int recordLen = record.getSerializeSize();
if (maxVoteInstanceId >= instanceId || capacity >= (used + recordLen)) {
record.writeToStream(writeStream, realEvent, realEvent != null);
++successfullInstanceId;
if (successRecord.getV().getType() == ValueType.PLACE.getValue()) {
long value = LongUtil.toLong(successRecord.getV().getValues().toByteArray(), 0);
if (value > successfullInstanceId) {
successfullInstanceId = value;
}
}
used += recordLen;
} else {
throw new ChunkFullException();
}
} else {
throw new RuntimeException(String.format("excepted successful instanceId %s , give instanceId %s", successfullInstanceId + 1, instanceId));
}
if (logger.isDebugEnabled()) {
logger.debug("instanceId:" + instanceId + " isPlace " + (successRecord.getV().getType() == ValueType.PLACE.getValue()) + " successfullInstanceId "
+ successfullInstanceId);
}
}
示例7: InstanceSaveContext
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
public InstanceSaveContext(long instanceId, cn.com.sparkle.firefly.stablestorage.model.StoreModel.SuccessfulRecord.Builder successfulRecord,
LinkedList<AddRequestPackage> addRequestPackages) {
super();
this.instanceId = instanceId;
this.successfulRecord = successfulRecord;
this.addRequestPackages = addRequestPackages;
}
示例8: toProtobuf
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
/**
*
* @param obj
* @param protobuf
* @return
*/
public static <X extends Builder<X>> X toProtobuf(Object obj, X protobuf) {
if (null == obj || null == protobuf) {
return null;
}
List<Method> methods = WizardReflexUtil.getGetMethods(obj);
for (Method method : methods) {
setProtobuf(obj, protobuf, method);
}
return protobuf;
}
示例9: toObject
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
/**
*
* @param protobuf
* @param obj
* @return
*/
public static <X> X toObject(Builder<?> protobuf, X obj) {
if (null == protobuf || null == obj) {
return null;
}
Set<FieldDescriptor> fieldSet = protobuf.getAllFields().keySet();
for (FieldDescriptor field : fieldSet) {
setObject(protobuf, obj, field);
}
return obj;
}
示例10: newInstance
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
/** @return a new message builder for this messageId, or null if the messageId is unknown */
public Builder<?> newInstance(byte messageId);
示例11: newInstance
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder<?> newInstance(byte messageId) {
throw new UnsupportedOperationException();
}
示例12: newBuilder
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder newBuilder() {
return ExampleHttpFileFragmentProto.newBuilder();
}
示例13: newBuilder
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder newBuilder() {
return FileFragmentProto.newBuilder();
}
示例14: newBuilder
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder newBuilder() {
return JdbcFragmentProto.newBuilder();
}
示例15: newBuilder
import com.google.protobuf.GeneratedMessage.Builder; //导入依赖的package包/类
@Override
public Builder newBuilder() {
return KafkaFragmentProto.newBuilder();
}