コード例 #1
0
ファイル: BigIntSerializer.java プロジェクト: rmetzger/flink
 public static boolean copyBigInteger(DataInputView source, DataOutputView target)
     throws IOException {
   final int len = source.readInt();
   target.writeInt(len);
   if (len > 4) {
     target.write(source, len - 4);
   }
   return len == 0; // returns true if the copied record was null
 }
コード例 #2
0
  @Override
  public void write(final DataOutputView out) throws IOException {
    out.writeInt(this.inetAddress.getAddress().length);
    out.write(this.inetAddress.getAddress());

    out.writeInt(this.dataPort);

    StringUtils.writeNullableString(fqdnHostName, out);
    StringUtils.writeNullableString(hostName, out);
  }
コード例 #3
0
ファイル: StringValue.java プロジェクト: rmetzger/flink
  @Override
  public void write(final DataOutputView out) throws IOException {
    int len = this.len;

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

    // write the char data, variable length encoded
    for (int i = 0; i < this.len; i++) {
      int c = this.value[i];

      while (c >= HIGH_BIT) {
        out.write(c | HIGH_BIT);
        c >>>= 7;
      }
      out.write(c);
    }
  }
コード例 #4
0
ファイル: BigIntSerializer.java プロジェクト: rmetzger/flink
 public static void writeBigInteger(BigInteger record, DataOutputView target) throws IOException {
   // null value support
   if (record == null) {
     target.writeInt(0);
     return;
   }
   // fast paths for 0, 1, 10
   // only reference equality is checked because equals would be too expensive
   else if (record == BigInteger.ZERO) {
     target.writeInt(1);
     return;
   } else if (record == BigInteger.ONE) {
     target.writeInt(2);
     return;
   } else if (record == BigInteger.TEN) {
     target.writeInt(3);
     return;
   }
   // default
   final byte[] bytes = record.toByteArray();
   // the length we write is offset by four, because null and short-paths for ZERO, ONE, and TEN
   target.writeInt(bytes.length + 4);
   target.write(bytes);
 }
コード例 #5
0
 @Override
 public void copy(DataInputView source, DataOutputView target) throws IOException {
   target.write(source, 2);
 }