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();
}
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();
}
Aggregations