Java Code Examples for org.apache.pig.data.DataByteArray#get()

The following examples show how to use org.apache.pig.data.DataByteArray#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RubyDataByteArray.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * Given a DataByteArray, this constructor creates a new one which copies the underlying bytes.
 *
 * @param ruby an instance of the ruby runtime
 * @param rc   an instance of the class object with meatadata
 * @param dba  a DataByteArray to copy then encapsulate
 */
protected RubyDataByteArray(final Ruby ruby, RubyClass rc, DataByteArray dba) {
    this(ruby, rc);
    byte[] buf1 = dba.get();
    byte[] buf2 = new byte[buf1.length];
    System.arraycopy(buf1, 0, buf2, 0, buf1.length);
    internalDBA = new DataByteArray(buf2);
}
 
Example 2
Source File: Bloom.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * For testing only, do not use directly.
 */
public void setFilter(DataByteArray dba) throws IOException {
    DataInputStream dis = new DataInputStream(new
        ByteArrayInputStream(dba.get()));
    filter = new BloomFilter();
    filter.readFields(dis);
}
 
Example 3
Source File: BuildBloomBase.java    From spork with Apache License 2.0 5 votes vote down vote up
protected BloomFilter bloomIn(DataByteArray b) throws IOException {
    DataInputStream dis = new DataInputStream(new
        ByteArrayInputStream(b.get()));
    BloomFilter f = new BloomFilter();
    f.readFields(dis);
    return f;
}
 
Example 4
Source File: Utf8StorageConverter.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] toBytes(DataByteArray a) throws IOException {
    return a.get();
}
 
Example 5
Source File: AccumuloBinaryConverter.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] toBytes(DataByteArray a) throws IOException {
    return a.get();
}
 
Example 6
Source File: HBaseBinaryConverter.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] toBytes(DataByteArray a) throws IOException {
    return a.get();
}
 
Example 7
Source File: AugmentBaseDataVisitor.java    From spork with Apache License 2.0 4 votes vote down vote up
Object GetSmallerValue(Object v) {
    byte type = DataType.findType(v);

    if (type == DataType.BAG || type == DataType.TUPLE
            || type == DataType.MAP)
        return null;

    switch (type) {
    case DataType.CHARARRAY:
        String str = (String) v;
        if (str.length() > 0)
            return str.substring(0, str.length() - 1);
        else
            return null;
    case DataType.BYTEARRAY:
        DataByteArray data = (DataByteArray) v;
        if (data.size() > 0)
            return new DataByteArray(data.get(), 0, data.size() - 1);
        else
            return null;
    case DataType.INTEGER:
        return Integer.valueOf((Integer) v - 1);
    case DataType.LONG:
        return Long.valueOf((Long) v - 1);
    case DataType.FLOAT:
        return Float.valueOf((Float) v - 1);
    case DataType.DOUBLE:
        return Double.valueOf((Double) v - 1);
    case DataType.BIGINTEGER:
        return ((BigInteger)v).subtract(BigInteger.ONE);
    case DataType.BIGDECIMAL:
        return ((BigDecimal)v).subtract(BigDecimal.ONE);
    case DataType.DATETIME:
        DateTime dt = (DateTime) v;
        if (dt.getMillisOfSecond() != 0) {
            return dt.minusMillis(1);
        } else if (dt.getSecondOfMinute() != 0) {
            return dt.minusSeconds(1);
        } else if (dt.getMinuteOfHour() != 0) {
            return dt.minusMinutes(1);
        } else if (dt.getHourOfDay() != 0) {
            return dt.minusHours(1);
        } else {
            return dt.minusDays(1);
        }
    default:
        return null;
    }

}