private boolean isFetchFirst(FetchOrientation fetchOrientation) { //TODO: Since OperationLog is moved to package o.a.h.h.ql.session, // we may add a Enum there and map FetchOrientation to it. if (fetchOrientation.equals(FetchOrientation.FETCH_FIRST)) { return true; } return false; }
/** * Verify if the given fetch orientation is part of the supported orientation types. * @param orientation * @param supportedOrientations * @throws HiveSQLException */ protected void validateFetchOrientation(FetchOrientation orientation, EnumSet<FetchOrientation> supportedOrientations) throws HiveSQLException { if (!supportedOrientations.contains(orientation)) { throw new HiveSQLException("The fetch type " + orientation.toString() + " is not supported for this resultset", "HY106"); } }
public static FetchOrientation getFetchOrientation(TFetchOrientation tFetchOrientation) { for (FetchOrientation fetchOrientation : values()) { if (tFetchOrientation.equals(fetchOrientation.toTFetchOrientation())) { return fetchOrientation; } } // TODO: Should this really default to FETCH_NEXT? return FETCH_NEXT; }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException { TFetchResultsResp resp = new TFetchResultsResp(); try { // Set fetch size int maxFetchSize = hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_MAX_FETCH_SIZE); if (req.getMaxRows() > maxFetchSize) { req.setMaxRows(maxFetchSize); } RowSet rowSet = cliService.fetchResults( new OperationHandle(req.getOperationHandle()), FetchOrientation.getFetchOrientation(req.getOrientation()), req.getMaxRows(), FetchType.getFetchType(req.getFetchType())); resp.setResults(rowSet.toTRowSet()); resp.setHasMoreRows(false); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error fetching results: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException { TFetchResultsResp resp = new TFetchResultsResp(); try { RowSet rowSet = cliService.fetchResults( new OperationHandle(req.getOperationHandle()), FetchOrientation.getFetchOrientation(req.getOrientation()), req.getMaxRows(), FetchType.getFetchType(req.getFetchType())); resp.setResults(rowSet.toTRowSet()); resp.setHasMoreRows(false); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error fetching results: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); } }
public static FetchOrientation getFetchOrientation(TFetchOrientation tFetchOrientation) { for (FetchOrientation fetchOrientation : values()) { if (tFetchOrientation.equals(fetchOrientation.toTFetchOrientation())) { return fetchOrientation; } } // TODO: Should this really default to FETCH_NEXT? return FETCH_NEXT; }
/** * Verify if the given fetch orientation is part of the supported orientation types. * @param orientation * @param supportedOrientations * @throws HiveSQLException */ protected void validateFetchOrientation(FetchOrientation orientation, EnumSet<FetchOrientation> supportedOrientations) throws HiveSQLException { if (!supportedOrientations.contains(orientation)) { throw new HiveSQLException("The fetch type " + orientation.toString() + " is not supported for this resultset", "HY106"); } }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException { TFetchResultsResp resp = new TFetchResultsResp(); try { RowSet rowSet = cliService.fetchResults( new OperationHandle(req.getOperationHandle()), FetchOrientation.getFetchOrientation(req.getOrientation()), req.getMaxRows(), FetchType.getFetchType(req.getFetchType())); resp.setResults(rowSet.toTRowSet()); resp.setHasMoreRows(false); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error fetching results: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); }
public static FetchOrientation getFetchOrientation(TFetchOrientation tFetchOrientation) { for (FetchOrientation fetchOrientation : values()) { if (tFetchOrientation.equals(fetchOrientation.toTFetchOrientation())) { return fetchOrientation; } } // TODO: Should this really default to FETCH_NEXT? return FETCH_NEXT; }
/** * Verify if the given fetch orientation is part of the supported orientation types. * @param orientation * @param supportedOrientations * @throws HiveSQLException */ protected void validateFetchOrientation(FetchOrientation orientation, EnumSet<FetchOrientation> supportedOrientations) throws HiveSQLException { if (!supportedOrientations.contains(orientation)) { throw new HiveSQLException("The fetch type " + orientation.toString() + " is not supported for this resultset", "HY106"); } }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException { TFetchResultsResp resp = new TFetchResultsResp(); try { RowSet rowSet = cliService.fetchResults( new OperationHandle(req.getOperationHandle()), FetchOrientation.getFetchOrientation(req.getOrientation()), req.getMaxRows(), FetchType.getFetchType(req.getFetchType())); resp.setResults(rowSet.toTRowSet()); resp.setHasMoreRows(false); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error fetching results: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); } }
public static FetchOrientation getFetchOrientation(TFetchOrientation tFetchOrientation) { for (FetchOrientation fetchOrientation : values()) { if (tFetchOrientation.equals(fetchOrientation.toTFetchOrientation())) { return fetchOrientation; } } // TODO: Should this really default to FETCH_NEXT? return FETCH_NEXT; }
/** * Verify if the given fetch orientation is part of the supported orientation types. * @param orientation * @param supportedOrientations * @throws HiveSQLException */ protected void validateFetchOrientation(FetchOrientation orientation, EnumSet<FetchOrientation> supportedOrientations) throws HiveSQLException { if (!supportedOrientations.contains(orientation)) { throw new HiveSQLException("The fetch type " + orientation.toString() + " is not supported for this resultset", "HY106"); } }