public void write(org.apache.thrift.protocol.TProtocol oprot, TOperationHandle struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.operationId != null) { oprot.writeFieldBegin(OPERATION_ID_FIELD_DESC); struct.operationId.write(oprot); oprot.writeFieldEnd(); } if (struct.operationType != null) { oprot.writeFieldBegin(OPERATION_TYPE_FIELD_DESC); oprot.writeI32(struct.operationType.getValue()); oprot.writeFieldEnd(); } oprot.writeFieldBegin(HAS_RESULT_SET_FIELD_DESC); oprot.writeBool(struct.hasResultSet); oprot.writeFieldEnd(); if (struct.isSetModifiedRowCount()) { oprot.writeFieldBegin(MODIFIED_ROW_COUNT_FIELD_DESC); oprot.writeDouble(struct.modifiedRowCount); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
public boolean equals(TOperationHandle that) { if (that == null) return false; boolean this_present_operationId = true && this.isSetOperationId(); boolean that_present_operationId = true && that.isSetOperationId(); if (this_present_operationId || that_present_operationId) { if (!(this_present_operationId && that_present_operationId)) return false; if (!this.operationId.equals(that.operationId)) return false; } boolean this_present_operationType = true && this.isSetOperationType(); boolean that_present_operationType = true && that.isSetOperationType(); if (this_present_operationType || that_present_operationType) { if (!(this_present_operationType && that_present_operationType)) return false; if (!this.operationType.equals(that.operationType)) return false; } boolean this_present_hasResultSet = true; boolean that_present_hasResultSet = true; if (this_present_hasResultSet || that_present_hasResultSet) { if (!(this_present_hasResultSet && that_present_hasResultSet)) return false; if (this.hasResultSet != that.hasResultSet) return false; } boolean this_present_modifiedRowCount = true && this.isSetModifiedRowCount(); boolean that_present_modifiedRowCount = true && that.isSetModifiedRowCount(); if (this_present_modifiedRowCount || that_present_modifiedRowCount) { if (!(this_present_modifiedRowCount && that_present_modifiedRowCount)) return false; if (this.modifiedRowCount != that.modifiedRowCount) return false; } return true; }
/** Performs a deep copy on <i>other</i>. */ public TOperationHandle(TOperationHandle other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetOperationId()) { this.operationId = new THandleIdentifier(other.operationId); } if (other.isSetOperationType()) { this.operationType = other.operationType; } this.hasResultSet = other.hasResultSet; this.modifiedRowCount = other.modifiedRowCount; }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TOperationHandle struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.operationId.write(oprot); oprot.writeI32(struct.operationType.getValue()); oprot.writeBool(struct.hasResultSet); BitSet optionals = new BitSet(); if (struct.isSetModifiedRowCount()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetModifiedRowCount()) { oprot.writeDouble(struct.modifiedRowCount); } }
public void read(org.apache.thrift.protocol.TProtocol iprot, TOperationHandle struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // OPERATION_ID if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.operationId = new THandleIdentifier(); struct.operationId.read(iprot); struct.setOperationIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // OPERATION_TYPE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.operationType = TOperationType.findByValue(iprot.readI32()); struct.setOperationTypeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // HAS_RESULT_SET if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.hasResultSet = iprot.readBool(); struct.setHasResultSetIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // MODIFIED_ROW_COUNT if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.modifiedRowCount = iprot.readDouble(); struct.setModifiedRowCountIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); }
public int compareTo(TOperationHandle other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; TOperationHandle typedOther = (TOperationHandle) other; lastComparison = Boolean.valueOf(isSetOperationId()).compareTo(typedOther.isSetOperationId()); if (lastComparison != 0) { return lastComparison; } if (isSetOperationId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationId, typedOther.operationId); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetOperationType()).compareTo(typedOther.isSetOperationType()); if (lastComparison != 0) { return lastComparison; } if (isSetOperationType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationType, typedOther.operationType); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetHasResultSet()).compareTo(typedOther.isSetHasResultSet()); if (lastComparison != 0) { return lastComparison; } if (isSetHasResultSet()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasResultSet, typedOther.hasResultSet); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetModifiedRowCount()).compareTo(typedOther.isSetModifiedRowCount()); if (lastComparison != 0) { return lastComparison; } if (isSetModifiedRowCount()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo( this.modifiedRowCount, typedOther.modifiedRowCount); if (lastComparison != 0) { return lastComparison; } } return 0; }
public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetStatus()) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'status' is unset! Struct:" + toString()); } // check for sub-struct validity if (status != null) { status.validate(); } if (operationHandle != null) { operationHandle.validate(); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TOperationHandle struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.operationId = new THandleIdentifier(); struct.operationId.read(iprot); struct.setOperationIdIsSet(true); struct.operationType = TOperationType.findByValue(iprot.readI32()); struct.setOperationTypeIsSet(true); struct.hasResultSet = iprot.readBool(); struct.setHasResultSetIsSet(true); BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.modifiedRowCount = iprot.readDouble(); struct.setModifiedRowCountIsSet(true); } }
public void validate() throws org.apache.thrift.TException { // check for required fields if (operationHandle == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'operationHandle' was not present! Struct: " + toString()); } if (orientation == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'orientation' was not present! Struct: " + toString()); } // alas, we cannot check 'maxRows' because it's a primitive and you chose the non-beans // generator. // check for sub-struct validity if (operationHandle != null) { operationHandle.validate(); } }
@Override public boolean execute(String sql) throws SQLException { checkConnection("execute"); closeClientOperation(); initFlags(); TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql); /** * Run asynchronously whenever possible Currently only a SQLOperation can be run asynchronously, * in a background operation thread Compilation is synchronous and execution is asynchronous */ execReq.setRunAsync(true); execReq.setConfOverlay(sessConf); try { TExecuteStatementResp execResp = client.ExecuteStatement(execReq); Utils.verifySuccessWithInfo(execResp.getStatus()); stmtHandle = execResp.getOperationHandle(); isExecuteStatementFailed = false; } catch (SQLException eS) { isExecuteStatementFailed = true; throw eS; } catch (Exception ex) { isExecuteStatementFailed = true; throw new SQLException(ex.toString(), "08S01", ex); } TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle); boolean operationComplete = false; TGetOperationStatusResp statusResp; // Poll on the operation status, till the operation is complete while (!operationComplete) { try { /** * For an async SQLOperation, GetOperationStatus will use the long polling approach It will * essentially return after the HIVE_SERVER2_LONG_POLLING_TIMEOUT (a server config) expires */ statusResp = client.GetOperationStatus(statusReq); Utils.verifySuccessWithInfo(statusResp.getStatus()); if (statusResp.isSetOperationState()) { switch (statusResp.getOperationState()) { case CLOSED_STATE: case FINISHED_STATE: operationComplete = true; break; case CANCELED_STATE: // 01000 -> warning throw new SQLException("Query was cancelled", "01000"); case ERROR_STATE: // Get the error details from the underlying exception throw new SQLException( statusResp.getErrorMessage(), statusResp.getSqlState(), statusResp.getErrorCode()); case UKNOWN_STATE: throw new SQLException("Unknown query", "HY000"); case INITIALIZED_STATE: case PENDING_STATE: case RUNNING_STATE: break; } } } catch (SQLException e) { isLogBeingGenerated = false; throw e; } catch (Exception e) { isLogBeingGenerated = false; throw new SQLException(e.toString(), "08S01", e); } } isLogBeingGenerated = false; // The query should be completed by now if (!stmtHandle.isHasResultSet()) { return false; } resultSet = new HiveQueryResultSet.Builder(this) .setClient(client) .setSessionHandle(sessHandle) .setStmtHandle(stmtHandle) .setMaxRows(maxRows) .setFetchSize(fetchSize) .setScrollable(isScrollableResultset) .build(); return true; }