Example usage for org.apache.hadoop.io WritableUtils readEnum

List of usage examples for org.apache.hadoop.io WritableUtils readEnum

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableUtils readEnum.

Prototype

public static <T extends Enum<T>> T readEnum(DataInput in, Class<T> enumType) throws IOException 

Source Link

Document

Read an Enum value from DataInput, Enums are read and written using String values.

Usage

From source file:com.netflix.aegisthus.input.AegSplit.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    end = in.readLong();/*from www. ja v  a2  s.c  o m*/
    hosts = WritableUtils.readStringArray(in);
    path = new Path(WritableUtils.readString(in));
    compressed = in.readBoolean();
    if (compressed) {
        compressedPath = new Path(WritableUtils.readString(in));
    }
    start = in.readLong();
    type = WritableUtils.readEnum(in, Type.class);
    int size = in.readInt();
    if (type == Type.sstable) {
        convertors = Maps.newHashMap();
        for (int i = 0; i < size; i++) {
            String[] parts = WritableUtils.readStringArray(in);
            try {
                convertors.put(parts[0], TypeParser.parse(parts[1]));
            } catch (ConfigurationException e) {
                throw new IOException(e);
            } catch (SyntaxException e) {
                throw new IOException(e);
            }
        }
    }
}

From source file:in.dream_lab.goffish.ControlMessage.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    transmissionType = WritableUtils.readEnum(in, IControlMessage.TransmissionType.class);
    extraInfo = Lists.newArrayList();/*from   www  . j  ava 2s .c  om*/
    int extraInfoSize;
    extraInfoSize = in.readInt();
    while (extraInfoSize-- > 0) {
        BytesWritable info = new BytesWritable();
        info.readFields(in);
        extraInfo.add(info);
    }
    if (isPartitionMessage()) {
        partitionID = in.readInt();
    } else if (isVertexMessage()) {
        vertexValues.readFields(in);
    }
}

From source file:in.dream_lab.goffish.hama.ControlMessage.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    transmissionType = WritableUtils.readEnum(in, IControlMessage.TransmissionType.class);
    extraInfo = Lists.newArrayList();/*from w w w.  ja  v  a 2s . co m*/
    int extraInfoSize;
    extraInfoSize = in.readInt();
    while (extraInfoSize-- > 0) {
        BytesWritable info = new BytesWritable();
        info.readFields(in);
        extraInfo.add(info);
    }
    if (isPartitionMessage()) {
        sourcePartitionID = in.readInt();
    } else if (isVertexMessage()) {
        vertexValues.readFields(in);
    }
}

From source file:in.dream_lab.goffish.hama.Message.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    control = new ControlMessage();
    control.readFields(in);/*  ww w.j  a  va2s . c  om*/
    messageType = WritableUtils.readEnum(in, IMessage.MessageType.class);
    hasSubgraphID = in.readBoolean();
    if (hasSubgraphID) {
        // TODO : Use reflection utils and instantiate
        // this.subgraphID = ReflectionUtils.newInstance(K.class);
        this.subgraphID = (K) new LongWritable();
        subgraphID.readFields(in);
    }
    hasMessage = in.readBoolean();
    if (hasMessage) {
        this.message = (M) ReflectionUtils.newInstance(GraphJobRunner.GRAPH_MESSAGE_CLASS);

        message.readFields(in);
    }
}

From source file:in.dream_lab.goffish.Message.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    control = new ControlMessage();
    control.readFields(in);/*from w  w w  .j  a  v a  2 s  .c  o m*/
    messageType = WritableUtils.readEnum(in, IMessage.MessageType.class);
    hasSubgraphID = in.readBoolean();
    if (hasSubgraphID) {
        //TODO : Use reflection utils and instantiate
        //this.subgraphID = ReflectionUtils.newInstance(K.class);
        this.subgraphID = (K) new LongWritable();
        subgraphID.readFields(in);
    }
    hasMessage = in.readBoolean();
    if (hasMessage) {
        this.message = (M) ReflectionUtils.newInstance(GraphJobRunner.GRAPH_MESSAGE_CLASS);

        message.readFields(in);
    }
}

From source file:org.apache.gora.filter.MapFieldValueFilter.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    fieldName = Text.readString(in);
    mapKey = new Utf8(Text.readString(in));
    filterOp = WritableUtils.readEnum(in, FilterOp.class);
    operands.clear();/*from  w  ww .jav a 2s  . c  o m*/
    int operandsSize = WritableUtils.readVInt(in);
    for (int i = 0; i < operandsSize; i++) {
        Object operand = ObjectWritable.readObject(in, conf);
        if (operand instanceof String) {
            operand = new Utf8((String) operand);
        }
        operands.add(operand);
    }
    filterIfMissing = in.readBoolean();
}

From source file:org.apache.gora.filter.SingleFieldValueFilter.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    fieldName = Text.readString(in);
    filterOp = WritableUtils.readEnum(in, FilterOp.class);
    operands.clear();// w  w  w .  j  a va  2  s.  c  o m
    int operandsSize = WritableUtils.readVInt(in);
    for (int i = 0; i < operandsSize; i++) {
        Object operand = ObjectWritable.readObject(in, conf);
        if (operand instanceof String) {
            operand = new Utf8((String) operand);
        }
        operands.add(operand);
    }
    filterIfMissing = in.readBoolean();
}

From source file:org.apache.hama.bsp.ClusterStatus.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    numActiveGrooms = in.readInt();//from w  w w .j av  a2 s  .co m
    boolean groomListFollows = in.readBoolean();

    if (groomListFollows) {
        activeGrooms = new HashMap<String, GroomServerStatus>(numActiveGrooms);

        for (int i = 0; i < numActiveGrooms; i++) {
            final String groomName = in.readUTF();
            final GroomServerStatus status = new GroomServerStatus();
            status.readFields(in);
            activeGrooms.put(groomName, status);
        }
    }

    tasks = in.readInt();
    maxTasks = in.readInt();
    state = WritableUtils.readEnum(in, BSPMaster.State.class);
}

From source file:org.apache.hama.bsp.DispatchTasksDirective.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    int length = WritableUtils.readVInt(in);
    if (length > 0) {
        this.actions = new GroomServerAction[length];
        for (int i = 0; i < length; ++i) {
            GroomServerAction.ActionType actionType = WritableUtils.readEnum(in,
                    GroomServerAction.ActionType.class);
            actions[i] = GroomServerAction.createAction(actionType);
            actions[i].readFields(in);/*  w  w  w.  ja va 2 s  . c o  m*/
        }
    } else {
        this.actions = null;
    }
}

From source file:org.apache.hama.bsp.GroomServerAction.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    actionType = WritableUtils.readEnum(in, ActionType.class);
}