@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);
   }
 }
Exemple #2
0
 void write(DataOutput out) throws IOException {
   out.writeShort(getStartPc());
   out.writeShort(getLength());
   out.writeShort(getNameIndex());
   out.writeShort(getTypeIndex());
   out.writeShort(getLocal());
 }
Exemple #3
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 #4
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 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);
   }
 }
 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);
 }
  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 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);
 }
 @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);
 }
 /**
  * {@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());
 }
 public void write(DataOutput out) throws IOException {
   out.write(BASE_TYPE);
   out.writeUTF(name);
   out.writeInt(sampleStrs.size());
   for (int i = 0; i < sampleStrs.size(); i++) {
     UTF8.writeString(out, sampleStrs.get(i));
   }
   out.writeInt(tokenClassIdentifier);
   out.writeBoolean(tokenParameter != null);
   if (tokenParameter != null) {
     UTF8.writeString(out, tokenParameter);
   }
 }
Exemple #13
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type);
   boolean isMergeView = view != null && view instanceof MergeView;
   out.writeBoolean(isMergeView);
   Util.writeStreamable(view, out);
   Util.writeAddress(mbr, out);
   Util.writeAddresses(mbrs, out);
   Util.writeStreamable(join_rsp, out);
   Util.writeStreamable(my_digest, out);
   Util.writeStreamable(merge_id, out);
   out.writeBoolean(merge_rejected);
   out.writeBoolean(useFlushIfPresent);
 }
  public void writeDataTo(DataOutput dout) throws IOException {
    int size = mEntries.size();
    dout.writeShort(size);
    for (int i = 0; i < size; i++) {
      Entry entry = (Entry) mEntries.get(i);

      int start_pc = entry.mStart.getLocation();

      check("line number table entry start PC", start_pc);

      dout.writeShort(start_pc);
      dout.writeShort(entry.mLineNumber);
    }
  }
Exemple #15
0
  private void serializeNode(DataOutput output, Node node) throws IOException {
    int flags = 0;
    if (node.left != null) {
      flags |= Flags.HAS_LEFT;
    }
    if (node.right != null) {
      flags |= Flags.HAS_RIGHT;
    }

    output.writeByte(flags);
    output.writeByte(node.level);
    output.writeLong(node.bits);
    output.writeDouble(node.weightedCount);
  }
 public void writeDataTo(DataOutput dout) throws IOException {
   int size = mInnerClasses.size();
   dout.writeShort(size);
   for (int i = 0; i < size; i++) {
     ((Info) mInnerClasses.get(i)).writeTo(dout);
   }
 }
Exemple #17
0
  /** Write a {@link Writable}, {@link String}, primitive type, or an array of the preceding. */
  public static void writeObject(
      DataOutput out, Object instance, Class declaredClass, Configuration conf) throws IOException {

    if (instance == null) { // null
      instance = new NullInstance(declaredClass, conf);
      declaredClass = Writable.class;
    }

    UTF8.writeString(out, declaredClass.getName()); // always write declared

    if (declaredClass.isArray()) { // array
      int length = Array.getLength(instance);
      out.writeInt(length);
      for (int i = 0; i < length; i++) {
        writeObject(out, Array.get(instance, i), declaredClass.getComponentType(), conf);
      }

    } else if (declaredClass == String.class) { // String
      UTF8.writeString(out, (String) instance);

    } else if (declaredClass.isPrimitive()) { // primitive type

      if (declaredClass == Boolean.TYPE) { // boolean
        out.writeBoolean(((Boolean) instance).booleanValue());
      } else if (declaredClass == Character.TYPE) { // char
        out.writeChar(((Character) instance).charValue());
      } else if (declaredClass == Byte.TYPE) { // byte
        out.writeByte(((Byte) instance).byteValue());
      } else if (declaredClass == Short.TYPE) { // short
        out.writeShort(((Short) instance).shortValue());
      } else if (declaredClass == Integer.TYPE) { // int
        out.writeInt(((Integer) instance).intValue());
      } else if (declaredClass == Long.TYPE) { // long
        out.writeLong(((Long) instance).longValue());
      } else if (declaredClass == Float.TYPE) { // float
        out.writeFloat(((Float) instance).floatValue());
      } else if (declaredClass == Double.TYPE) { // double
        out.writeDouble(((Double) instance).doubleValue());
      } else if (declaredClass == Void.TYPE) { // void
      } else {
        throw new IllegalArgumentException("Not a primitive: " + declaredClass);
      }
    } else if (declaredClass.isEnum()) { // enum
      UTF8.writeString(out, ((Enum) instance).name());
    } else if (Writable.class.isAssignableFrom(declaredClass)) { // Writable
      UTF8.writeString(out, instance.getClass().getName());
      ((Writable) instance).write(out);

    } else {
      throw new IOException("Can't write: " + instance + " as " + declaredClass);
    }
  }
 public void write(DataOutput out) throws IOException {
   out.writeBoolean(isNode);
   if (node != null) {
     node.write(out);
   } else {
     contribution.write(out);
   }
 }
