use of org.apache.hive.service.rpc.thrift.TRowSet in project hive by apache.
the class HiveQueryResultSet method next.
/**
* Moves the cursor down one row from its current position.
*
* @see java.sql.ResultSet#next()
* @throws SQLException
* if a database access error occurs.
*/
public boolean next() throws SQLException {
if (isClosed) {
throw new SQLException("Resultset is closed");
}
if (emptyResultSet || (maxRows > 0 && rowsFetched >= maxRows)) {
return false;
}
/**
* Poll on the operation status, till the operation is complete.
* We need to wait only for HiveStatement to complete.
* HiveDatabaseMetaData which also uses this ResultSet returns only after the RPC is complete.
*/
if ((statement != null) && (statement instanceof HiveStatement)) {
((HiveStatement) statement).waitForOperationToComplete();
}
try {
TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT;
if (fetchFirst) {
// If we are asked to start from begining, clear the current fetched resultset
orientation = TFetchOrientation.FETCH_FIRST;
fetchedRows = null;
fetchedRowsItr = null;
fetchFirst = false;
}
if (fetchedRows == null || !fetchedRowsItr.hasNext()) {
TFetchResultsReq fetchReq = new TFetchResultsReq(stmtHandle, orientation, fetchSize);
TFetchResultsResp fetchResp;
fetchResp = client.FetchResults(fetchReq);
Utils.verifySuccessWithInfo(fetchResp.getStatus());
TRowSet results = fetchResp.getResults();
fetchedRows = RowSetFactory.create(results, protocol);
fetchedRowsItr = fetchedRows.iterator();
}
if (fetchedRowsItr.hasNext()) {
row = fetchedRowsItr.next();
} else {
return false;
}
rowsFetched++;
} catch (SQLException eS) {
throw eS;
} catch (Exception ex) {
ex.printStackTrace();
throw new SQLException("Error retrieving next row", ex);
}
// NOTE: fetchOne doesn't throw new SQLFeatureNotSupportedException("Method not supported").
return true;
}
use of org.apache.hive.service.rpc.thrift.TRowSet 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;
}
use of org.apache.hive.service.rpc.thrift.TRowSet 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;
}
Aggregations