public boolean equals(TFetchResultsReq that) {
    if (that == null) return false;

    boolean this_present_operationHandle = true && this.isSetOperationHandle();
    boolean that_present_operationHandle = true && that.isSetOperationHandle();
    if (this_present_operationHandle || that_present_operationHandle) {
      if (!(this_present_operationHandle && that_present_operationHandle)) return false;
      if (!this.operationHandle.equals(that.operationHandle)) return false;
    }

    boolean this_present_orientation = true && this.isSetOrientation();
    boolean that_present_orientation = true && that.isSetOrientation();
    if (this_present_orientation || that_present_orientation) {
      if (!(this_present_orientation && that_present_orientation)) return false;
      if (!this.orientation.equals(that.orientation)) return false;
    }

    boolean this_present_maxRows = true;
    boolean that_present_maxRows = true;
    if (this_present_maxRows || that_present_maxRows) {
      if (!(this_present_maxRows && that_present_maxRows)) return false;
      if (this.maxRows != that.maxRows) return false;
    }

    return true;
  }
 /** Performs a deep copy on <i>other</i>. */
 public TFetchResultsReq(TFetchResultsReq other) {
   __isset_bitfield = other.__isset_bitfield;
   if (other.isSetOperationHandle()) {
     this.operationHandle = new TOperationHandle(other.operationHandle);
   }
   if (other.isSetOrientation()) {
     this.orientation = other.orientation;
   }
   this.maxRows = other.maxRows;
 }
Esempio n. 3
0
  /**
   * Get the execution logs of the given SQL statement. This method is a public API for usage
   * outside of Hive, although it is not part of the interface java.sql.Statement.
   *
   * @param incremental indicate getting logs either incrementally or from the beginning, when it is
   *     true or false.
   * @param fetchSize the number of lines to fetch
   * @return a list of logs. It can be empty if there are no new logs to be retrieved at that time.
   * @throws SQLException
   * @throws ClosedOrCancelledStatementException if statement has been cancelled or closed
   */
  public List<String> getQueryLog(boolean incremental, int fetchSize)
      throws SQLException, ClosedOrCancelledStatementException {
    checkConnection("getQueryLog");
    if (isCancelled) {
      throw new ClosedOrCancelledStatementException(
          "Method getQueryLog() failed. The " + "statement has been closed or cancelled.");
    }

    List<String> logs = new ArrayList<String>();
    TFetchResultsResp tFetchResultsResp = null;
    try {
      if (stmtHandle != null) {
        TFetchResultsReq tFetchResultsReq =
            new TFetchResultsReq(stmtHandle, getFetchOrientation(incremental), fetchSize);
        tFetchResultsReq.setFetchType((short) 1);
        tFetchResultsResp = client.FetchResults(tFetchResultsReq);
        Utils.verifySuccessWithInfo(tFetchResultsResp.getStatus());
      } else {
        if (isQueryClosed) {
          throw new ClosedOrCancelledStatementException(
              "Method getQueryLog() failed. The " + "statement has been closed or cancelled.");
        }
        if (isExecuteStatementFailed) {
          throw new SQLException(
              "Method getQueryLog() failed. Because the stmtHandle in "
                  + "HiveStatement is null and the statement execution might fail.");
        } else {
          return logs;
        }
      }
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      throw new SQLException("Error when getting query log: " + e, e);
    }

    RowSet rowSet = RowSetFactory.create(tFetchResultsResp.getResults(), connection.getProtocol());
    for (Object[] row : rowSet) {
      logs.add(String.valueOf(row[0]));
    }
    return logs;
  }
  @Override
  public int compareTo(TFetchResultsReq other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison =
        Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOperationHandle()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetOrientation()).compareTo(other.isSetOrientation());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOrientation()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.orientation, other.orientation);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMaxRows()).compareTo(other.isSetMaxRows());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMaxRows()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxRows, other.maxRows);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }
    public void read(org.apache.thrift.protocol.TProtocol iprot, TFetchResultsReq 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_HANDLE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.operationHandle = new TOperationHandle();
              struct.operationHandle.read(iprot);
              struct.setOperationHandleIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // ORIENTATION
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.orientation = TFetchOrientation.findByValue(iprot.readI32());
              struct.setOrientationIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // MAX_ROWS
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.maxRows = iprot.readI64();
              struct.setMaxRowsIsSet(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();

      // check for required fields of primitive type, which can't be checked in the validate method
      if (!struct.isSetMaxRows()) {
        throw new org.apache.thrift.protocol.TProtocolException(
            "Required field 'maxRows' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, TFetchResultsReq struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   struct.operationHandle = new TOperationHandle();
   struct.operationHandle.read(iprot);
   struct.setOperationHandleIsSet(true);
   struct.orientation = TFetchOrientation.findByValue(iprot.readI32());
   struct.setOrientationIsSet(true);
   struct.maxRows = iprot.readI64();
   struct.setMaxRowsIsSet(true);
 }
    public void write(org.apache.thrift.protocol.TProtocol oprot, TFetchResultsReq struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.operationHandle != null) {
        oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC);
        struct.operationHandle.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.orientation != null) {
        oprot.writeFieldBegin(ORIENTATION_FIELD_DESC);
        oprot.writeI32(struct.orientation.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(MAX_ROWS_FIELD_DESC);
      oprot.writeI64(struct.maxRows);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }