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:org.apache.hama.bsp.TaskCompletionEvent.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    taskId.readFields(in);//from   w w w .j av  a  2  s .c  om
    idWithinJob = WritableUtils.readVInt(in);
    status = WritableUtils.readEnum(in, Status.class);
    groomServerInfo = WritableUtils.readString(in);
    taskRunTime = WritableUtils.readVInt(in);
    eventId = WritableUtils.readVInt(in);
}

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

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    this.jobId.readFields(in);
    this.taskId.readFields(in);
    this.progress = in.readFloat();
    this.runState = WritableUtils.readEnum(in, State.class);
    this.stateString = Text.readString(in);
    this.phase = WritableUtils.readEnum(in, Phase.class);
    this.startTime = in.readLong();
    this.finishTime = in.readLong();

    counters = new Counters();
    this.counters.readFields(in);
}

From source file:org.apache.hama.ml.ann.AbstractLayeredNeuralNetwork.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    // read regularization weight
    this.regularizationWeight = input.readDouble();
    // read momentum weight
    this.momentumWeight = input.readDouble();

    // read cost function
    this.costFunction = FunctionFactory.createDoubleDoubleFunction(WritableUtils.readString(input));

    // read layer size list
    int numLayers = input.readInt();
    this.layerSizeList = Lists.newArrayList();
    for (int i = 0; i < numLayers; ++i) {
        this.layerSizeList.add(input.readInt());
    }//w  ww.j  av a2 s. com

    this.trainingMethod = WritableUtils.readEnum(input, TrainingMethod.class);
    this.learningStyle = WritableUtils.readEnum(input, LearningStyle.class);
}

From source file:org.apache.horn.core.AbstractLayeredNeuralNetwork.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    // read regularization weight
    this.regularizationWeight = input.readFloat();
    // read momentum weight
    this.momentumWeight = input.readFloat();

    // read cost function
    this.costFunction = FunctionFactory.createFloatFloatFunction(WritableUtils.readString(input));

    // read layer size list
    int numLayers = input.readInt();
    this.layerSizeList = Lists.newArrayList();
    for (int i = 0; i < numLayers; ++i) {
        this.layerSizeList.add(input.readInt());
    }//from   w w  w.j  av  a2  s  .c  o  m

    this.trainingMethod = WritableUtils.readEnum(input, TrainingMethod.class);
    this.learningStyle = WritableUtils.readEnum(input, LearningStyle.class);
}

From source file:org.apache.mahout.classifier.mlp.NeuralNetwork.java

License:Apache License

/**
 * Read the fields of the model from input.
 * /*w  w w.ja v a 2  s.  com*/
 * @param input The input instance.
 * @throws IOException
 */
public void readFields(DataInput input) throws IOException {
    // Read model type
    modelType = WritableUtils.readString(input);
    if (!modelType.equals(this.getClass().getSimpleName())) {
        throw new IllegalArgumentException(
                "The specified location does not contains the valid NeuralNetwork model.");
    }
    // Read learning rate
    learningRate = input.readDouble();
    // Read model path
    modelPath = WritableUtils.readString(input);
    if (modelPath.equals("null")) {
        modelPath = null;
    }

    // Read regularization weight
    regularizationWeight = input.readDouble();
    // Read momentum weight
    momentumWeight = input.readDouble();

    // Read cost function
    costFunctionName = WritableUtils.readString(input);

    // Read layer size list
    int numLayers = input.readInt();
    layerSizeList = Lists.newArrayList();
    for (int i = 0; i < numLayers; i++) {
        layerSizeList.add(input.readInt());
    }

    trainingMethod = WritableUtils.readEnum(input, TrainingMethod.class);

    // Read squash functions
    int squashingFunctionSize = input.readInt();
    squashingFunctionList = Lists.newArrayList();
    for (int i = 0; i < squashingFunctionSize; i++) {
        squashingFunctionList.add(WritableUtils.readString(input));
    }

    // Read weights and construct matrices of previous updates
    int numOfMatrices = input.readInt();
    weightMatrixList = Lists.newArrayList();
    prevWeightUpdatesList = Lists.newArrayList();
    for (int i = 0; i < numOfMatrices; i++) {
        Matrix matrix = MatrixWritable.readMatrix(input);
        weightMatrixList.add(matrix);
        prevWeightUpdatesList.add(new DenseMatrix(matrix.rowSize(), matrix.columnSize()));
    }
}

From source file:org.apache.phoenix.expression.function.ToCharFunction.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    formatString = WritableUtils.readString(input);
    type = WritableUtils.readEnum(input, FunctionArgumentType.class);
    formatter = type.getFormatter(formatString);
}

From source file:org.apache.phoenix.expression.function.ToNumberFunction.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    formatString = WritableUtils.readString(input);
    type = WritableUtils.readEnum(input, FunctionArgumentType.class);
    if (formatString != null) {
        format = type.getFormatter(formatString);
    }//from  w w w .  j  a v  a  2  s .  c o  m
}

From source file:org.apache.phoenix.expression.SingleCellConstructorExpression.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    this.immutableStorageScheme = WritableUtils.readEnum(input, ImmutableStorageScheme.class);
}

From source file:org.apache.rya.reasoning.Derivation.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    sources.clear();// ww w.  j  ava2 s . c  om
    sourceNodes.clear();
    rule = WritableUtils.readEnum(in, OwlRule.class);
    if (rule == OwlRule.NONE) {
        iteration = 0;
        node = EMPTY_NODE;
    } else {
        iteration = in.readInt();
        node.readFields(in);
        if (node.get() != null) {
            sourceNodes.add(node.get());
        }
        int numPredecessors = in.readInt();
        for (int i = 0; i < numPredecessors; i++) {
            Fact fact = new Fact();
            fact.readFields(in);
            addSource(fact);
        }
    }
}

From source file:org.apache.tez.engine.records.TezDependentTaskCompletionEvent.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    taskAttemptId.readFields(in);// www  . j  a v  a 2  s.c o m
    //    isMap = in.readBoolean();
    status = WritableUtils.readEnum(in, Status.class);
    taskTrackerHttp = WritableUtils.readString(in);
    taskRunTime = WritableUtils.readVInt(in);
    eventId = WritableUtils.readVInt(in);

}