com.google.protobuf.Message.writeDelimitedTo()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中com.google.protobuf.Message.writeDelimitedTo()方法的一些代码示例,展示了Message.writeDelimitedTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.writeDelimitedTo()方法的具体详情如下:
包路径:com.google.protobuf.Message
类名称:Message
方法名:writeDelimitedTo

Message.writeDelimitedTo介绍

暂无

代码示例

代码示例来源:origin: twitter/elephant-bird

@Override
public void serialize(Message message) throws IOException {
 message.writeDelimitedTo(out);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public void writeTo(ResponseBuffer out) throws IOException {
 requestHeader.writeDelimitedTo(out);
 if (payload != null) {
  payload.writeDelimitedTo(out);
 }
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Streams multiple messages to {@code output}. Reading the messages back requires to
 * call methods {@code readStream(...)}.
 * <p>
 * See https://developers.google.com/protocol-buffers/docs/techniques#streaming
 * </p>
 */
public static <MSG extends Message> void writeStream(Iterable<MSG> messages, OutputStream output) {
 try {
  for (Message message : messages) {
   message.writeDelimitedTo(output);
  }
 } catch (Exception e) {
  throw ContextException.of("Unable to write messages", e);
 }
}

代码示例来源:origin: spring-projects/spring-framework

private DataBuffer encodeMessage(Message message, DataBufferFactory bufferFactory, boolean streaming) {
  DataBuffer buffer = bufferFactory.allocateBuffer();
  OutputStream outputStream = buffer.asOutputStream();
  try {
    if (streaming) {
      message.writeDelimitedTo(outputStream);
    }
    else {
      message.writeTo(outputStream);
    }
    return buffer;
  }
  catch (IOException ex) {
    throw new IllegalStateException("Unexpected I/O error while writing to data buffer", ex);
  }
}

代码示例来源:origin: org.springframework/spring-web

private DataBuffer encodeMessage(Message message, DataBufferFactory bufferFactory, boolean streaming) {
  DataBuffer buffer = bufferFactory.allocateBuffer();
  OutputStream outputStream = buffer.asOutputStream();
  try {
    if (streaming) {
      message.writeDelimitedTo(outputStream);
    }
    else {
      message.writeTo(outputStream);
    }
    return buffer;
  }
  catch (IOException ex) {
    throw new IllegalStateException("Unexpected I/O error while writing to data buffer", ex);
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
void writeTo(ResponseBuffer out) throws IOException {
 int length = message.getSerializedSize();
 length += CodedOutputStream.computeRawVarint32Size(length);
 out.ensureCapacity(length);
 message.writeDelimitedTo(out);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

((Message)instance).writeDelimitedTo(
   DataOutputOutputStream.constructOutputStream(out));
} else {

代码示例来源:origin: opensourceBIM/BIMserver

public Message callBlockingMethod(MethodDescriptorContainer methodDescriptor, Message request) throws ServiceException {
  try {
    dataOutputStream.writeUTF(methodDescriptor.getServiceDescriptorContainer().getName());
    dataOutputStream.writeUTF(methodDescriptor.getName());
    dataOutputStream.writeUTF(tokenHolder.getToken() == null ? "" : tokenHolder.getToken());
    request.writeDelimitedTo(dataOutputStream);
    dataOutputStream.flush();
    DynamicMessage response = DynamicMessage.getDefaultInstance(methodDescriptor.getOutputDescriptor());
    Builder responseBuilder = response.newBuilderForType();
    responseBuilder.mergeDelimitedFrom(inputStream);
    return responseBuilder.build();
  } catch (IOException e) {
    LOGGER.error("", e);
  }
  return null;
}

代码示例来源:origin: opensourceBIM/BIMserver

DynamicMessage request = newBuilder.build();
  Message response = reflectiveRpcChannel.callBlockingMethod(methodDescriptorContainer, request);
  response.writeDelimitedTo(socket.getOutputStream());
} catch (ServiceNotFoundException e) {

代码示例来源:origin: opensourceBIM/BIMserver

requestBuilder.mergeDelimitedFrom(dataInputStream);
Message response = reflectiveRpcChannel.callBlockingMethod(pbMethod, requestBuilder.build());
response.writeDelimitedTo(outputStream);
outputStream.flush();

代码示例来源:origin: SonarSource/sonarlint-core

public static <T extends Message> void writeMessage(OutputStream output, T message) {
  try {
   message.writeDelimitedTo(output);
  } catch (IOException e) {
   throw new IllegalStateException("failed to write message: " + message, e);
  }
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
public void write(DataOutput out) throws IOException {
 OutputStream os = DataOutputOutputStream.constructOutputStream(out);
 
 ((Message)requestHeader).writeDelimitedTo(os);
 theRequest.writeDelimitedTo(os);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
public void write(DataOutput out) throws IOException {
 OutputStream os = DataOutputOutputStream.constructOutputStream(out);
 
 ((Message)requestHeader).writeDelimitedTo(os);
 theRequest.writeDelimitedTo(os);
}

代码示例来源:origin: alibaba/wasp

/**
 * @param m
 *          Message to get delimited pb serialization of (with pb magic
 *          prefix)
 */
public static byte[] toDelimitedByteArray(final Message m) throws IOException {
 // Allocate arbitrary big size so we avoid resizing.
 ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
 m.writeDelimitedTo(baos);
 baos.close();
 return baos.toByteArray();
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-client

private static void send(final DataOutputStream out, final Op opcode,
  final Message proto) throws IOException {
 LOG.trace("Sending DataTransferOp {}: {}",
   proto.getClass().getSimpleName(), proto);
 op(out, opcode);
 proto.writeDelimitedTo(out);
 out.flush();
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
public void write(DataOutput out) throws IOException {
 OutputStream os = DataOutputOutputStream.constructOutputStream(out);
 theResponse.writeDelimitedTo(os);   
}

代码示例来源:origin: com.truward.brikar.protobuf/spring-protobuf-http-bin

@Override
protected void writeInternal(Object o, HttpOutputMessage httpOutputMessage) throws IOException, HttpMessageNotWritableException {
 // Use writeDelimited to avoid empty request/response bodies as Spring 4.x does not work with them,
 // it's a real shame we have to do this, but there is simply no other choice without significant complication of
 // the rest of the code. The reason why it is done here is because Spring became more strict about parsing
 // request body (and response body as well) and what worked before simply doesn't work anymore.
 final Message message = (Message) o;
 message.writeDelimitedTo(httpOutputMessage.getBody());
}

代码示例来源:origin: io.hops/hadoop-common

@Override
public void writeTo(ResponseBuffer out) throws IOException {
 requestHeader.writeDelimitedTo(out);
 if (payload != null) {
  payload.writeDelimitedTo(out);
 }
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-extensions-protobuf

@Override
public void encode(T value, OutputStream outStream, Context context) throws IOException {
 if (value == null) {
  throw new CoderException("cannot encode a null " + protoMessageClass.getSimpleName());
 }
 if (context.isWholeStream) {
  value.writeTo(outStream);
 } else {
  value.writeDelimitedTo(outStream);
 }
}

代码示例来源:origin: io.hops/hadoop-common

@Override
void writeTo(ResponseBuffer out) throws IOException {
 int length = message.getSerializedSize();
 length += CodedOutputStream.computeRawVarint32Size(length);
 out.ensureCapacity(length);
 message.writeDelimitedTo(out);
}

相关文章