client.closeOperation(opHandle); return opStatus;
+ " = false"; opHandle = client.executeStatement(sessionHandle, queryString, confOverlay); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeSession(sessionHandle);
+ " = false"; OperationHandle opHandle = client.executeStatement(sessionHandle, setLockMgr, null); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeOperation(opHandle); client.closeSession(sessionHandle);
+ " = false"; opHandle = client.executeStatement(sessionHandle, queryString, confOverlay); client.closeOperation(opHandle);
@Test public void testGetFunctions() throws Exception { SessionHandle sessionHandle = client.openSession("tom", "password"); assertNotNull(sessionHandle); OperationHandle opHandle = client.getFunctions(sessionHandle, null, null, "*"); TableSchema schema = client.getResultSetMetadata(opHandle); ColumnDescriptor columnDesc = schema.getColumnDescriptorAt(0); assertEquals("FUNCTION_CAT", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(1); assertEquals("FUNCTION_SCHEM", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(2); assertEquals("FUNCTION_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(3); assertEquals("REMARKS", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(4); assertEquals("FUNCTION_TYPE", columnDesc.getName()); assertEquals(Type.INT_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(5); assertEquals("SPECIFIC_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); // Cleanup client.closeOperation(opHandle); client.closeSession(sessionHandle); }
@Override public boolean hasNext() throws LensException { if (fetchedRowsItr == null || !fetchedRowsItr.hasNext()) { try { rowSet = client.fetchResults(opHandle, orientation, fetchSize, FetchType.QUERY_OUTPUT); orientation = FetchOrientation.FETCH_NEXT; noMoreResults = rowSet.numRows() == 0; if (noMoreResults) { if (closeAfterFecth) { log.info("No more results closing the query"); client.closeOperation(opHandle); } return false; } fetchedRowsItr = rowSet.iterator(); } catch (Exception e) { throw new LensException(e); } } return fetchedRowsItr.hasNext(); }
@Override public boolean hasNext() throws LensException { if (fetchedRowsItr == null || !fetchedRowsItr.hasNext()) { try { rowSet = client.fetchResults(opHandle, orientation, fetchSize, FetchType.QUERY_OUTPUT); orientation = FetchOrientation.FETCH_NEXT; noMoreResults = rowSet.numRows() == 0; if (noMoreResults) { if (closeAfterFecth) { log.info("No more results closing the query"); client.closeOperation(opHandle); } return false; } fetchedRowsItr = rowSet.iterator(); } catch (Exception e) { throw new LensException(e); } } return fetchedRowsItr.hasNext(); }
@Override public void closeQuery(QueryHandle handle) throws LensException { if (handle == null) { return; } log.info("CloseQuery: {}", handle); OperationHandle opHandle = hiveHandles.remove(handle); if (opHandle != null) { log.info("CloseQuery hiveHandle: {}", opHandle); try { fetchLogs(opHandle); getClient().closeOperation(opHandle); } catch (HiveSQLException e) { checkInvalidOperation(handle, e); throw new LensException("Unable to close query", e); } finally { SessionHandle hiveSession = opHandleToSession.remove(opHandle); if (null != hiveSession && !opHandleToSession.containsValue(hiveSession) && orphanedHiveSessions.contains(hiveSession)) { orphanedHiveSessions.remove(hiveSession); try { getClient().closeSession(hiveSession); log.info("Closed orphaned hive session : {}", hiveSession.getHandleIdentifier()); } catch (HiveSQLException e) { log.warn("Error closing orphan hive session : {} ", hiveSession.getHandleIdentifier(), e); } } } } }
@Override public void closeQuery(QueryHandle handle) throws LensException { if (handle == null) { return; } log.info("CloseQuery: {}", handle); OperationHandle opHandle = hiveHandles.remove(handle); if (opHandle != null) { log.info("CloseQuery hiveHandle: {}", opHandle); try { fetchLogs(opHandle); getClient().closeOperation(opHandle); } catch (HiveSQLException e) { checkInvalidOperation(handle, e); throw new LensException("Unable to close query", e); } finally { SessionHandle hiveSession = opHandleToSession.remove(opHandle); if (null != hiveSession && !opHandleToSession.containsValue(hiveSession) && orphanedHiveSessions.contains(hiveSession)) { orphanedHiveSessions.remove(hiveSession); try { getClient().closeSession(hiveSession); log.info("Closed orphaned hive session : {}", hiveSession.getHandleIdentifier()); } catch (HiveSQLException e) { log.warn("Error closing orphan hive session : {} ", hiveSession.getHandleIdentifier(), e); } } } } }