@Override
 public void toData(DataOutput out) throws IOException {
   out.writeInt(this.prId);
   out.writeByte(this.scope.ordinal);
   InternalDataSerializer.invokeToData(this.pAttrs, out);
   out.writeBoolean(this.isDestroying);
   out.writeBoolean(this.isColocationComplete);
   InternalDataSerializer.invokeToData(this.nodes, out);
   DataSerializer.writeString(this.partitionResolver, out);
   DataSerializer.writeString(this.colocatedWith, out);
   DataSerializer.writeString(this.fullPath, out);
   InternalDataSerializer.invokeToData(this.ea, out);
   InternalDataSerializer.invokeToData(this.regionIdleTimeout, out);
   InternalDataSerializer.invokeToData(this.regionTimeToLive, out);
   InternalDataSerializer.invokeToData(this.entryIdleTimeout, out);
   InternalDataSerializer.invokeToData(this.entryTimeToLive, out);
   out.writeBoolean(this.firstDataStoreCreated);
   DataSerializer.writeObject(elderFPAs, out);
   DataSerializer.writeArrayList(this.partitionListenerClassNames, out);
   if (this.gatewaySenderIds.isEmpty()) {
     DataSerializer.writeObject(null, out);
   } else {
     DataSerializer.writeObject(this.gatewaySenderIds, out);
   }
 }
 public byte[] buildContainer() throws IOException {
   DataOutput res = new DataOutput();
   BserWriter writer = new BserWriter(res);
   writer.writeInt(1, getHeader());
   writer.writeBytes(2, toByteArray());
   return res.toByteArray();
 }
  /**
   * Serializes a long to a binary stream with zero-compressed encoding. For -112 <= i <= 127, only
   * one byte is used with the actual value. For other values of i, the first byte value indicates
   * whether the long is positive or negative, and the number of bytes that follow. If the first
   * byte value v is between -113 and -120, the following long is positive, with number of bytes
   * that follow are -(v+112). If the first byte value v is between -121 and -128, the following
   * long is negative, with number of bytes that follow are -(v+120). Bytes are stored in the
   * high-non-zero-byte-first order.
   *
   * @param stream Binary output stream
   * @param i Long to be serialized
   * @throws java.io.IOException
   */
  public static void writeVLong(DataOutput stream, long i) throws IOException {
    if (i >= -112 && i <= 127) {
      stream.writeByte((byte) i);
      return;
    }

    int len = -112;
    if (i < 0) {
      i ^= -1L; // take one's complement'
      len = -120;
    }

    long tmp = i;
    while (tmp != 0) {
      tmp = tmp >> 8;
      len--;
    }

    stream.writeByte((byte) len);

    len = (len < -120) ? -(len + 120) : -(len + 112);

    for (int idx = len; idx != 0; idx--) {
      int shiftbits = (idx - 1) * 8;
      long mask = 0xFFL << shiftbits;
      stream.writeByte((byte) ((i & mask) >> shiftbits));
    }
  }
Exemple #4
0
  public void serialize(final DataOutput output) {
    try {
      output.writeDouble(maxError);
      output.writeDouble(alpha);
      output.writeLong(landmarkInSeconds);
      output.writeLong(min);
      output.writeLong(max);
      output.writeInt(totalNodeCount);

      postOrderTraversal(
          root,
          new Callback() {
            @Override
            public boolean process(Node node) {
              try {
                serializeNode(output, node);
              } catch (IOException e) {
                Throwables.propagate(e);
              }
              return true;
            }
          });
    } catch (IOException e) {
      Throwables.propagate(e);
    }
  }
Exemple #5
0
 void write(DataOutput out) throws IOException {
   out.writeShort(getStartPc());
   out.writeShort(getLength());
   out.writeShort(getNameIndex());
   out.writeShort(getTypeIndex());
   out.writeShort(getLocal());
 }
 @Override
 public void toData(DataOutput out) throws IOException {
   super.toData(out);
   out.writeByte(this.attributeCode);
   out.writeInt(this.newValue);
   out.writeInt(this.cacheId);
 }
 public void serialize(TreeRequest request, DataOutput dos, int version) throws IOException {
   dos.writeUTF(request.sessionid);
   CompactEndpointSerializationHelper.serialize(request.endpoint, dos);
   dos.writeUTF(request.cf.left);
   dos.writeUTF(request.cf.right);
   if (version > MessagingService.VERSION_07)
     AbstractBounds.serializer().serialize(request.range, dos, version);
 }
