Package com.google.common.io

Examples of com.google.common.io.ByteArrayDataOutput.toByteArray()


                }

                output.write(data, 0, bytes.length - (SIZE_PER_BUCKET - bucketOffset));
            }

            System.arraycopy(output.toByteArray(), 0, bytes, 0, bytes.length);
        } catch (ExecutionException | InterruptedException exc) {
            throw new IOException(exc);
        }
    }
View Full Code Here


    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }

  /**
   * @return the set of clusterIds that have consumed the mutation
   */
 
View Full Code Here

    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }

  /**
   * @return the set of cluster Ids that have consumed the mutation
   */
 
View Full Code Here

    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }

  /**
   * @return the set of clusterIds that have consumed the mutation
   */
 
View Full Code Here

  public static byte[] serialize(Writable value) {
    checkNotNull(value);
    try {
      ByteArrayDataOutput out = ByteStreams.newDataOutput();
      value.write(out);
      return out.toByteArray();
    } catch (IOException e) {
      throw new IllegalStateException("cannot serialize", e);
    }
  }
View Full Code Here

        byte[] initialhash = mt.hash(full);

        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
        byte[] serialized = out.toByteArray();

        ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
        MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

        assertHashEquals(initialhash, restored.hash(full));
View Full Code Here

    protected <T> void testSerializedSize(T obj, IVersionedSerializer<T> serializer) throws IOException
    {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        serializer.serialize(obj, out, getVersion());
        assert out.toByteArray().length == serializer.serializedSize(obj, getVersion());
    }

    protected static DataInputStream getInput(String name) throws IOException
    {
        File f = new File("test/data/serialization/" + CUR_VER + "/" + name);
View Full Code Here

    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
    return this;
  }

  /**
   * @return the set of clusterIds that have consumed the mutation
View Full Code Here

  public final Packet makePacket()
  {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeByte(getPacketId());
    write(out);
    return PacketDispatcher.getPacket(CHANNEL, out.toByteArray());
  }

  public abstract void write(ByteArrayDataOutput out);

  public abstract void read(ByteArrayDataInput in) throws ProtocolException;
View Full Code Here

      case DRILL_SERIALIZIABLE: {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        OutputStream outputStream = DataOutputOutputStream.constructOutputStream(out);
        ((DrillSerializable)obj).writeToStream(outputStream);
        outputStream.flush();
        return new BytesHolder(out.toByteArray());
      }

      case JACKSON: {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.write(mapper.writeValueAsBytes(obj));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.