/*
   * this.values = copy.values; this.table = copy.table; this.state = copy.state; this.freeEntries =
   * copy.freeEntries; this.distinct = copy.distinct; this.lowWaterMark = copy.lowWaterMark;
   * this.highWaterMark = copy.highWaterMark; this.minLoadFactor = copy.minLoadFactor;
   * this.maxLoadFactor = copy.maxLoadFactor;
   */
  @Override
  public void write(DataOutput out) throws IOException {
    this.trimToSize();

    WritableUtils.writeVInt(out, freeEntries);
    WritableUtils.writeVInt(out, distinct);
    WritableUtils.writeVInt(out, lowWaterMark);
    WritableUtils.writeVInt(out, highWaterMark);
    out.writeDouble(minLoadFactor);
    out.writeDouble(maxLoadFactor);

    WritableUtils.writeVInt(out, table.length);
    for (int i = 0; i < table.length; i++) {
      WritableUtils.writeVInt(out, table[i]);
    }

    WritableUtils.writeVInt(out, values.length);
    for (int i = 0; i < values.length; i++) {
      out.writeDouble(values[i]);
    }

    WritableUtils.writeVInt(out, state.length);
    for (int i = 0; i < state.length; i++) {
      out.writeByte(state[i]);
    }
  }
 @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 void a(DataOutput dataoutput) {
   dataoutput.writeInt(this.a);
   dataoutput.writeShort(this.b);
   dataoutput.writeInt(this.c);
   dataoutput.writeByte((byte) this.d);
   a(this.e, dataoutput);
 }
 @Override
 public void write(DataOutput out) throws IOException {
   out.writeInt(set.size());
   for (long l : set) {
     out.writeLong(l);
   }
 }
示例#5
1
 @Override
 protected void writeNode(DataOutput out) throws IOException {
   out.writeInt(attr);
   out.writeDouble(split);
   loChild.write(out);
   hiChild.write(out);
 }
  /**
   * See PIG-2936. The purpose of this test is to ensure that Tuples are being serialized in the
   * specific way that we expect.
   */
  @Test
  public void testTupleSerializationSpecific() throws Exception {
    byte[] flags = {
      BinInterSedes.TUPLE_0,
      BinInterSedes.TUPLE_1,
      BinInterSedes.TUPLE_2,
      BinInterSedes.TUPLE_3,
      BinInterSedes.TUPLE_4,
      BinInterSedes.TUPLE_5,
      BinInterSedes.TUPLE_6,
      BinInterSedes.TUPLE_7,
      BinInterSedes.TUPLE_8,
      BinInterSedes.TUPLE_9,
    };

    for (int i = 0; i < flags.length; i++) {
      Tuple t = mTupleFactory.newTuple(i);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      DataOutput out = new DataOutputStream(baos);
      out.writeByte(flags[i]);

      for (int j = 0; j < i; j++) {
        Integer val = Integer.valueOf(random.nextInt());
        bis.writeDatum(out, val);
        t.set(j, val);
      }

      testSerTuple(t, baos.toByteArray());
    }
  }
 @Override
 public void toData(DataOutput out) throws IOException {
   super.toData(out);
   out.writeInt(this.prId);
   out.writeInt(this.processorId);
   DataSerializer.writeObject(this.profiles, out);
 }
  void writeData(DataOutput out) throws IOException {
    out.writeInt(rowIndices.size());
    if (rowIndices.size() > 0) {
      int n = rowIndices.get(0).length;
      out.writeInt(n);

      if (this.useDictionary == true) {
        dict.write(out);
        for (int i = 0; i < rowIndices.size(); i++) {
          int[] row = rowIndices.get(i);
          for (int j = 0; j < n; j++) {
            out.writeInt(row[j]);
          }
        }

      } else {
        for (int i = 0; i < rowIndices.size(); i++) {
          int[] row = rowIndices.get(i);
          for (int j = 0; j < n; j++) {
            out.writeUTF(dict.getValueFromId(row[j]));
          }
        }
      }
    }
  }
  public void save(final DataOutput out) {
    super.save(out);
    myType.save(out);

    try {
      if (myValue instanceof String) {
        out.writeByte(STRING);
        String value = (String) myValue;
        RW.writeUTF(out, value);
      } else if (myValue instanceof Integer) {
        out.writeByte(INTEGER);
        DataInputOutputUtil.writeINT(out, ((Integer) myValue).intValue());
      } else if (myValue instanceof Long) {
        out.writeByte(LONG);
        out.writeLong(((Long) myValue).longValue());
      } else if (myValue instanceof Float) {
        out.writeByte(FLOAT);
        out.writeFloat(((Float) myValue).floatValue());
      } else if (myValue instanceof Double) {
        out.writeByte(DOUBLE);
        out.writeDouble(((Double) myValue).doubleValue());
      } else if (myValue instanceof Type) {
        out.writeByte(TYPE);
        RW.writeUTF(out, ((Type) myValue).getDescriptor());
      } else {
        out.writeByte(NONE);
      }
    } catch (IOException e) {
      throw new BuildDataCorruptedException(e);
    }
  }
