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

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

Introduction

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

Prototype

public static int readVInt(DataInput stream) throws IOException 

Source Link

Document

Reads a zero-compressed encoded integer from input stream and returns it.

Usage

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    int ordinal = WritableUtils.readVInt(input);
    rowKeyOrderOptimizable = false;/*from  w w w  .ja  v  a  2s. c  o m*/
    if (ordinal < 0) {
        rowKeyOrderOptimizable = true;
        ordinal = -(ordinal + 1);
    }
    toType = PDataType.values()[ordinal];
    toSortOrder = SortOrder.fromSystemValue(WritableUtils.readVInt(input));
    int byteSize = WritableUtils.readVInt(input);
    this.maxLength = byteSize == -1 ? null : byteSize;
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    // read/write type ordinal, maxLength presence, scale presence and isNullable bit together to save space
    int typeAndFlag = WritableUtils.readVInt(input);
    isNullable = (typeAndFlag & 0x01) != 0;
    if ((typeAndFlag & 0x02) != 0) {
        scale = WritableUtils.readVInt(input);
    }//from w  w  w.  j a  v  a  2 s . c  o  m
    if ((typeAndFlag & 0x04) != 0) {
        maxLength = WritableUtils.readVInt(input);
    }
    type = PDataType.values()[typeAndFlag >>> 3];
    sortOrder = SortOrder.fromSystemValue(WritableUtils.readVInt(input));
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    op = CompareOp.values()[WritableUtils.readVInt(input)];
    super.readFields(input);
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    scale = WritableUtils.readVInt(input);
}

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

License:Apache License

private int readValue(DataInput input, byte[] valuesBytes, int offset, ImmutableBytesPtr ptr)
        throws IOException {
    int valueLen = fixedWidth == -1 ? WritableUtils.readVInt(input) : fixedWidth;
    values.add(new ImmutableBytesPtr(valuesBytes, offset, valueLen));
    return offset + valueLen;
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    input.readBoolean(); // Unused, but left for b/w compat. TODO: remove in next major release
    fixedWidth = WritableUtils.readVInt(input);
    byte[] valuesBytes = Bytes.readByteArray(input);
    valuesByteLength = valuesBytes.length;
    int len = fixedWidth == -1 ? WritableUtils.readVInt(input) : valuesByteLength / fixedWidth;
    // TODO: consider using a regular HashSet as we never serialize from the server-side
    values = Sets.newLinkedHashSetWithExpectedSize(len);
    int offset = 0;
    int i = 0;/*from  www . java2 s  . co m*/
    if (i < len) {
        offset = readValue(input, valuesBytes, offset, minValue = new ImmutableBytesPtr());
        while (++i < len - 1) {
            offset = readValue(input, valuesBytes, offset, new ImmutableBytesPtr());
        }
        if (i < len) {
            offset = readValue(input, valuesBytes, offset, maxValue = new ImmutableBytesPtr());
        } else {
            maxValue = minValue;
        }
    } else {
        minValue = maxValue = new ImmutableBytesPtr(ByteUtil.EMPTY_BYTE_ARRAY);
    }
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    int encodedByteLengthAndBool = WritableUtils.readVInt(input);
    int byteLength = Math.abs(encodedByteLengthAndBool) - 1;
    this.byteValue = new byte[byteLength];
    input.readFully(byteValue, 0, byteLength);
    int sortOrderAndDeterminism = WritableUtils.readVInt(input);
    if (sortOrderAndDeterminism <= 2) {
        //client is on an older version
        this.determinism = encodedByteLengthAndBool > 0 ? Determinism.ALWAYS : Determinism.PER_ROW;
        this.sortOrder = SortOrder.fromSystemValue(sortOrderAndDeterminism);
        ;/*  w ww. java 2s. c o m*/
    } else {
        int determinismOrdinal = (sortOrderAndDeterminism >> 2) - 1;
        this.determinism = Determinism.values()[determinismOrdinal];
        int sortOrderValue = sortOrderAndDeterminism & ((1 << 2) - 1); //get the least 2 significant bits
        this.sortOrder = SortOrder.fromSystemValue(sortOrderValue);
    }
    int typeOrdinal = WritableUtils.readVInt(input);
    if (typeOrdinal < 0) {
        this.type = null;
    } else {
        this.type = PDataType.values()[typeOrdinal];
    }
    if (this.byteValue.length == 0) {
        this.value = null;
    } else {
        this.value = this.type.toObject(byteValue, 0, byteValue.length, this.type, sortOrder);
    }
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    this.isNullsLast = input.readBoolean();
    this.isAscending = input.readBoolean();
    expression = ExpressionType.values()[WritableUtils.readVInt(input)].newInstance();
    expression.readFields(input);//from w  ww  .ja v a 2s  . c o  m
}

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

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);
    this.decodedColumnQualifier = WritableUtils.readVInt(input);
    this.encodingScheme = QualifierEncodingScheme.values()[WritableUtils.readVInt(input)];
    setKeyValueExpression();//w  ww . j  a v  a2 s.c o m
}

From source file:org.apache.phoenix.filter.BooleanExpressionFilter.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    try {/*from w  ww  .jav  a 2  s  .co  m*/
        expression = ExpressionType.values()[WritableUtils.readVInt(input)].newInstance();
        expression.readFields(input);
        expression.reset(); // Initializes expression tree for partial evaluation
    } catch (Throwable t) { // Catches incompatibilities during reading/writing and doesn't retry
        ServerUtil.throwIOException("BooleanExpressionFilter failed during reading", t);
    }
}