Exemple #8
0
 // Used for internal Hadoop purposes.
 // Describes how to write this node across a network
 public void write(DataOutput out) throws IOException {
   out.writeLong(nodeid);
   out.writeDouble(pageRank);
   for (long n : outgoing) {
     out.writeLong(n);
   }
   out.writeLong(-1);
 }
 public void serialize(IndexScanCommand o, DataOutput out, int version) throws IOException {
   out.writeUTF(o.keyspace);
   out.writeUTF(o.column_family);
   TSerializer ser = new TSerializer(new TBinaryProtocol.Factory());
   FBUtilities.serialize(ser, o.index_clause, out);
   FBUtilities.serialize(ser, o.predicate, out);
   AbstractBounds.serializer().serialize(o.range, out, version);
 }
  void write(DataOutput dos) throws IOException {
    if (list.size() > 0) type = list.get(0).getId();
    else type = 1;

    dos.writeByte(type);
    dos.writeInt(list.size());
    for (int i = 0; i < list.size(); i++) list.get(i).write(dos);
  }
 public void serialize(ReadResponse response, DataOutput dos, int version) throws IOException {
   dos.writeInt(response.isDigestQuery() ? response.digest().remaining() : 0);
   ByteBuffer buffer =
       response.isDigestQuery() ? response.digest() : ByteBufferUtil.EMPTY_BYTE_BUFFER;
   ByteBufferUtil.write(buffer, dos);
   dos.writeBoolean(response.isDigestQuery());
   if (!response.isDigestQuery()) Row.serializer.serialize(response.row(), dos, version);
 }
 public void write(DataOutput out) throws IOException {
   out.write(UNION_TYPE);
   out.writeUTF(name);
   out.writeInt(unionTypes.size());
   for (InferredType it : unionTypes) {
     it.write(out);
   }
 }
 public void write(DataOutput out) throws IOException {
   out.write(STRUCT_TYPE);
   out.writeUTF(name);
   out.writeInt(structTypes.size());
   for (InferredType it : structTypes) {
     it.write(out);
   }
 }
 @Test
 public void testLimitsBool() throws Exception {
   DataOutput dataOutput = new DataOutput();
   BserWriter writer = new BserWriter(dataOutput);
   writer.writeBool(32, true);
   writer.writeBytes(33, new byte[26]);
   byte[] data = dataOutput.toByteArray();
   BserParser.deserialize(new DataInput(data));
 }
  public void writeObject(DataOutput out) throws IOException {
    super.writeObject(out);
    Vector3f dir = new Vector3f();
    ((SpotLight) node).getDirection(dir);
    control.writeVector3f(out, dir);

    out.writeFloat(((SpotLight) node).getSpreadAngle());
    out.writeFloat(((SpotLight) node).getConcentration());
  }
Exemple #16
0
  public void write(DataOutput out) throws InvalidByteCodeException, IOException {

    out.writeShort(attributeNameIndex);
    out.writeInt(getAttributeLength());
    if (getClass().equals(AttributeInfo.class)) {
      out.write(info);
      if (debug) debug("wrote " + getDebugMessage());
    }
  }
 ///////////////////////////////////////////
 // Writable
 ///////////////////////////////////////////
 public void write(DataOutput out) throws IOException {
   blockToken.write(out);
   out.writeBoolean(corrupt);
   out.writeLong(offset);
   b.write(out);
   out.writeInt(locs.length);
   for (int i = 0; i < locs.length; i++) {
     locs[i].write(out);
   }
 }
Exemple #18
0
  public void writeObject(DataOutput out) throws IOException {

    super.writeObject(out);

    control.writeBounds(out, ((Node) node).getBounds());

    out.writeBoolean(((Node) node).getPickable());
    out.writeBoolean(((Node) node).getCollidable());
    out.writeBoolean(((Node) node).getBoundsAutoCompute());
  }
Exemple #19
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeInt(status);
   Bits.writeString(classname, out);
   Bits.writeString(name, out);
   out.writeLong(start_time);
   out.writeLong(stop_time);
   Bits.writeString(failure_type, out);
   Bits.writeString(failure_msg, out);
   Bits.writeString(stack_trace, out);
 }
Exemple #20
0
 /*
  * Write a String array as a Nework Int N, followed by Int N Byte Array of
  * compressed Strings. Handles also null arrays and null values.
  * Could be generalised using introspection.
  *
  */
 public static void writeCompressedStringArray(DataOutput out, String[] s) throws IOException {
   if (s == null) {
     out.writeInt(-1);
     return;
   }
   out.writeInt(s.length);
   for (int i = 0; i < s.length; i++) {
     writeCompressedString(out, s[i]);
   }
 }