示例#10
0
  public void writeObject(DataOutput out) throws IOException {
    super.writeObject(out);

    scope = new int[((Light) node).numScopes()];
    for (int i = 0; i < ((Light) node).numScopes(); i++) {
      scope[i] = control.getSymbolTable().addReference(((Light) node).getScope(i));
      ;
    }
    boundingLeaf =
        control.getSymbolTable().addReference(((Light) node).getInfluencingBoundingLeaf());

    Color3f color = new Color3f();
    ((Light) node).getColor(color);
    control.writeColor3f(out, color);

    out.writeBoolean(((Light) node).getEnable());

    out.writeInt(boundingLeaf);
    control.writeBounds(out, ((Light) node).getInfluencingBounds());

    out.writeInt(scope.length);
    for (int i = 0; i < scope.length; i++) {
      out.writeInt(scope[i]);
    }
  }
示例#11
0
 /**
  * Write a Map<String, Integer>
  *
  * @param out DataOutput
  * @param map Map to write
  * @throws IOException I/O errors
  */
 public static void writeStrIntMap(DataOutput out, Map<String, Integer> map) throws IOException {
   out.writeInt(map.size());
   for (Map.Entry<String, Integer> entry : map.entrySet()) {
     WritableUtils.writeString(out, entry.getKey());
     out.writeInt(entry.getValue());
   }
 }
示例#12
0
 @Override
 public void write(final DataOutput out) throws IOException {
   out.writeUTF(this.inputSpecID);
   Class<?> delegateClass = this.delegate.getClass();
   out.writeUTF(delegateClass.getName());
   serializeDelegate(new AdapterOutput(out), delegateClass);
 }
示例#13
0
  /** Write the actual data contents of the tag, implemented in NBT extension classes */
  void write(DataOutput output) throws IOException {
    output.writeInt(this.intArray.length);

    for (int var2 = 0; var2 < this.intArray.length; ++var2) {
      output.writeInt(this.intArray[var2]);
    }
  }
示例#14
0
 public void write(final DataOutput dataoutput) throws IOException {
   dataoutput.writeInt(fileOffset);
   dataoutput.write(attribute);
   dataoutput.write((byte) (uniqueID >> 16));
   dataoutput.write((byte) (uniqueID >> 8));
   dataoutput.write((byte) uniqueID);
 }
示例#15
0
  @Override
  public void write(DataOutput dOut) throws IOException {
    dOut.writeUTF(instanceId);

    // Hadoop Configuration has to get its act right
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    conf.writeXml(baos);
    baos.close();
    byte[] array = baos.toByteArray();
    dOut.writeInt(array.length);
    dOut.write(array);

    def.write(dOut);
    dOut.writeUTF(status.toString());
    dOut.writeInt(executionPaths.size());
    for (Map.Entry<String, NodeInstance> entry : executionPaths.entrySet()) {
      dOut.writeUTF(entry.getKey());
      dOut.writeUTF(entry.getValue().nodeName);
      dOut.writeBoolean(entry.getValue().started);
    }
    dOut.writeInt(persistentVars.size());
    for (Map.Entry<String, String> entry : persistentVars.entrySet()) {
      dOut.writeUTF(entry.getKey());
      writeStringAsBytes(entry.getValue(), dOut);
    }
  }
  private void writeSearchResults(IFrameTupleAccessor leftAccessor, int tIndex) throws Exception {
    while (cursor.hasNext()) {
      tb.reset();
      cursor.next();

      ITupleReference frameTuple = cursor.getTuple();
      for (int i = 0; i < inputRecDesc.getFields().length; i++) {
        int tupleStart = leftAccessor.getTupleStartOffset(tIndex);
        int fieldStart = leftAccessor.getFieldStartOffset(tIndex, i);
        int offset = leftAccessor.getFieldSlotsLength() + tupleStart + fieldStart;
        int len = leftAccessor.getFieldEndOffset(tIndex, i) - fieldStart;
        dos.write(leftAccessor.getBuffer().array(), offset, len);
        tb.addFieldEndOffset();
      }
      for (int i = 0; i < frameTuple.getFieldCount(); i++) {
        dos.write(
            frameTuple.getFieldData(i), frameTuple.getFieldStart(i), frameTuple.getFieldLength(i));
        tb.addFieldEndOffset();
      }

      if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
        FrameUtils.flushFrame(writeBuffer, writer);
        appender.reset(writeBuffer, true);
        if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
          throw new IllegalStateException();
        }
      }
    }
  }
