Example usage for org.apache.hadoop.typedbytes TypedBytesInput get

List of usage examples for org.apache.hadoop.typedbytes TypedBytesInput get

Introduction

In this page you can find the example usage for org.apache.hadoop.typedbytes TypedBytesInput get.

Prototype

public static TypedBytesInput get(DataInput in) 

Source Link

Document

Get a thread-local typed bytes input for the supplied DataInput .

Usage

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public String bytesToCharArray(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.STRING) {
        throw new FrontendException("Type code does not correspond to string.");
    }//from ww  w. j a va2  s.  co m
    return tbin.readString();
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Double bytesToDouble(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.DOUBLE) {
        throw new FrontendException("Type code does not correspond to double.");
    }//from  w  w  w .j ava  2 s.  com
    return tbin.readDouble();
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Float bytesToFloat(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.FLOAT) {
        throw new FrontendException("Type code does not correspond to float.");
    }/*from   w w w  . j  a v a2s .c o  m*/
    return tbin.readFloat();
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Integer bytesToInteger(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.INT) {
        throw new FrontendException("Type code does not correspond to int.");
    }//from w  w  w  . ja  v a 2s  .c  om
    return tbin.readInt();
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Long bytesToLong(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.LONG) {
        throw new FrontendException("Type code does not correspond to long.");
    }/*from   ww w.ja  v  a2s .  c  o m*/
    return tbin.readLong();
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Map<String, Object> bytesToMap(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.MAP) {
        throw new FrontendException("Type code does not correspond to map.");
    }/*from  w ww.j a  va  2s  . c o  m*/
    Map<String, Object> result = new HashMap<String, Object>();
    for (Object item : tbin.readMap().entrySet()) {
        Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) item;
        result.put(entry.getKey().toString(), entry.getValue());
    }
    return result;
}

From source file:fm.last.pigtail.storage.TypedBytesSequenceFileLoader.java

License:Apache License

@Override
public Tuple bytesToTuple(byte[] b) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    DataInputStream dis = new DataInputStream(bais);
    TypedBytesInput tbin = TypedBytesInput.get(dis);
    if (tbin.readType() != org.apache.hadoop.typedbytes.Type.VECTOR) {
        throw new FrontendException("Type code does not correspond to vector.");
    }/*from w  w w  .j a v a 2s  .  c  o m*/
    Tuple result = tupleFactory.newTuple();
    for (Object item : tbin.readVector()) {
        result.append(item);
    }
    return result;
}