Package com.google.protobuf

Examples of com.google.protobuf.CodedInputStream$SkippedDataSink


  }

  @Override
  public int skip(PositionedByteRange src) {
    CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
    CodedInputStream is = inputStreamFromByteRange(src);
    try {
      builder.mergeFrom(is);
      int consumed = is.getTotalBytesRead();
      src.setPosition(src.getPosition() + consumed);
      return consumed;
    } catch (IOException e) {
      throw new RuntimeException("Error while skipping type.", e);
    }
View Full Code Here


  }

  @Override
  public CellProtos.Cell decode(PositionedByteRange src) {
    CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
    CodedInputStream is = inputStreamFromByteRange(src);
    try {
      CellProtos.Cell ret = builder.mergeFrom(is).build();
      src.setPosition(src.getPosition() + is.getTotalBytesRead());
      return ret;
    } catch (IOException e) {
      throw new RuntimeException("Error while decoding type.", e);
    }
  }
View Full Code Here

    protected void processRequest(byte[] buf) throws IOException, InterruptedException {
      long totalRequestSize = buf.length;
      int offset = 0;
      // Here we read in the header.  We avoid having pb
      // do its default 4k allocation for CodedInputStream.  We force it to use backing array.
      CodedInputStream cis = CodedInputStream.newInstance(buf, offset, buf.length);
      int headerSize = cis.readRawVarint32();
      offset = cis.getTotalBytesRead();
      RequestHeader header = RequestHeader.newBuilder().mergeFrom(buf, offset, headerSize).build();
      offset += headerSize;
      int id = header.getCallId();
      if (LOG.isTraceEnabled()) {
        LOG.trace("RequestHeader " + TextFormat.shortDebugString(header) +
          " totalRequestSize: " + totalRequestSize + " bytes");
      }
      // Enforcing the call queue size, this triggers a retry in the client
      // This is a bit late to be doing this check - we have already read in the total request.
      if ((totalRequestSize + callQueueSize.get()) > maxQueueSize) {
        final Call callTooBig =
          new Call(id, this.service, null, null, null, null, this,
            responder, totalRequestSize, null);
        ByteArrayOutputStream responseBuffer = new ByteArrayOutputStream();
        setupResponse(responseBuffer, callTooBig, new CallQueueTooBigException(),
          "Call queue is full, is ipc.server.max.callqueue.size too small?");
        responder.doRespond(callTooBig);
        return;
      }
      MethodDescriptor md = null;
      Message param = null;
      CellScanner cellScanner = null;
      try {
        if (header.hasRequestParam() && header.getRequestParam()) {
          md = this.service.getDescriptorForType().findMethodByName(header.getMethodName());
          if (md == null) throw new UnsupportedOperationException(header.getMethodName());
          Builder builder = this.service.getRequestPrototype(md).newBuilderForType();
          // To read the varint, I need an inputstream; might as well be a CIS.
          cis = CodedInputStream.newInstance(buf, offset, buf.length);
          int paramSize = cis.readRawVarint32();
          offset += cis.getTotalBytesRead();
          if (builder != null) {
            param = builder.mergeFrom(buf, offset, paramSize).build();
          }
          offset += paramSize;
        }
View Full Code Here

        }
    }

    @Override
    public HistogramRollup fromByteBuffer(ByteBuffer byteBuffer) {
        CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());

        try {
            byte version = in.readRawByte();
            switch (version) {
                case Constants.VERSION_1_HISTOGRAM:
                    return deserializeV1Histogram(in);
                default:
                    throw new SerializationException("Unexpected serialization version");
View Full Code Here

        return 1 + CodedOutputStream.computeStringSizeNoTag(obj); // 1 for type
    }

    @Override
    public String fromByteBuffer(ByteBuffer byteBuffer) {
        CodedInputStream is = CodedInputStream.newInstance(byteBuffer.array());
        try {
            byte type = is.readRawByte();
            if (type == STRING) {
                return is.readString();
            } else {
                throw new IOException("Unexpected first byte. Expected '4' (string). Got '" + type + "'.");
            }
        } catch (IOException e) {
            throw new RuntimeException("IOException during deserialization", e);
View Full Code Here

            }
        }

        @Override
        public Object fromByteBuffer(ByteBuffer byteBuffer) {
            CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());
            try {
                byte version = in.readRawByte();
                if (version != VERSION_1_FULL_RES && version != VERSION_1_ROLLUP) {
                    throw new SerializationException(String.format("Unexpected serialization version: %d",
                            (int)version));
                }
                return deserializeSimpleMetric(in);
View Full Code Here

            }
        }

        @Override
        public BasicRollup fromByteBuffer(ByteBuffer byteBuffer) {
            CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());
            try {
                byte version = in.readRawByte();
                if (version != VERSION_1_FULL_RES && version != VERSION_1_ROLLUP) {
                    throw new SerializationException(String.format("Unexpected serialization version: %d",
                            (int)version));
                }
                return deserializeV1Rollup(in);
View Full Code Here

            }
        }

        @Override
        public TimerRollup fromByteBuffer(ByteBuffer byteBuffer) {
            CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());
            try {
                byte version = in.readRawByte();
                if (version != VERSION_1_TIMER)
                    throw new SerializationException(String.format("Unexpected serialization version: %d", (int)version));
                return deserializeV1Timer(in);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
View Full Code Here

            }
        }

        @Override
        public SetRollup fromByteBuffer(ByteBuffer byteBuffer) {
            CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());
            try {
                byte version = in.readRawByte();
                if (version != VERSION_1_SET_ROLLUP)
                    throw new SerializationException(String.format("Unexpected serialization version: %d", (int)version));
                return deserializeV1SetRollup(in);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
View Full Code Here

            }
        }

        @Override
        public GaugeRollup fromByteBuffer(ByteBuffer byteBuffer) {
            CodedInputStream in = CodedInputStream.newInstance(byteBuffer.array());
            try {
                byte version = in.readRawByte();
                if (version != VERSION_1_ROLLUP)
                    throw new SerializationException(String.format("Unexpected serialization version: %d", (int)version));
                return deserializeV1Gauge(in);
            } catch (Exception e) {
                throw new RuntimeException("Deserialization Failure", e);
View Full Code Here

TOP

Related Classes of com.google.protobuf.CodedInputStream$SkippedDataSink

Copyright © 2018 www.massapicom. 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.