示例#17
0
  /**
   * The object implements the writeTo method to save its contents by calling the methods of
   * DataOutput for its primitive values and strings or calling the writeTo method for other
   * objects.
   *
   * @param out the stream to write the object to.
   * @throws IOException Includes any I/O exceptions that may occur.
   */
  public void writeTo(DataOutput out) throws IOException {
    out.writeInt(schemaId);

    out.writeInt(ids.length);

    for (Integer id : ids) out.writeInt(id);
  }
  @Override
  public void writeObject(DataOutput out) throws IOException {
    super.writeObject(out);

    out.writeFloat(((PositionInterpolator) node).getStartPosition());
    out.writeFloat(((PositionInterpolator) node).getEndPosition());
  }
示例#19
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);
    }
  }
 protected void tightMarshalByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeInt(data.length);
     dataOut.write(data);
   }
 }
 /** Abstract. Writes the raw packet data to the data stream. */
 public void writePacketData(DataOutput par1DataOutput) throws IOException {
   par1DataOutput.writeDouble(this.xPosition);
   par1DataOutput.writeDouble(this.yPosition);
   par1DataOutput.writeDouble(this.stance);
   par1DataOutput.writeDouble(this.zPosition);
   super.writePacketData(par1DataOutput);
 }
 protected void tightMarshalByteSequence2(ByteSequence data, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeInt(data.getLength());
     dataOut.write(data.getData(), data.getOffset(), data.getLength());
   }
 }
示例#23
0
 /**
  * Serializes this object.
  *
  * @param out where to write the raw byte representation
  */
 public void write(DataOutput out) throws IOException {
   int size = size();
   out.writeInt(size);
   for (int i = 0; i < size; i++) {
     out.writeInt(get(i));
   }
 }
 @Override
 public void serialize(DataOutput out) throws IOException {
   out.write(multiplexerSessions.size());
   for (String id : multiplexerSessions) {
     out.writeUTF(id);
   }
 }
示例#25
0
 @Override
 public void write(DataOutput out) throws IOException {
   out.writeInt(VERSION);
   out.writeInt(byteSize);
   out.writeInt(hashCount);
   out.writeInt(keyCount.intValue());
 }
 @Override
 public void save(@NotNull DataOutput out, PsiJavaFileStub value) throws IOException {
   BufferExposingByteArrayOutputStream buffer = new BufferExposingByteArrayOutputStream();
   mySerializer.serialize(value, buffer);
   out.writeInt(buffer.size());
   out.write(buffer.getInternalBuffer(), 0, buffer.size());
 }
示例#27
0
  /**
   * 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));
    }
  }
 @Override
 public void write(DataOutput out) throws IOException {
   super.write(out);
   out.writeLong(myTimestamp);
   out.writeBoolean(isReadOnly);
   myContent.write(out);
 }
 @Override
 public void toData(DataOutput out) throws IOException {
   super.toData(out);
   out.writeByte(this.attributeCode);
   out.writeInt(this.newValue);
   out.writeInt(this.cacheId);
 }
 @Override
 public void write(DataOutput out) throws IOException {
   out.writeShort(vbuckets.size());
   for (Integer v : vbuckets) {
     out.writeShort(v.shortValue());
   }
 }