Search in sources :

Example 1 with TRowSet

use of org.apache.hive.service.cli.thrift.TRowSet in project cdap by caskdata.

the class Hive12ExploreService method doFetchNextResults.

@SuppressWarnings("unchecked")
@Override
protected List<QueryResult> doFetchNextResults(OperationHandle handle, FetchOrientation fetchOrientation, int size) throws Exception {
    Class cliServiceClass = Class.forName("org.apache.hive.service.cli.CLIService");
    Method fetchResultsMethod = cliServiceClass.getMethod("fetchResults", OperationHandle.class, FetchOrientation.class, Long.TYPE);
    Object rowSet = fetchResultsMethod.invoke(getCliService(), handle, fetchOrientation, size);
    ImmutableList.Builder<QueryResult> rowsBuilder = ImmutableList.builder();
    Class rowSetClass = Class.forName("org.apache.hive.service.cli.RowSet");
    Method toTRowSetMethod = rowSetClass.getMethod("toTRowSet");
    TRowSet tRowSet = (TRowSet) toTRowSetMethod.invoke(rowSet);
    for (TRow tRow : tRowSet.getRows()) {
        List<Object> cols = Lists.newArrayList();
        for (TColumnValue tColumnValue : tRow.getColVals()) {
            cols.add(HiveUtilities.tColumnToObject(tColumnValue));
        }
        rowsBuilder.add(new QueryResult(cols));
    }
    return rowsBuilder.build();
}
Also used : TRowSet(org.apache.hive.service.cli.thrift.TRowSet) TRow(org.apache.hive.service.cli.thrift.TRow) QueryResult(co.cask.cdap.proto.QueryResult) ImmutableList(com.google.common.collect.ImmutableList) Method(java.lang.reflect.Method) TColumnValue(org.apache.hive.service.cli.thrift.TColumnValue)

Example 2 with TRowSet

use of org.apache.hive.service.cli.thrift.TRowSet in project cdap by caskdata.

the class Hive12CDH5ExploreService method doFetchNextResults.

@Override
protected List<QueryResult> doFetchNextResults(OperationHandle handle, FetchOrientation fetchOrientation, int size) throws Exception {
    Class<?> cliServiceClass = Class.forName("org.apache.hive.service.cli.CLIService");
    Method fetchResultsMethod = cliServiceClass.getMethod("fetchResults", OperationHandle.class, FetchOrientation.class, Long.TYPE);
    Object rowSet = fetchResultsMethod.invoke(getCliService(), handle, fetchOrientation, size);
    ImmutableList.Builder<QueryResult> rowsBuilder = ImmutableList.builder();
    Class<?> rowSetClass = Class.forName("org.apache.hive.service.cli.RowSet");
    Method toTRowSetMethod = rowSetClass.getMethod("toTRowSet");
    TRowSet tRowSet = (TRowSet) toTRowSetMethod.invoke(rowSet);
    for (TRow tRow : tRowSet.getRows()) {
        List<Object> cols = Lists.newArrayList();
        for (TColumnValue tColumnValue : tRow.getColVals()) {
            cols.add(HiveUtilities.tColumnToObject(tColumnValue));
        }
        rowsBuilder.add(new QueryResult(cols));
    }
    return rowsBuilder.build();
}
Also used : TRowSet(org.apache.hive.service.cli.thrift.TRowSet) TRow(org.apache.hive.service.cli.thrift.TRow) QueryResult(co.cask.cdap.proto.QueryResult) ImmutableList(com.google.common.collect.ImmutableList) Method(java.lang.reflect.Method) TColumnValue(org.apache.hive.service.cli.thrift.TColumnValue)

Aggregations

QueryResult (co.cask.cdap.proto.QueryResult)2 ImmutableList (com.google.common.collect.ImmutableList)2 Method (java.lang.reflect.Method)2 TColumnValue (org.apache.hive.service.cli.thrift.TColumnValue)2 TRow (org.apache.hive.service.cli.thrift.TRow)2 TRowSet (org.apache.hive.service.cli.thrift.TRowSet)2