Search in sources :

Example 1 with TRow

use of org.apache.hive.service.rpc.thrift.TRow in project hive by apache.

the class RowBasedSet method iterator.

@Override
public Iterator<Object[]> iterator() {
    return new Iterator<Object[]>() {

        final Iterator<TRow> iterator = rows.iterator();

        final Object[] convey = new Object[numColumns()];

        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public Object[] next() {
            TRow row = iterator.next();
            List<TColumnValue> values = row.getColVals();
            for (int i = 0; i < values.size(); i++) {
                convey[i] = ColumnValue.toColumnValue(values.get(i));
            }
            return convey;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("remove");
        }
    };
}
Also used : TRow(org.apache.hive.service.rpc.thrift.TRow) Iterator(java.util.Iterator) TColumnValue(org.apache.hive.service.rpc.thrift.TColumnValue)

Example 2 with TRow

use of org.apache.hive.service.rpc.thrift.TRow in project hive by apache.

the class RowBasedSet method addRow.

@Override
public RowBasedSet addRow(Object[] fields) {
    TRow tRow = new TRow();
    for (int i = 0; i < fields.length; i++) {
        tRow.addToColVals(ColumnValue.toTColumnValue(descriptors[i], fields[i]));
    }
    rows.add(tRow);
    return this;
}
Also used : TRow(org.apache.hive.service.rpc.thrift.TRow)

Example 3 with TRow

use of org.apache.hive.service.rpc.thrift.TRow in project hive by apache.

the class RowBasedSet method toTRowSet.

public TRowSet toTRowSet() {
    TRowSet tRowSet = new TRowSet();
    tRowSet.setStartRowOffset(startOffset);
    tRowSet.setRows(new ArrayList<TRow>(rows));
    return tRowSet;
}
Also used : TRowSet(org.apache.hive.service.rpc.thrift.TRowSet) TRow(org.apache.hive.service.rpc.thrift.TRow)

Example 4 with TRow

use of org.apache.hive.service.rpc.thrift.TRow in project hive by apache.

the class ColumnBasedSet method toTRowSet.

public TRowSet toTRowSet() {
    TRowSet tRowSet = new TRowSet(startOffset, new ArrayList<TRow>());
    if (isBlobBased) {
        tRowSet.setColumns(null);
        tRowSet.setBinaryColumns(blob);
        tRowSet.setColumnCount(numColumns());
    } else {
        for (int i = 0; i < columns.size(); i++) {
            tRowSet.addToColumns(columns.get(i).toTColumn());
        }
    }
    return tRowSet;
}
Also used : TRowSet(org.apache.hive.service.rpc.thrift.TRowSet) TRow(org.apache.hive.service.rpc.thrift.TRow)

Aggregations

TRow (org.apache.hive.service.rpc.thrift.TRow)4 TRowSet (org.apache.hive.service.rpc.thrift.TRowSet)2 Iterator (java.util.Iterator)1 TColumnValue (org.apache.hive.service.rpc.thrift.TColumnValue)1