コード例 #1
0
ファイル: StringValue.java プロジェクト: rmetzger/flink
  public static final void writeString(CharSequence cs, DataOutput out) throws IOException {
    if (cs != null) {
      // the length we write is offset by one, because a length of zero indicates a null value
      int lenToWrite = cs.length() + 1;
      if (lenToWrite < 0) {
        throw new IllegalArgumentException("CharSequence is too long.");
      }

      // write the length, variable-length encoded
      while (lenToWrite >= HIGH_BIT) {
        out.write(lenToWrite | HIGH_BIT);
        lenToWrite >>>= 7;
      }
      out.write(lenToWrite);

      // write the char data, variable length encoded
      for (int i = 0; i < cs.length(); i++) {
        int c = cs.charAt(i);

        while (c >= HIGH_BIT) {
          out.write(c | HIGH_BIT);
          c >>>= 7;
        }
        out.write(c);
      }
    } else {
      out.write(0);
    }
  }
コード例 #2
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);
 }
コード例 #3
0
ファイル: HelloPacket.java プロジェクト: AMPBEdu/jOryx
  @Override
  public void writeToDataOutput(DataOutput write) throws IOException {
    write.writeUTF(buildVersion);
    write.writeInt(gameId);
    write.writeUTF(guid);
    write.writeUTF(password);
    write.writeUTF(secret);
    write.writeInt(keyTime);

    if (key != null) {
      write.writeShort(key.length);
      write.write(key);
    } else {
      write.writeShort(0);
    }

    if (unkStr != null) {
      byte[] buf = unkStr.getBytes("UTF-8");
      write.writeInt(buf.length);
      write.write(buf);
    } else {
      write.writeInt(0);
    }

    write.writeUTF(pk);
    write.writeUTF(Tq);
    write.writeUTF(H);
    write.writeUTF(playPlatform);
  }
コード例 #4
0
ファイル: Packet14BlockDig.java プロジェクト: CrazyDev/mc-dev
 public void a(DataOutput dataoutput) {
   dataoutput.write(this.e);
   dataoutput.writeInt(this.a);
   dataoutput.write(this.b);
   dataoutput.writeInt(this.c);
   dataoutput.write(this.face);
 }
コード例 #5
0
  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();
        }
      }
    }
  }
コード例 #6
0
 /**
  * Writes this record to a {@link DataOutput} stream. The output may, in some edge cases, be not
  * byte-for-byte identical to what was parsed from a {@link DataInput}. However it has the same
  * meaning and should not lose any information.
  *
  * @param out The output stream to which this record should be appended.
  * @throws IOException
  */
 public void write(DataOutput out) throws IOException {
   header.write(out);
   out.write(CRLF_BYTES);
   out.write(content);
   out.write(CRLF_BYTES);
   out.write(CRLF_BYTES);
 }
コード例 #7
0
  public void writePayload(DataOutput buffer) throws IOException {

    buffer.write(_protocolHeader);
    buffer.write(_protocolClass);
    buffer.write(_protocolInstance);
    buffer.write(_protocolMajor);
    buffer.write(_protocolMinor);
  }
 public void writeData(DataOutput dout) throws IOException {
   dout.writeShort(m_Reference);
   if (m_Coil) {
     dout.write(Modbus.COIL_ON_BYTES, 0, 2);
   } else {
     dout.write(Modbus.COIL_OFF_BYTES, 0, 2);
   }
 }
 public void writeData(DataOutput dout) throws IOException {
   dout.writeShort(getReference());
   if (getCoil()) {
     dout.write(Modbus.COIL_ON_BYTES, 0, 2);
   } else {
     dout.write(Modbus.COIL_OFF_BYTES, 0, 2);
   }
 } // writeData
コード例 #10
0
 @Override
 public void writeData(DataOutput writer) throws IOException {
   for (Map.Entry<String, DataTagBase> entry : dataMap.entrySet()) {
     writer.write(entry.getValue().getId());
     writer.writeChars(entry.getKey());
     entry.getValue().writeData(writer);
   }
   writer.write(0);
 }
