Package com.google.protobuf

Examples of com.google.protobuf.Message.writeTo()


      benchmark("Serialize to byte array", inputData.length, new Action() {
        public void execute() { sampleMessage.toByteArray(); }
      });
      benchmark("Serialize to memory stream", inputData.length, new Action() {
        public void execute() throws IOException {
          sampleMessage.writeTo(new ByteArrayOutputStream());
        }
      });
      if (devNull != null) {
        benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
View Full Code Here


        }
      });
      if (devNull != null) {
        benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(devNull);
          }
        });
        benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(reuseDevNull);
View Full Code Here

            sampleMessage.writeTo(devNull);
          }
        });
        benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(reuseDevNull);
            reuseDevNull.flush()// force the write to the OutputStream
          }
        });
      }
      benchmark("Deserialize from byte string", inputData.length, new Action() {
View Full Code Here

            sampleMessage.writeTo(devNull);
          }
        });
        benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(reuseDevNull);
            reuseDevNull.flush()// force the write to the OutputStream
          }
        });
      }
      benchmark("Deserialize from byte string", inputData.length, new Action() {
View Full Code Here

      benchmark("Serialize to byte array", inputData.length, new Action() {
        public void execute() { sampleMessage.toByteArray(); }
      });
      benchmark("Serialize to memory stream", inputData.length, new Action() {
        public void execute() throws IOException {
          sampleMessage.writeTo(new ByteArrayOutputStream());
        }
      });
      if (devNull != null) {
        benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
View Full Code Here

        }
      });
      if (devNull != null) {
        benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(devNull);
          }
        });
        benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() {
          public void execute() throws IOException {
            sampleMessage.writeTo(reuseDevNull);
View Full Code Here

       * Instead of writing to the output Writer, we write directly to the
       * HttpServletResponse output stream. That way, we can avoid any weirdness
       * with encoding the serialized protobuf to a String.
       */
      HttpServletResponse res = ServletActionContext.getResponse();
      message.writeTo(res.getOutputStream());
    } else {
      stream.write(response.getText());
    }
    return null;
  }
View Full Code Here

      throws IOException {
    TupleEntry tupleEntry = sinkCall.getOutgoingEntry();

    Message message = (Message)tupleEntry.getObject(fieldName);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    message.writeTo(baos);
    // TODO: cache this BytesWritable
    BytesWritable outputWritable = new BytesWritable(baos.toByteArray());

    sinkCall.getOutput().collect(NullWritable.get(), outputWritable);
  }
View Full Code Here

                return;
            }
            Message data = savingPledge ? pledge.getData() : project.getProto();
            log.info("Saving {} data to {}", pledge != null ? "pledge" : "project", file);
            try (OutputStream outputStream = new FileOutputStream(file)) {
                data.writeTo(outputStream);
                if (pledge != null)
                    pledge.commit(true);
                overlayUI.done();   // Only if successful.
            } catch (IOException e) {
                GuiUtils.informationalAlert("Failed to save file", e.getLocalizedMessage());
View Full Code Here

    Message block = SerializedBlock
        .newInstance(innerClass_.getCanonicalName(),protoBlobs_)
        .getMessage();
    protoBlobs_ = new ArrayList<ByteString>(numRecordsPerBlock_);
    writeRawLittleEndian32(block.getSerializedSize());
    block.writeTo(out_);
  }

  private void writeRawLittleEndian32(int size) throws IOException {
     out_.write((size) & 0xFF);
     out_.write((size >> 8) & 0xFF);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.