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

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

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public TreeMap readMap() throws IOException 

Source Link

Document

Reads the map following a Type.MAP code.

Usage

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 w  w .  jav a 2  s  .c  om
    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;
}