コード例 #11
0
 public void getClosedFieldValue(ARecordType recordType, int fieldId, DataOutput dOut)
     throws IOException, AsterixException {
   if (isClosedFieldNull(recordType, fieldId)) {
     dOut.writeByte(ATypeTag.NULL.serialize());
   } else {
     dOut.write(getClosedFieldTag(recordType, fieldId));
     dOut.write(
         bytes,
         getClosedFieldOffset(recordType, fieldId),
         getClosedFieldSize(recordType, fieldId));
   }
 }
コード例 #12
0
 @Override
 public void writeTo(DataOutput out) throws IOException {
   out.writeUTF(commandName);
   out.writeUTF(commandIdentifier);
   out.writeBoolean(expectReply);
   out.writeUTF(payloadType);
   out.writeUTF(payloadRevision == null ? "_null" : payloadRevision);
   out.writeInt(serializedPayload.length);
   out.write(serializedPayload);
   out.writeInt(serializedMetaData.length);
   out.write(serializedMetaData);
 }
コード例 #13
0
ファイル: DataSerializer.java プロジェクト: BenKoerber/TomP2P
 private void write(DataOutput out, ByteBuffer[] nioBuffers) throws IOException {
   final int length = nioBuffers.length;
   for (int i = 0; i < length; i++) {
     int remaining = nioBuffers[i].remaining();
     if (nioBuffers[i].hasArray()) {
       out.write(nioBuffers[i].array(), nioBuffers[i].arrayOffset(), remaining);
     } else {
       byte[] me = new byte[remaining];
       nioBuffers[i].get(me);
       out.write(me);
     }
   }
 }
コード例 #14
0
 @Override
 public void convertString(UTF8StringPointable stringp, DataOutput dOut)
     throws SystemException, IOException {
   boolean castable = true;
   try {
     abvsInner.reset();
     CastToIntegerOperation castTo = new CastToIntegerOperation();
     castTo.convertString(stringp, dOutInner);
   } catch (Exception e) {
     castable = false;
   }
   dOut.write(ValueTag.XS_BOOLEAN_TAG);
   dOut.write((byte) (castable ? 1 : 0));
 }
コード例 #15
0
  /**
   * DO NOT call symbolTable.addReference in writeObject as this (may) result in a
   * concurrentModificationException.
   *
   * <p>All references should be created in the constructor
   */
  public void writeObject(DataOutput out) throws IOException {
    boolean sgIO = node instanceof com.sun.j3d.utils.scenegraph.io.SceneGraphIO;
    out.writeBoolean(sgIO);
    out.writeInt(symbol.nodeID);

    int nodeClassID = control.getNodeClassID(node);

    out.writeShort(nodeClassID);

    if (nodeClassID == -1) out.writeUTF(nodeClassName);

    writeConstructorParams(out);

    if (sgIO) {
      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      DataOutputStream tmpOut = new DataOutputStream(byteStream);
      ((com.sun.j3d.utils.scenegraph.io.SceneGraphIO) node).writeSceneGraphObject(tmpOut);
      tmpOut.close();
      out.writeInt(byteStream.size());
      out.write(byteStream.toByteArray());
    }

    writeUserData(out);
    writeString(node.getName(), out);

    writeCapabilities(out);
  }
コード例 #16
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);
    }
  }
コード例 #17
0
 /**
  * Write the current message to an ExtendedDataOutput object
  *
  * @param dataOutput Where the current message will be written to
  */
 public void writeCurrentMessageBytes(DataOutput dataOutput) {
   try {
     dataOutput.write(getByteArray(), messageOffset, messageBytes);
   } catch (IOException e) {
     throw new IllegalStateException("writeCurrentMessageBytes: Got " + "IOException", e);
   }
 }
コード例 #18
0
 @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());
 }
コード例 #19
0
 @Override
 public void serialize(DataOutput out) throws IOException {
   out.write(multiplexerSessions.size());
   for (String id : multiplexerSessions) {
     out.writeUTF(id);
   }
 }
