예제 #1
0
 /**
  * {@inheritDoc}
  *
  * @see Writable#readFields(DataInput)
  */
 public void readFields(DataInput in) throws IOException {
   BSONDecoder dec = new BSONDecoder();
   BSONCallback cb = new BasicBSONCallback();
   // Read the BSON length from the start of the record
   int dataLen = in.readInt();
   byte[] buf = new byte[dataLen];
   in.readFully(buf);
   dec.decode(buf, cb);
   _doc = (BSONObject) cb.get();
   log.info("Decoded a BSON Object: " + _doc);
 }
예제 #2
0
    @Override
    public GeobufFeature deserialize(DataInput dataInput, int i) throws IOException {
      int len = dataInput.readInt();
      byte[] feat = new byte[len];
      dataInput.readFully(feat);
      Geobuf.Data data = Geobuf.Data.parseFrom(feat);

      return new GeobufFeature(
          data.getFeatureCollection().getFeatures(0),
          data.getKeysList(),
          Math.pow(10, data.getPrecision()));
    }
예제 #3
0
    public void readFrom(DataInput in) throws Exception {
      type = Type.values()[in.readByte()];
      // We can't use Util.readObject since it's size is limited to 2^15-1
      try {
        short first = in.readShort();
        if (first == -1) {
          object = Util.readGenericStreamable(in);
        } else {
          ByteBuffer bb = ByteBuffer.allocate(4);
          bb.putShort(first);
          bb.putShort(in.readShort());

          int size = bb.getInt(0);
          byte[] bytes = new byte[size];
          in.readFully(bytes, 0, size);
          object = Util.objectFromByteBuffer(bytes);
        }
      } catch (IOException e) {
        throw e;
      } catch (Exception e) {
        throw new IOException("Exception encountered while serializing execution request", e);
      }
      request = in.readLong();
    }
예제 #4
0
파일: ENCRYPT.java 프로젝트: x97mdr/JGroups
 public void readFrom(DataInput in) throws Exception {
   type = in.readByte();
   short len = in.readShort();
   version = new byte[len];
   in.readFully(version);
 }