Search in sources :

Example 1 with ByteArrayRef

use of org.apache.hadoop.hive.serde2.lazy.ByteArrayRef in project hive by apache.

the class LazyBinarySerDe method deserialize.

/**
   * Deserialize a table record to a lazybinary struct.
   */
@Override
public Object deserialize(Writable field) throws SerDeException {
    if (byteArrayRef == null) {
        byteArrayRef = new ByteArrayRef();
    }
    BinaryComparable b = (BinaryComparable) field;
    if (b.getLength() == 0) {
        return null;
    }
    byteArrayRef.setData(b.getBytes());
    cachedLazyBinaryStruct.init(byteArrayRef, 0, b.getLength());
    lastOperationSerialize = false;
    lastOperationDeserialize = true;
    return cachedLazyBinaryStruct;
}
Also used : BinaryComparable(org.apache.hadoop.io.BinaryComparable) ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Example 2 with ByteArrayRef

use of org.apache.hadoop.hive.serde2.lazy.ByteArrayRef in project hive by apache.

the class LazyDioByte method init.

@Override
public void init(ByteArrayRef bytes, int start, int length) {
    byte value = 0;
    try {
        in = new ByteStream.Input(bytes.getData(), start, length);
        din = new DataInputStream(in);
        value = din.readByte();
        data.set(value);
        isNull = false;
    } catch (Exception e) {
        isNull = true;
    } finally {
        try {
            din.close();
        } catch (IOException e) {
        // swallow exception
        }
        try {
            in.close();
        } catch (IOException e) {
        // swallow exception
        }
    }
}
Also used : ByteStream(org.apache.hadoop.hive.serde2.ByteStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) IOException(java.io.IOException)

Example 3 with ByteArrayRef

use of org.apache.hadoop.hive.serde2.lazy.ByteArrayRef in project hive by apache.

the class LazyDioDouble method init.

/* (non-Javadoc)
   * This provides a LazyDouble like class which can be initialized from data stored in a
   * binary format.
   *
   * @see org.apache.hadoop.hive.serde2.lazy.LazyObject#init
   *        (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef, int, int)
   */
@Override
public void init(ByteArrayRef bytes, int start, int length) {
    double value = 0.0;
    try {
        in = new ByteStream.Input(bytes.getData(), start, length);
        din = new DataInputStream(in);
        value = din.readDouble();
        data.set(value);
        isNull = false;
    } catch (IOException e) {
        isNull = true;
    } finally {
        try {
            din.close();
        } catch (IOException e) {
        // swallow exception
        }
        try {
            in.close();
        } catch (IOException e) {
        // swallow exception
        }
    }
}
Also used : ByteStream(org.apache.hadoop.hive.serde2.ByteStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 4 with ByteArrayRef

use of org.apache.hadoop.hive.serde2.lazy.ByteArrayRef in project hive by apache.

the class LazyDioFloat method init.

/* (non-Javadoc)
   * This provides a LazyFloat like class which can be initialized from data stored in a
   * binary format.
   *
   * @see org.apache.hadoop.hive.serde2.lazy.LazyObject#init
   *        (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef, int, int)
   */
@Override
public void init(ByteArrayRef bytes, int start, int length) {
    float value = 0.0F;
    try {
        in = new ByteStream.Input(bytes.getData(), start, length);
        din = new DataInputStream(in);
        value = din.readFloat();
        data.set(value);
        isNull = false;
    } catch (IOException e) {
        isNull = true;
    } finally {
        try {
            din.close();
        } catch (IOException e) {
        // swallow exception
        }
        try {
            in.close();
        } catch (IOException e) {
        // swallow exception
        }
    }
}
Also used : ByteStream(org.apache.hadoop.hive.serde2.ByteStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 5 with ByteArrayRef

use of org.apache.hadoop.hive.serde2.lazy.ByteArrayRef in project hive by apache.

the class LazyDioLong method init.

/* (non-Javadoc)
   * This provides a LazyLong like class which can be initialized from data stored in a
   * binary format.
   *
   * @see org.apache.hadoop.hive.serde2.lazy.LazyObject#init
   *        (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef, int, int)
   */
@Override
public void init(ByteArrayRef bytes, int start, int length) {
    long value = 0;
    try {
        in = new ByteStream.Input(bytes.getData(), start, length);
        din = new DataInputStream(in);
        value = din.readLong();
        data.set(value);
        isNull = false;
    } catch (IOException e) {
        isNull = true;
    } finally {
        try {
            din.close();
        } catch (IOException e) {
        // swallow exception
        }
        try {
            in.close();
        } catch (IOException e) {
        // swallow exception
        }
    }
}
Also used : ByteStream(org.apache.hadoop.hive.serde2.ByteStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Aggregations

ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)27 LazySimpleStructObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector)12 Text (org.apache.hadoop.io.Text)11 Test (org.junit.Test)11 Mutation (org.apache.accumulo.core.data.Mutation)10 LazyStruct (org.apache.hadoop.hive.serde2.lazy.LazyStruct)9 DataInputStream (java.io.DataInputStream)8 Properties (java.util.Properties)8 Configuration (org.apache.hadoop.conf.Configuration)8 ByteStream (org.apache.hadoop.hive.serde2.ByteStream)8 LazySerDeParameters (org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters)8 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)8 IOException (java.io.IOException)7 Connector (org.apache.accumulo.core.client.Connector)6 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)6 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)6 Key (org.apache.accumulo.core.data.Key)6 Value (org.apache.accumulo.core.data.Value)6 Authorizations (org.apache.accumulo.core.security.Authorizations)6 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)6