コード例 #20
0
  @Override
  public void convertString(UTF8StringPointable stringp, DataOutput dOut)
      throws SystemException, IOException {
    ICharacterIterator charIterator = new UTF8StringCharacterIterator(stringp);
    charIterator.reset();
    long value = 0;
    int c = 0;
    boolean negative = false;
    long limit = -Integer.MAX_VALUE;

    // Check the first character.
    c = charIterator.next();
    if (c == Character.valueOf('-') && negativeAllowed) {
      negative = true;
      c = charIterator.next();
      limit = Integer.MIN_VALUE;
    }

    // Read the numeric value.
    do {
      if (Character.isDigit(c)) {
        if (value < limit + Character.getNumericValue(c)) {
          throw new SystemException(ErrorCode.FORG0001);
        }
        value = value * 10 - Character.getNumericValue(c);
      } else {
        throw new SystemException(ErrorCode.FORG0001);
      }
    } while ((c = charIterator.next()) != ICharacterIterator.EOS_CHAR);

    dOut.write(returnTag);
    dOut.writeInt((int) (negative ? value : -value));
  }
コード例 #21
0
 public void write(byte[] b, int off, int len) {
   try {
     dataOutput.write(b, off, len);
   } catch (IOException ex) {
     throw new RuntimeException(ex.getMessage());
   }
 }
コード例 #22
0
 protected void tightMarshalByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeInt(data.length);
     dataOut.write(data);
   }
 }
コード例 #23
0
 /** in order to improve the likelihood of not corrupting the header write as a single operation */
 protected void write(DataOutput out) throws IOException {
   ByteBuffer buffer = ByteBuffer.allocate(16);
   buffer.putLong(dataPointer);
   buffer.putInt(dataCapacity);
   buffer.putInt(dataCount);
   out.write(buffer.array(), 0, 16);
 }
コード例 #24
0
 public void getOpenFieldValue(ARecordType recordType, int fieldId, DataOutput dOut)
     throws IOException, AsterixException {
   dOut.write(
       bytes,
       getOpenFieldValueOffset(recordType, fieldId),
       getOpenFieldValueSize(recordType, fieldId));
 }
コード例 #25
0
ファイル: DataTagList.java プロジェクト: korti11/KatlonEngine
 @Override
 public void writeData(DataOutput writer) throws IOException {
   for (DataTagBase tag : tags) {
     writer.write(tag.getId());
     tag.writeData(writer);
   }
 }
コード例 #26
0
ファイル: RowId.java プロジェクト: tuan08/datatp
 public void write(DataOutput out) throws IOException {
   out.writeInt(key.length);
   out.write(key);
   out.writeLong(createdTime);
   out.writeLong(modifiedTime);
   out.writeByte(state);
 }
コード例 #27
0
 public static long inputStream2DataOutput(
     final InputStream is, final DataOutput output, final BytesPool pool) {
   long totalBytes = 0;
   final Ref<byte[]> bytes = pool.retainObject();
   try {
     while (is.available() > 0) {
       final int actualSize = is.read(bytes.object());
       if (actualSize == -1) {
         break;
       }
       output.write(bytes.object(), 0, actualSize);
       totalBytes += actualSize;
       if (LOG.isTraceEnabled()) {
         LOG.trace("read bytebuf's content to bytesList, size {}", actualSize);
       }
     }
   } catch (Throwable e) {
     LOG.warn(
         "exception when inputStream -> OutputStream, detail: {}",
         ExceptionUtils.exception2detail(e));
   } finally {
     bytes.release();
   }
   return totalBytes;
 }
コード例 #28
0
 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());
   }
 }
コード例 #29
0
 private void buffering(byte[] buffer, int pos, byte value, DataOutput out) throws IOException {
   int innerPos = pos % buffer.length;
   if (pos > 0 && innerPos == 0) {
     out.write(buffer, 0, buffer.length);
   }
   buffer[innerPos] = value;
 }
コード例 #30
0
 public void write(int b) {
   try {
     dataOutput.write(b);
   } catch (IOException ex) {
     throw new RuntimeException(ex.getMessage());
   }
 }