Exemple #19
0
  @Override
  public byte[] getFollowRequests(UserPublicKey owner) {
    byte[] dummy = null;
    FollowRequestData request = new FollowRequestData(owner, dummy);
    RowData[] requests = request.select();
    if (requests == null) return new byte[4];

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    DataOutput dout = new DataOutputStream(bout);
    try {
      dout.writeInt(requests.length);
      for (RowData req : requests) Serialize.serialize(req.data, dout);
      return bout.toByteArray();
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
Exemple #20
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type.ordinal());
   // We can't use Util.writeObject since it's size is limited to 2^15-1
   try {
     if (object instanceof Streamable) {
       out.writeShort(-1);
       Util.writeGenericStreamable((Streamable) object, out);
     } else {
       byte[] bytes = Util.objectToByteBuffer(object);
       out.writeInt(bytes.length);
       out.write(bytes);
     }
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     throw new IOException("Exception encountered while serializing execution request", e);
   }
   out.writeLong(request);
 }
Exemple #21
0
 @Override
 public void write(DataOutput output) throws IOException {
   Bytes.writeByteArray(output, name.getBytes());
   WritableUtils.writeVInt(output, type.ordinal());
   WritableUtils.writeVLong(output, sequenceNumber);
   output.writeLong(timeStamp);
   Bytes.writeByteArray(
       output, pkName == null ? ByteUtil.EMPTY_BYTE_ARRAY : Bytes.toBytes(pkName));
   WritableUtils.writeVInt(output, allColumns.size());
   for (int i = 0; i < allColumns.size(); i++) {
     PColumn column = allColumns.get(i);
     column.write(output);
   }
   stats.write(output);
 }
    public void writeTo(DataOutput dout) throws IOException {
      if (mInner == null) {
        dout.writeShort(0);
      } else {
        dout.writeShort(mInner.getIndex());
      }

      if (mOuter == null) {
        dout.writeShort(0);
      } else {
        dout.writeShort(mOuter.getIndex());
      }

      if (mName == null) {
        dout.writeShort(0);
      } else {
        dout.writeShort(mName.getIndex());
      }

      dout.writeShort(mModifier);
    }
 public void writeGenotype(final EvolutionState state, final DataOutput dataOutput)
     throws IOException {
   dataOutput.writeInt(genome.length);
   for (int x = 0; x < genome.length; x++)
     dataOutput.writeBoolean(genome[x]); // inefficient: booleans are written out as bytes
 }
Exemple #24
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type);
   out.writeShort(version.length);
   out.write(version);
 }
  public void write(DataOutput out) throws IOException {
    super.write(out);

    out.writeFloat(score);
  }
Exemple #26
0
 @Override
 public void writeTo(DataOutput out) throws Exception {
   super.writeTo(out);
   out.writeLong(threadId);
 }
Exemple #27
0
 /**
  * Writes a subpopulation in binary form, in a format readable by
  * readSubpopulation(EvolutionState, DataInput).
  */
 public void writeSubpopulation(final EvolutionState state, final DataOutput dataOutput)
     throws IOException {
   dataOutput.writeInt(individuals.length);
   for (int i = 0; i < individuals.length; i++) individuals[i].writeIndividual(state, dataOutput);
 }
 public void save(DataOutput s, Set<String> set) throws IOException {
   s.writeInt(set.size());
   for (String each : set) {
     s.writeUTF(each);
   }
 }
 void write(DataOutput dos) throws IOException {
   for (Tag tag : tags.values()) {
     Tag.writeNamedTag(tag, dos);
   }
   dos.writeByte(Tag.TAG_End);
 }
Exemple #30
0
  private void writeRecord(DataOutput dataOutput, Object[] objectArray) throws IOException {

    dataOutput.write((byte) ' ');
    for (int j = 0; j < this.header.fieldArray.length; j++) {
      /* iterate throught fields */

      switch (this.header.fieldArray[j].getDataType()) {
        case 'C':
          if (objectArray[j] != null) {

            String str_value = objectArray[j].toString();
            dataOutput.write(
                Utils.textPadding(
                    str_value, characterSetName, this.header.fieldArray[j].getFieldLength()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    "", this.characterSetName, this.header.fieldArray[j].getFieldLength()));
          }

          break;

        case 'D':
          if (objectArray[j] != null) {

            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime((Date) objectArray[j]);
            dataOutput.write(String.valueOf(calendar.get(Calendar.YEAR)).getBytes());
            dataOutput.write(
                Utils.textPadding(
                    String.valueOf(calendar.get(Calendar.MONTH) + 1),
                    this.characterSetName,
                    2,
                    Utils.ALIGN_RIGHT,
                    (byte) '0'));
            dataOutput.write(
                Utils.textPadding(
                    String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)),
                    this.characterSetName,
                    2,
                    Utils.ALIGN_RIGHT,
                    (byte) '0'));
          } else {

            dataOutput.write("        ".getBytes());
          }

          break;

        case 'F':
          if (objectArray[j] != null) {

            dataOutput.write(
                Utils.doubleFormating(
                    (Double) objectArray[j],
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    this.header.fieldArray[j].getDecimalCount()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    " ",
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    Utils.ALIGN_RIGHT));
          }

          break;

        case 'N':
          if (objectArray[j] != null) {

            dataOutput.write(
                Utils.doubleFormating(
                    (Double) objectArray[j],
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    this.header.fieldArray[j].getDecimalCount()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    " ",
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    Utils.ALIGN_RIGHT));
          }

          break;
        case 'L':
          if (objectArray[j] != null) {

            if ((Boolean) objectArray[j] == Boolean.TRUE) {

              dataOutput.write((byte) 'T');
            } else {

              dataOutput.write((byte) 'F');
            }
          } else {

            dataOutput.write((byte) '?');
          }

          break;

        case 'M':
          break;

        default:
          throw new DBFException("Unknown field type " + this.header.fieldArray[j].getDataType());
      }
    } /* iterating through the fields */
  }