Search in sources :

Example 1 with ByteArrayDataInput

use of com.google.common.io.ByteArrayDataInput in project presto by prestodb.

the class RaptorColumnIdentity method deserialize.

public static RaptorColumnIdentity deserialize(byte[] bytes) {
    checkArgument(bytes.length >= Byte.BYTES, "bytes for RaptorColumnIdentity is corrupt");
    ByteArrayDataInput input = newDataInput(bytes);
    byte version = input.readByte();
    if ((version == CURRENT_VERSION) && (bytes.length == SERIALIZED_SIZE)) {
        long columnId = input.readLong();
        return new RaptorColumnIdentity(columnId);
    }
    throw new PrestoException(CORRUPT_SERIALIZED_IDENTITY, "RaptorColumnIdentity is corrupt: " + base16().lowerCase().encode(bytes));
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput)

Example 2 with ByteArrayDataInput

use of com.google.common.io.ByteArrayDataInput in project presto by prestodb.

the class RaptorTableIdentity method deserialize.

public static RaptorTableIdentity deserialize(byte[] bytes) {
    checkArgument(bytes.length >= Byte.BYTES, "bytes for RaptorTableIdentity is corrupt");
    ByteArrayDataInput input = newDataInput(bytes);
    byte version = input.readByte();
    if ((version == CURRENT_VERSION) && (bytes.length == SERIALIZED_SIZE)) {
        long tableId = input.readLong();
        return new RaptorTableIdentity(tableId);
    }
    throw new PrestoException(CORRUPT_SERIALIZED_IDENTITY, "RaptorTableIdentity is corrupt: " + base16().lowerCase().encode(bytes));
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput)

Example 3 with ByteArrayDataInput

use of com.google.common.io.ByteArrayDataInput in project hbase by apache.

the class Mutation method getClusterIds.

/**
   * @return the set of clusterIds that have consumed the mutation
   */
public List<UUID> getClusterIds() {
    List<UUID> clusterIds = new ArrayList<>();
    byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
    if (bytes != null) {
        ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
        int numClusters = in.readInt();
        for (int i = 0; i < numClusters; i++) {
            clusterIds.add(new UUID(in.readLong(), in.readLong()));
        }
    }
    return clusterIds;
}
Also used : ArrayList(java.util.ArrayList) UUID(java.util.UUID) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput)

Example 4 with ByteArrayDataInput

use of com.google.common.io.ByteArrayDataInput in project MinecraftForge by MinecraftForge.

the class ClassPatchManager method readPatch.

private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis) {
    if (DEBUG)
        FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
    ByteArrayDataInput input;
    try {
        input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
    } catch (IOException e) {
        FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
        return null;
    }
    String name = input.readUTF();
    String sourceClassName = input.readUTF();
    String targetClassName = input.readUTF();
    boolean exists = input.readBoolean();
    int inputChecksum = 0;
    if (exists) {
        inputChecksum = input.readInt();
    }
    int patchLength = input.readInt();
    byte[] patchBytes = new byte[patchLength];
    input.readFully(patchBytes);
    return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
Also used : IOException(java.io.IOException) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput)

Example 5 with ByteArrayDataInput

use of com.google.common.io.ByteArrayDataInput in project drill by apache.

the class HiveSubScan method deserializeInputSplit.

public static InputSplit deserializeInputSplit(String base64, String className) throws IOException, ReflectiveOperationException {
    Constructor<?> constructor = Class.forName(className).getDeclaredConstructor();
    if (constructor == null) {
        throw new ReflectiveOperationException("Class " + className + " does not implement a default constructor.");
    }
    constructor.setAccessible(true);
    InputSplit split = (InputSplit) constructor.newInstance();
    ByteArrayDataInput byteArrayDataInput = ByteStreams.newDataInput(Base64.decodeBase64(base64));
    split.readFields(byteArrayDataInput);
    return split;
}
Also used : ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) InputSplit(org.apache.hadoop.mapred.InputSplit)

Aggregations

ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)8 PrestoException (com.facebook.presto.spi.PrestoException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 Set (java.util.Set)1 UUID (java.util.UUID)1 RedisNetwork (me.itsmas.network.server.network.redis.RedisNetwork)1 BungeeForwardEvent (org.anhcraft.spaciouslib.events.BungeeForwardEvent)1 InputSplit (org.apache.hadoop.mapred.InputSplit)1 InputSplit (org.apache.hadoop.mapreduce.InputSplit)1