Examples of ByteArrayDataOutput


Examples of com.google.common.io.ByteArrayDataOutput

            byte[] data = mByteCache.getIfPresent(bucketIndex);
            if (data == null) {
                data = getAndprefetchBuckets(bucketIndex);
            }

            final ByteArrayDataOutput output = ByteStreams.newDataOutput(bytes.length);
            int length = -1;
            if (bucketOffset + bytes.length > SIZE_PER_BUCKET) {
                length = SIZE_PER_BUCKET - bucketOffset;
            } else {
                length = bytes.length;
            }

            output.write(data, bucketOffset, length);

            if (bucketOffset + bytes.length > SIZE_PER_BUCKET) {
                data = mByteCache.getIfPresent(bucketIndex + 1);
                if (data == null) {
                    data = getAndprefetchBuckets(bucketIndex + 1);
                }

                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

Examples of com.google.common.io.ByteArrayDataOutput

  /**
   * Marks that the clusters with the given clusterIds have consumed the mutation
   * @param clusterIds of the clusters that have consumed the mutation
   */
  public void setClusterIds(List<UUID> clusterIds) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }
View Full Code Here

Examples of com.google.common.io.ByteArrayDataOutput

  /**
   * Marks that the clusters with the given clusterIds have consumed the mutation
   * @param clusterIds of the clusters that have consumed the mutation
   */
  public void setClusterIds(List<UUID> clusterIds) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }
View Full Code Here

Examples of com.google.common.io.ByteArrayDataOutput

  /**
   * Marks that the clusters with the given clusterIds have consumed the mutation
   * @param clusterIds of the clusters that have consumed the mutation
   */
  public void setClusterIds(List<UUID> clusterIds) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
  }
View Full Code Here

Examples of com.google.common.io.ByteArrayDataOutput

   * @return The serialized data
   */
  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

Examples of com.google.common.io.ByteArrayDataOutput

        for (TreeRange range : mt.invalids())
            range.addAll(new HIterator(range.right));

        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

Examples of com.google.common.io.ByteArrayDataOutput

        return VERSION_MAP.get(CUR_VER);
    }

    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());
    }
View Full Code Here

Examples of com.google.common.io.ByteArrayDataOutput

  /**
   * Marks that the clusters with the given clusterIds have consumed the mutation
   * @param clusterIds of the clusters that have consumed the mutation
   */
  public Mutation setClusterIds(List<UUID> clusterIds) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeInt(clusterIds.size());
    for (UUID clusterId : clusterIds) {
      out.writeLong(clusterId.getMostSignificantBits());
      out.writeLong(clusterId.getLeastSignificantBits());
    }
    setAttribute(CONSUMED_CLUSTER_IDS, out.toByteArray());
    return this;
  }
View Full Code Here

Examples of com.google.common.io.ByteArrayDataOutput

    }
  }

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

Examples of com.google.common.io.ByteArrayDataOutput

    }
      try{
      switch(mode){

      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));
        return new BytesHolder(out.toByteArray());
      }

      case PROTOBUF:
        return new BytesHolder(( (Message) obj).toByteArray());
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.