Exemple #21
0
 /*
  *
  * Write a String as a Network Int n, followed by n Bytes
  * Alternative to 16 bit read/writeUTF.
  * Encoding standard is... ?
  *
  */
 public static void writeString(DataOutput out, String s) throws IOException {
   if (s != null) {
     byte[] buffer = s.getBytes("UTF-8");
     int len = buffer.length;
     out.writeInt(len);
     out.write(buffer, 0, len);
   } else {
     out.writeInt(-1);
   }
 }
 public byte[] toByteArray() {
   DataOutput outputStream = new DataOutput();
   BserWriter writer = new BserWriter(outputStream);
   try {
     serialize(writer);
   } catch (IOException e) {
     throw new RuntimeException("Unexpected IO exception");
   }
   return outputStream.toByteArray();
 }
Exemple #23
0
  public final void write(DataOutput out) throws IOException {
    Text.writeString(out, id); // write url

    out.writeInt(content.length); // write content
    out.write(content);

    Text.writeString(out, contentType); // write contentType

    metadata.write(out); // write metadata
  }
 /**
  * {@inheritDoc}
  *
  * @see Writable#write(DataOutput)
  */
 public void write(DataOutput out) throws IOException {
   BSONEncoder enc = new BSONEncoder();
   BasicOutputBuffer buf = new BasicOutputBuffer();
   enc.set(buf);
   enc.putObject(_doc);
   enc.done();
   out.writeInt(buf.size());
   // For better performance we can copy BasicOutputBuffer.pipe(OutputStream)
   // to have a method signature that works with DataOutput
   out.write(buf.toByteArray());
 }
 @Override
 public void write(DataOutput out) throws IOException {
   schema.write(out);
   out.writeInt(slots.size());
   for (List<KeyRange> orclause : slots) {
     out.writeInt(orclause.size());
     for (KeyRange range : orclause) {
       range.write(out);
     }
   }
 }
 @Override
 public void serialize(DataOutput dataOutput, GeobufFeature geobufFeature) throws IOException {
   GeobufEncoder enc = getEncoder();
   // This could be more efficient, we're wrapping a single feature in a feature collection. But
   // that way the key/value
   // serialization all works.
   Geobuf.Data feat = enc.makeFeatureCollection(Arrays.asList(geobufFeature));
   byte[] data = feat.toByteArray();
   dataOutput.writeInt(data.length);
   dataOutput.write(data);
 }
  /*
   * NOTE:  This implementation assumes a maximum of 64 capability
   * bits per node class.  If this changes in the future, this
   * implementation will need to be updated.
   */
  private void writeCapabilities(DataOutput out) throws IOException {
    long capabilities = 0;
    long frequentCapabilities = 0;

    for (int i = 0; i < 64; i++) {
      if (node.getCapability(i)) capabilities |= (1L << i);
      if (!(node.getCapabilityIsFrequent(i))) frequentCapabilities |= (1L << i);
    }
    out.writeLong(capabilities);
    out.writeLong(frequentCapabilities);
  }
 @SuppressWarnings("deprecation")
 public void write(DataOutput out) throws IOException {
   out.writeLong(rpcVersion);
   UTF8.writeString(out, declaringClassProtocolName);
   UTF8.writeString(out, methodName);
   out.writeLong(clientVersion);
   out.writeInt(clientMethodsHash);
   out.writeInt(parameterClasses.length);
   for (int i = 0; i < parameterClasses.length; i++) {
     ObjectWritable.writeObject(out, parameters[i], parameterClasses[i], conf, true);
   }
 }
 @Override
 public void write(DataOutput out) throws IOException {
   out.writeInt(values.length); // write values
   for (int i = 0; i < values.length; i++) {
     out.writeInt(values[i].length);
   }
   for (int i = 0; i < values.length; i++) {
     for (int j = 0; j < values[i].length; j++) {
       values[i][j].write(out);
     }
   }
 }
 public static void writeLongString(DataOutput dos, String str) throws IOException {
   int chunk = 1000;
   int count = str.length() / chunk;
   int remaining = str.length() - (count * chunk);
   dos.writeInt(count + ((remaining > 0) ? 1 : 0));
   for (int i = 0; i < count; i++) {
     dos.writeUTF(str.substring(i * chunk, (i + 1) * chunk));
   }
   if (remaining > 0) {
     dos.writeUTF(str.substring(count * chunk));
   }
 }