trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sureshsubbiah <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request: [TRAFODION-1444] Reduced pathlen...
Date Wed, 12 Aug 2015 00:53:35 GMT
Github user sureshsubbiah commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/52#discussion_r36817459
  
    --- Diff: core/sql/executor/HBaseClient_JNI.cpp ---
    @@ -2844,819 +2871,980 @@ HBC_RetCode HBaseClient_JNI::getHbaseTableInfo(const char* tblName,
       return HBC_OK;  // Table exists.
     }
     
    -
    -// ===========================================================================
    -// ===== Class HTableClient
    -// ===========================================================================
    -
    -JavaMethodInit* HTableClient_JNI::JavaMethods_ = NULL;
    -jclass HTableClient_JNI::javaClass_ = 0;
    -bool HTableClient_JNI::javaMethodsInitialized_ = false;
    -pthread_mutex_t HTableClient_JNI::javaMethodsInitMutex_ = PTHREAD_MUTEX_INITIALIZER;
    -
    -static const char* const htcErrorEnumStr[] = 
    -{
    -  "Preparing parameters for initConnection()."
    - ,"Java exception in initConnection()."
    - ,"Java exception in setTransactionID()."
    - ,"Java exception in cleanup()."
    - ,"Java exception in close()."
    - ,"Preparing parameters for scanOpen()."
    - ,"Java exception in scanOpen()."
    - ,"Java exception in fetchRows()."
    - ,"Java exception in scanClose()."
    - ,"Preparing parameters for getRowOpen()."
    - ,"Java exception in getRowOpen()."
    - ,"Preparing parameters for getRowsOpen()."
    - ,"Java exception in getRowsOpen()."
    - ,"Java exception in getClose()."
    - ,"Preparing parameters for deleteRow()."
    - ,"Java exception in deleteRow()."
    - ,"Preparing parameters for deleteRows()."
    - ,"Java exception in deleteRows()."
    - ,"Preparing parameters for checkAndDeleteRow()."
    - ,"Java exception in checkAndDeleteRow()."
    - ,"Row deleted in checkAndDeleteRow()."
    - ,"Preparing parameters for insertRow()."
    - ,"Java exception in insertRow()."
    - ,"Preparing parameters for insertRows()."
    - ,"Java exception in insertRows()."
    - ,"Preparing parameters for checkAndInsertRow()."
    - ,"Java exception in checkAndInsertRow()."
    - ,"Dup RowId in checkAndInsertRow()."
    - ,"Transactions not supported yet in checkAndInsertRow()"
    - ,"Preparing parameters for checkAndUpdateRow()."
    - ,"Java exception in checkAndUpdateRow()."
    - ,"Dup RowId in checkAndUpdateRow()."
    - ,"Transactions not supported yet in checkAndUpdateRow()"
    - ,"Preparing parameters for create()."
    - ,"Java exception in create()."
    - ,"Preparing parameters for drop()."
    - ,"Java exception in drop()."
    - ,"Preparing parameters for exists()."
    - ,"Java exception in exists()."
    - ,"Preparing parameters for coProcAggr()."
    - ,"Java exception in coProcAggr()."
    - ,"Preparing parameters for grant()."
    - ,"Java exception in grant()."
    - ,"Preparing parameters for revoke()."
    - ,"Java exception in revoke()."
    - ,"Java exception in getendkeys()."
    - ,"Java exception in getHTableName()."
    - ,"Java exception in flush()."
    - ,"Java exception in getColName()."
    - ,"Java exception in getColValue()."
    - ,"Java exception in getRowID()."
    - ,"Java exception in nextCell()."
    - ,"Preparing parameters for getRows()."
    - ,"Java exception in getRows()."
    - ,"Java exception in completeAsyncOperation()."
    - ,"Async Hbase Operation not yet complete."
    -};
    -
     //////////////////////////////////////////////////////////////////////////////
     // 
     //////////////////////////////////////////////////////////////////////////////
    -char* HTableClient_JNI::getErrorText(HTC_RetCode errEnum)
    +HBC_RetCode HBaseClient_JNI::insertRow(NAHeap *heap, const char *tableName,
    +      ExHbaseAccessStats *hbs, bool useTRex, Int64 transID, HbaseStr rowID,
    +      HbaseStr row, Int64 timestamp, bool checkAndPut, bool asyncOperation,
    +      HTableClient_JNI **outHtc)
     {
    -  if (errEnum < (HTC_RetCode)JOI_LAST)
    -    return JavaObjectInterface::getErrorText((JOI_RetCode)errEnum);
    -  else    
    -    return (char*)htcErrorEnumStr[errEnum-HTC_FIRST-1];
    -}
    +  
    +  HTableClient_JNI *htc = NULL;
     
    -//////////////////////////////////////////////////////////////////////////////
    -// 
    -//////////////////////////////////////////////////////////////////////////////
    -HTableClient_JNI::~HTableClient_JNI()
    -{
    -  //QRLogger::log(CAT_JNI_TOP, LL_DEBUG, "HTableClient destructor called.");
    -  cleanupResultInfo();
    -  if (tableName_ != NULL)
    -  {
    -     NADELETEBASIC(tableName_, heap_);
    +  if (asyncOperation) {
    +     HTableClient_JNI *htc = new (heap) HTableClient_JNI(heap, (jobject)-1);
    +     if (htc->init() != HTC_OK) {
    +         NADELETE(htc, HTableClient_JNI, heap);
    +         return HBC_ERROR_INSERTROW_EXCEPTION;
    +     }
    +     htc->setTableName(tableName);
    +     htc->setHbaseStats(hbs);
       }
    -  if (colNameAllocLen_ != 0)
    -     NADELETEBASIC(colName_, heap_);
    -  if (numCellsAllocated_ > 0)
    -  {
    -      NADELETEBASIC(p_kvValLen_, heap_);
    -      NADELETEBASIC(p_kvValOffset_, heap_);
    -      NADELETEBASIC(p_kvFamLen_, heap_);
    -      NADELETEBASIC(p_kvFamOffset_, heap_);
    -      NADELETEBASIC(p_kvQualLen_, heap_);
    -      NADELETEBASIC(p_kvQualOffset_, heap_);
    -      NADELETEBASIC(p_timestamp_, heap_);
    -      numCellsAllocated_ = 0;
    +  if (jenv_->PushLocalFrame(jniHandleCapacity_) != 0) {
    +    getExceptionDetails();
    +    if (htc != NULL) 
    +       NADELETE(htc, HTableClient_JNI, heap);
    +    return HBC_ERROR_INSERTROW_PARAM;
       }
    -}
    - 
    -//////////////////////////////////////////////////////////////////////////////
    -// 
    -//////////////////////////////////////////////////////////////////////////////
    -HTC_RetCode HTableClient_JNI::init()
    -{
    -  static char className[]="org/trafodion/sql/HBaseAccess/HTableClient";
    -  HTC_RetCode rc;
    -  
    -  if (isInitialized())
    -    return HTC_OK;
    +  jstring js_tblName = jenv_->NewStringUTF(tableName);
    +  if (js_tblName == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_INSERTROW_PARAM;
    +  }
    +  jbyteArray jba_rowID = jenv_->NewByteArray(rowID.len);
    +  if (jba_rowID == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_INSERTROW_PARAM;
    +  }
    +  jenv_->SetByteArrayRegion(jba_rowID, 0, rowID.len, (const jbyte*)rowID.val);
       
    -  if (javaMethodsInitialized_)
    -    return (HTC_RetCode)JavaObjectInterface::init(className, javaClass_, JavaMethods_,
(Int32)JM_LAST, javaMethodsInitialized_);
    -  else
    -  {
    -    pthread_mutex_lock(&javaMethodsInitMutex_);
    -    if (javaMethodsInitialized_)
    -    {
    -      pthread_mutex_unlock(&javaMethodsInitMutex_);
    -      return (HTC_RetCode)JavaObjectInterface::init(className, javaClass_, JavaMethods_,
(Int32)JM_LAST, javaMethodsInitialized_);
    -    }
    -    JavaMethods_ = new JavaMethodInit[JM_LAST];
    -    
    -    JavaMethods_[JM_CTOR       ].jm_name      = "<init>";
    -    JavaMethods_[JM_CTOR       ].jm_signature = "()V";
    -    JavaMethods_[JM_GET_ERROR  ].jm_name      = "getLastError";
    -    JavaMethods_[JM_GET_ERROR  ].jm_signature = "()Ljava/lang/String;";
    -    JavaMethods_[JM_SCAN_OPEN  ].jm_name      = "startScan";
    -    JavaMethods_[JM_SCAN_OPEN  ].jm_signature = "(J[B[B[Ljava/lang/Object;JZI[Ljava/lang/Object;[Ljava/lang/Object;[Ljava/lang/Object;FZZILjava/lang/String;Ljava/lang/String;II)Z";
    -    JavaMethods_[JM_GET_OPEN   ].jm_name      = "startGet";
    -    JavaMethods_[JM_GET_OPEN   ].jm_signature = "(J[B[Ljava/lang/Object;J)I";
    -    JavaMethods_[JM_GETS_OPEN  ].jm_name      = "startGet";
    -    JavaMethods_[JM_GETS_OPEN  ].jm_signature = "(J[Ljava/lang/Object;[Ljava/lang/Object;J)I";
    -    JavaMethods_[JM_DELETE     ].jm_name      = "deleteRow";
    -    JavaMethods_[JM_DELETE     ].jm_signature = "(J[B[Ljava/lang/Object;J)Z";
    -    JavaMethods_[JM_CHECKANDDELETE     ].jm_name      = "checkAndDeleteRow";
    -    JavaMethods_[JM_CHECKANDDELETE     ].jm_signature = "(J[B[B[BJ)Z";
    -    JavaMethods_[JM_CHECKANDUPDATE     ].jm_name      = "checkAndUpdateRow";
    -    JavaMethods_[JM_CHECKANDUPDATE     ].jm_signature = "(J[BLjava/lang/Object;[B[BJZ)Z";
    -    JavaMethods_[JM_COPROC_AGGR     ].jm_name      = "coProcAggr";
    -    JavaMethods_[JM_COPROC_AGGR     ].jm_signature = "(JI[B[B[B[BZI)[B";
    -    JavaMethods_[JM_GET_NAME   ].jm_name      = "getTableName";
    -    JavaMethods_[JM_GET_NAME   ].jm_signature = "()Ljava/lang/String;";
    -    JavaMethods_[JM_GET_HTNAME ].jm_name      = "getTableName";
    -    JavaMethods_[JM_GET_HTNAME ].jm_signature = "()Ljava/lang/String;";
    -    JavaMethods_[JM_GETENDKEYS ].jm_name      = "getEndKeys";
    -    JavaMethods_[JM_GETENDKEYS ].jm_signature = "()Lorg/trafodion/sql/HBaseAccess/ByteArrayList;";
    -    JavaMethods_[JM_FLUSHT     ].jm_name      = "flush";
    -    JavaMethods_[JM_FLUSHT     ].jm_signature = "()Z";
    -    JavaMethods_[JM_SET_WB_SIZE ].jm_name      = "setWriteBufferSize";
    -    JavaMethods_[JM_SET_WB_SIZE ].jm_signature = "(J)Z";
    -    JavaMethods_[JM_SET_WRITE_TO_WAL ].jm_name      = "setWriteToWAL";
    -    JavaMethods_[JM_SET_WRITE_TO_WAL ].jm_signature = "(Z)Z";
    -    JavaMethods_[JM_DIRECT_INSERT ].jm_name      = "insertRow";
    -    JavaMethods_[JM_DIRECT_INSERT ].jm_signature = "(J[BLjava/lang/Object;JZ)Z";
    -    JavaMethods_[JM_DIRECT_CHECKANDINSERT     ].jm_name      = "checkAndInsertRow";
    -    JavaMethods_[JM_DIRECT_CHECKANDINSERT     ].jm_signature = "(J[BLjava/lang/Object;JZ)Z";
    -    JavaMethods_[JM_DIRECT_INSERT_ROWS ].jm_name      = "putRows";
    -    JavaMethods_[JM_DIRECT_INSERT_ROWS ].jm_signature = "(JSLjava/lang/Object;Ljava/lang/Object;JZZ)Z";
    -    JavaMethods_[JM_DIRECT_DELETE_ROWS ].jm_name      = "deleteRows";
    -    JavaMethods_[JM_DIRECT_DELETE_ROWS ].jm_signature = "(JSLjava/lang/Object;J)Z";
    -    JavaMethods_[JM_FETCH_ROWS ].jm_name      = "fetchRows";
    -    JavaMethods_[JM_FETCH_ROWS ].jm_signature = "()I";
    -    JavaMethods_[JM_DIRECT_GET_ROWS ].jm_name      = "getRows";
    -    JavaMethods_[JM_DIRECT_GET_ROWS ].jm_signature = "(JSLjava/lang/Object;[Ljava/lang/Object;)I";
    -    JavaMethods_[JM_COMPLETE_PUT ].jm_name      = "completeAsyncOperation";
    -    JavaMethods_[JM_COMPLETE_PUT ].jm_signature = "(I[Z)Z";
    -   
    -    rc = (HTC_RetCode)JavaObjectInterface::init(className, javaClass_, JavaMethods_,
(Int32)JM_LAST, javaMethodsInitialized_);
    -    javaMethodsInitialized_ = TRUE;
    -    pthread_mutex_unlock(&javaMethodsInitMutex_);
    +  jobject jRow = jenv_->NewDirectByteBuffer(row.val, row.len);
    +  if (jRow == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_INSERTROW_PARAM;
       }
    -  return rc;
    -}
    -
    -//////////////////////////////////////////////////////////////////////////////
    -// 
    -//////////////////////////////////////////////////////////////////////////////
    -NAString HTableClient_JNI::getLastJavaError()
    -{
    -  return JavaObjectInterface::getLastJavaError(JavaMethods_[JM_GET_ERROR].methodID);
    +  jlong j_htc = (long)htc;
    +  jboolean j_useTRex = useTRex;
    +  jlong j_tid = transID;  
    +  jlong j_ts = timestamp;
    +  jboolean j_checkAndPut = checkAndPut;
    +  jboolean j_asyncOperation = asyncOperation;
    + 
    +  if (hbs)
    +    hbs->getTimer().start();
    +  tsRecentJMFromJNI = JavaMethods_[JM_HBC_DIRECT_INSERT_ROW].jm_full_name;
    +  jboolean jresult = jenv_->CallBooleanMethod(javaObj_, JavaMethods_[JM_HBC_DIRECT_INSERT_ROW].methodID,

    +               	j_htc, js_tblName, j_useTRex, j_tid, jba_rowID, jRow, j_ts, j_checkAndPut,
j_asyncOperation);
    +  if (hbs) {
    +      hbs->incHbaseCalls();
    +      if (!asyncOperation)
    +         hbs->incMaxHbaseIOTime(hbs->getTimer().stop());
    +  }
    +  if (jenv_->ExceptionCheck()) {
    +    getExceptionDetails();
    +    logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    +    logError(CAT_SQL_HBASE, "HBaseClient_JNI::insertRow()", getLastError());
    +    jenv_->PopLocalFrame(NULL);
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    return HBC_ERROR_INSERTROW_EXCEPTION;
    +  }
    +  if (hbs)
    +    hbs->incBytesRead(rowID.len + row.len);
    +  if (jresult == false) {
    +     jenv_->PopLocalFrame(NULL);
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +     return HBC_ERROR_INSERTROW_DUP_ROWID;
    +  }
    +  *outHtc = htc;
    +  jenv_->PopLocalFrame(NULL);
    +  return HBC_OK;
     }
     
     //////////////////////////////////////////////////////////////////////////////
     // 
     //////////////////////////////////////////////////////////////////////////////
    -HTC_RetCode HTableClient_JNI::startScan(Int64 transID, const Text& startRowID, 
    -   const Text& stopRowID, const LIST(HbaseStr) & cols, Int64 timestamp, 
    -   bool cacheBlocks, Lng32 numCacheRows, NABoolean preFetch,
    -					const LIST(NAString) *inColNamesToFilter, 
    -					const LIST(NAString) *inCompareOpList,
    -					const LIST(NAString) *inColValuesToCompare,
    -					Float32 samplePercent,
    -					NABoolean useSnapshotScan,
    -					Lng32 snapTimeout,
    -					char * snapName ,
    -					char * tmpLoc,
    -					Lng32 espNum,
    -                                        Lng32 versions)
    +HBC_RetCode HBaseClient_JNI::insertRows(NAHeap *heap, const char *tableName,
    +      ExHbaseAccessStats *hbs, bool useTRex, Int64 transID, short rowIDLen, HbaseStr
rowIDs,
    +      HbaseStr rows, Int64 timestamp, bool autoFlush, bool asyncOperation,
    +      HTableClient_JNI **outHtc)
     {
    -  QRLogger::log(CAT_SQL_HBASE, LL_DEBUG, "HTableClient_JNI::startScan() called.");
    +  
    +  HTableClient_JNI *htc = NULL;
     
    +  if (asyncOperation) {
    +     HTableClient_JNI *htc = new (heap) HTableClient_JNI(heap, (jobject)-1);
    +     if (htc->init() != HTC_OK) {
    +         NADELETE(htc, HTableClient_JNI, heap);
    +         return HBC_ERROR_INSERTROWS_EXCEPTION;
    +     }
    +     htc->setTableName(tableName);
    +     htc->setHbaseStats(hbs);
    +  }
       if (jenv_->PushLocalFrame(jniHandleCapacity_) != 0) {
         getExceptionDetails();
    -    return HTC_ERROR_SCANOPEN_EXCEPTION;
    +    if (htc != NULL) 
    +       NADELETE(htc, HTableClient_JNI, heap);
    +    return HBC_ERROR_INSERTROWS_PARAM;
       }
    -  int len = startRowID.size();
    -  jbyteArray jba_startRowID = jenv_->NewByteArray(len);
    -  if (jba_startRowID == NULL) 
    -  {
    -    GetCliGlobals()->setJniErrorStr(getErrorText(HTC_ERROR_SCANOPEN_PARAM));
    +  jstring js_tblName = jenv_->NewStringUTF(tableName);
    +  if (js_tblName == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROWS_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
         jenv_->PopLocalFrame(NULL);
    -    return HTC_ERROR_SCANOPEN_PARAM;
    +    return HBC_ERROR_INSERTROWS_PARAM;
       }
    -  jenv_->SetByteArrayRegion(jba_startRowID, 0, len, (const jbyte*)startRowID.data());
    -
    -  len = stopRowID.size();
    -  jbyteArray jba_stopRowID = jenv_->NewByteArray(len);
    -  if (jba_stopRowID == NULL) 
    -  {
    -    GetCliGlobals()->setJniErrorStr(getErrorText(HTC_ERROR_SCANOPEN_PARAM));
    -    jenv_->DeleteLocalRef(jba_startRowID);
    +  jobject jRowIDs = jenv_->NewDirectByteBuffer(rowIDs.val, rowIDs.len);
    +  if (jRowIDs == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROWS_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
         jenv_->PopLocalFrame(NULL);
    -    return HTC_ERROR_SCANOPEN_PARAM;
    +    return HBC_ERROR_INSERTROWS_PARAM;
       }
    -  jenv_->SetByteArrayRegion(jba_stopRowID, 0, len, (const jbyte*)stopRowID.data());
    -
    -  jobjectArray j_cols = NULL;
    -  if (!cols.isEmpty())
    -  {
    -    j_cols = convertToByteArrayObjectArray(cols);
    -    if (j_cols == NULL)
    -    {
    -       getExceptionDetails();
    -       logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -       logError(CAT_SQL_HBASE, "HTableClient_JNI::startScan()", getLastError());
    -       jenv_->DeleteLocalRef(jba_startRowID);
    -       jenv_->DeleteLocalRef(jba_stopRowID);
    -       jenv_->PopLocalFrame(NULL);
    -       return HTC_ERROR_SCANOPEN_PARAM;
    -    }
    -    numColsInScan_ = cols.entries();
    +  
    +  jobject jRows = jenv_->NewDirectByteBuffer(rows.val, rows.len);
    +  if (jRows == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_INSERTROWS_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_INSERTROWS_PARAM;
       }
    -  else
    -     numColsInScan_ = 0;
    +  jboolean j_useTRex = useTRex;
       jlong j_tid = transID;  
       jlong j_ts = timestamp;
    -
    -  jboolean j_cb = cacheBlocks;
    -  jboolean j_preFetch = preFetch;
    -  jint j_ncr = numCacheRows;
    -  numReqRows_ = numCacheRows;
    -  currentRowNum_ = -1;
    -  currentRowCellNum_ = -1;
    -
    -  jobjectArray j_colnamestofilter = NULL;
    -  if ((inColNamesToFilter) && (!inColNamesToFilter->isEmpty()))
    -  {
    -    j_colnamestofilter = convertToByteArrayObjectArray(*inColNamesToFilter);
    -    if (j_colnamestofilter == NULL)
    -    {
    -       getExceptionDetails();
    -       logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -       logError(CAT_SQL_HBASE, "HTableClient_JNI::startScan()", getLastError());
    -       jenv_->DeleteLocalRef(jba_startRowID);
    -       jenv_->DeleteLocalRef(jba_stopRowID);
    -       if (j_cols != NULL)
    -           jenv_->DeleteLocalRef(j_cols);
    -       jenv_->PopLocalFrame(NULL);
    -       return HTC_ERROR_SCANOPEN_PARAM;
    -    }
    -  }
    -
    -  jobjectArray j_compareoplist = NULL;
    -  if ((inCompareOpList) && (! inCompareOpList->isEmpty()))
    -  {
    -     j_compareoplist = convertToByteArrayObjectArray(*inCompareOpList);
    -     if (j_compareoplist == NULL)
    -     {
    -        getExceptionDetails();
    -        logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -        logError(CAT_SQL_HBASE, "HTableClient_JNI::startScan()", getLastError());
    -        jenv_->DeleteLocalRef(jba_startRowID);
    -        jenv_->DeleteLocalRef(jba_stopRowID);
    -        if (j_cols != NULL)
    -           jenv_->DeleteLocalRef(j_cols);
    -        if (j_colnamestofilter != NULL)
    -           jenv_->DeleteLocalRef(j_colnamestofilter);
    -        jenv_->PopLocalFrame(NULL);
    -        return HTC_ERROR_SCANOPEN_PARAM;
    -     }
    -  }
    -
    -  jobjectArray j_colvaluestocompare = NULL;
    -  if ((inColValuesToCompare) && (!inColValuesToCompare->isEmpty()))
    -  {
    -     j_colvaluestocompare = convertToByteArrayObjectArray(*inColValuesToCompare);
    -     if (j_colvaluestocompare == NULL)
    -     {
    -        getExceptionDetails();
    -        logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -        logError(CAT_SQL_HBASE, "HTableClient_JNI::startScan()", getLastError());
    -        jenv_->DeleteLocalRef(jba_startRowID);
    -        jenv_->DeleteLocalRef(jba_stopRowID);
    -        if (j_cols != NULL)
    -           jenv_->DeleteLocalRef(j_cols);
    -        if (j_colnamestofilter != NULL)
    -           jenv_->DeleteLocalRef(j_colnamestofilter);
    -        if (j_compareoplist != NULL)
    -           jenv_->DeleteLocalRef(j_compareoplist);
    -        jenv_->PopLocalFrame(NULL);
    -        return HTC_ERROR_SCANOPEN_PARAM;
    -     }
    -  }
    -  jfloat j_smplPct = samplePercent;
    -  jboolean j_useSnapshotScan = useSnapshotScan;
    -  jint j_snapTimeout = snapTimeout;
    -  jint j_espNum = espNum;
    -  jint j_versions = versions;
    -
    -  jstring js_snapName = jenv_->NewStringUTF(snapName != NULL ? snapName : "Dummy");
    -   if (js_snapName == NULL)
    -   {
    -     GetCliGlobals()->setJniErrorStr(getErrorText(HTC_ERROR_SCANOPEN_PARAM));
    -     jenv_->PopLocalFrame(NULL);
    -     return HTC_ERROR_SCANOPEN_PARAM;
    -   }
    -  jstring js_tmp_loc = jenv_->NewStringUTF(tmpLoc != NULL ? tmpLoc : "Dummy");
    -   if (js_tmp_loc == NULL)
    -   {
    -     GetCliGlobals()->setJniErrorStr(getErrorText(HTC_ERROR_SCANOPEN_PARAM));
    -     //delete the previous string in case of error
    -     jenv_->DeleteLocalRef(js_snapName);
    -     jenv_->PopLocalFrame(NULL);
    -     return HTC_ERROR_SCANOPEN_PARAM;
    -   }
    -
    -  if (hbs_)
    -      hbs_->getTimer().start();
    -
    -  tsRecentJMFromJNI = JavaMethods_[JM_SCAN_OPEN].jm_full_name;
    -  jboolean jresult = jenv_->CallBooleanMethod(
    -                                              javaObj_, 
    -                                              JavaMethods_[JM_SCAN_OPEN].methodID, 
    -                                              j_tid, jba_startRowID, jba_stopRowID, j_cols,
j_ts, j_cb, j_ncr,
    -                                              j_colnamestofilter, j_compareoplist, j_colvaluestocompare,

    -                                              j_smplPct, j_preFetch, j_useSnapshotScan,
    -                                              j_snapTimeout, js_snapName, js_tmp_loc,
j_espNum,
    -                                              j_versions);
    -
    -  if (hbs_)
    -  {
    -    hbs_->incMaxHbaseIOTime(hbs_->getTimer().stop());
    -    hbs_->incHbaseCalls();
    +  jlong j_htc = (long)htc;
    +  jshort j_rowIDLen = rowIDLen;
    +  jboolean j_af = autoFlush;
    +  jboolean j_asyncOperation = asyncOperation;
    + 
    +  if (hbs)
    +    hbs->getTimer().start();
    +  tsRecentJMFromJNI = JavaMethods_[JM_HBC_DIRECT_INSERT_ROWS].jm_full_name;
    +  jboolean jresult = jenv_->CallBooleanMethod(javaObj_, JavaMethods_[JM_HBC_DIRECT_INSERT_ROWS].methodID,

    +               	j_htc, js_tblName, j_useTRex, j_tid, j_rowIDLen, jRowIDs, jRows, j_ts,
j_af, j_asyncOperation);
    +  if (hbs) {
    +      hbs->incHbaseCalls();
    +      if (!asyncOperation)
    +         hbs->incMaxHbaseIOTime(hbs->getTimer().stop());
       }
    -
    -  jenv_->DeleteLocalRef(jba_startRowID);  
    -  jenv_->DeleteLocalRef(jba_stopRowID);  
    -  if (j_cols != NULL)
    -     jenv_->DeleteLocalRef(j_cols);
    -  if (j_colnamestofilter != NULL)
    -     jenv_->DeleteLocalRef(j_colnamestofilter);
    -  if (j_compareoplist != NULL)
    -     jenv_->DeleteLocalRef(j_compareoplist);
    -  if (j_colvaluestocompare != NULL)
    -     jenv_->DeleteLocalRef(j_colvaluestocompare);
    -  if (js_tmp_loc!= NULL)
    -    jenv_->DeleteLocalRef(js_tmp_loc);
    -  if (js_snapName!= NULL)
    -    jenv_->DeleteLocalRef(js_snapName);
    -  if (jenv_->ExceptionCheck())
    -  {
    +  if (jenv_->ExceptionCheck()) {
         getExceptionDetails();
         logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -    logError(CAT_SQL_HBASE, "HTableClient_JNI::scanOpen()", getLastError());
    +    logError(CAT_SQL_HBASE, "HBaseClient_JNI::insertRows()", getLastError());
         jenv_->PopLocalFrame(NULL);
    -    return HTC_ERROR_SCANOPEN_EXCEPTION;
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    return HBC_ERROR_INSERTROWS_EXCEPTION;
       }
    -
    -  if (jresult == false) 
    -  {
    -    logError(CAT_SQL_HBASE, "HTableClient_JNI::scanOpen()", getLastError());
    +  if (jresult == false) {
    +    logError(CAT_SQL_HBASE, "HBaseClient_JNI::insertRows()", getLastError());
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
         jenv_->PopLocalFrame(NULL);
    -    return HTC_ERROR_SCANOPEN_EXCEPTION;
    +    return HBC_ERROR_INSERTROWS_EXCEPTION;
       }
    -  fetchMode_ = SCAN_FETCH;
    +  if (hbs)
    +    hbs->incBytesRead(rowIDs.len + rows.len);
    +  *outHtc = htc;
       jenv_->PopLocalFrame(NULL);
    -  return HTC_OK;
    +  return HBC_OK;
     }
    -
    +//
     //////////////////////////////////////////////////////////////////////////////
     // 
     //////////////////////////////////////////////////////////////////////////////
    -HTC_RetCode HTableClient_JNI::startGet(Int64 transID, const HbaseStr& rowID, 
    -      const LIST(HbaseStr) & cols, Int64 timestamp)
    +HBC_RetCode HBaseClient_JNI::checkAndUpdateRow(NAHeap *heap, const char *tableName,
    +      ExHbaseAccessStats *hbs, bool useTRex, Int64 transID, HbaseStr rowID,
    +      HbaseStr row, HbaseStr columnToCheck, HbaseStr columnValToCheck,
    +       Int64 timestamp, bool asyncOperation,
    +      HTableClient_JNI **outHtc)
     {
    -  QRLogger::log(CAT_SQL_HBASE, LL_DEBUG, "HTableClient_JNI::startGet(%s) called.", rowID.val);
    +  
    +  HTableClient_JNI *htc = NULL;
     
    +  if (asyncOperation) {
    +     HTableClient_JNI *htc = new (heap) HTableClient_JNI(heap, (jobject)-1);
    +     if (htc->init() != HTC_OK) {
    +         NADELETE(htc, HTableClient_JNI, heap);
    +         return HBC_ERROR_CHECKANDUPDATEROW_EXCEPTION;
    +     }
    +     htc->setTableName(tableName);
    +     htc->setHbaseStats(hbs);
    +  }
       if (jenv_->PushLocalFrame(jniHandleCapacity_) != 0) {
         getExceptionDetails();
    -    return HTC_ERROR_GETROWOPEN_EXCEPTION;
    +    if (htc != NULL) 
    +       NADELETE(htc, HTableClient_JNI, heap);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
       }
    -  int len = rowID.len;
    -  jbyteArray jba_rowID = jenv_->NewByteArray(len);
    -  if (jba_rowID == NULL) 
    -  {
    -     GetCliGlobals()->setJniErrorStr(getErrorText(HTC_ERROR_GETROWOPEN_PARAM));
    -     jenv_->PopLocalFrame(NULL);
    -     return HTC_ERROR_GETROWOPEN_PARAM;
    +  jstring js_tblName = jenv_->NewStringUTF(tableName);
    +  if (js_tblName == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_CHECKANDUPDATEROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
       }
    -  jenv_->SetByteArrayRegion(jba_rowID, 0, len, (const jbyte*)rowID.val);
    -  jobjectArray j_cols = NULL;
    -  if (!cols.isEmpty())
    -  {
    -     j_cols = convertToByteArrayObjectArray(cols);
    -     if (j_cols == NULL)
    -     {
    -        getExceptionDetails();
    -        logError(CAT_SQL_HBASE, __FILE__, __LINE__);
    -        logError(CAT_SQL_HBASE, "HTableClient_JNI::startGet()", getLastError());
    -        jenv_->DeleteLocalRef(jba_rowID);
    -        jenv_->PopLocalFrame(NULL);
    -        return HTC_ERROR_GETROWOPEN_PARAM;
    -     }  
    -     numColsInScan_ = cols.entries();
    +  jbyteArray jba_rowID = jenv_->NewByteArray(rowID.len);
    +  if (jba_rowID == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_CHECKANDUPDATEROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
       }
    -  else
    -     numColsInScan_ = 0;
    -  numReqRows_ = 1;
    -  jlong j_tid = transID;  
    -  jlong j_ts = timestamp;
    +  jenv_->SetByteArrayRegion(jba_rowID, 0, rowID.len, (const jbyte*)rowID.val);
       
    -  if (hbs_)
    -    hbs_->getTimer().start();
    -  tsRecentJMFromJNI = JavaMethods_[JM_GET_OPEN].jm_full_name;
    -  jint jresult = jenv_->CallIntMethod(javaObj_, 
    -            JavaMethods_[JM_GET_OPEN].methodID, j_tid, jba_rowID, 
    -            j_cols, j_ts);
    -  if (hbs_)
    -    {
    -      hbs_->incMaxHbaseIOTime(hbs_->getTimer().stop());
    -      hbs_->incHbaseCalls();
    -    }
    +  jobject jRow = jenv_->NewDirectByteBuffer(row.val, row.len);
    +  if (jRow == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_CHECKANDUPDATEROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
    +  }
     
    -  jenv_->DeleteLocalRef(jba_rowID);  
    -  if (j_cols != NULL)
    -     jenv_->DeleteLocalRef(j_cols);
    +  jbyteArray jba_columnToCheck = jenv_->NewByteArray(columnToCheck.len);
    +  if (jba_columnToCheck == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_CHECKANDUPDATEROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
    +  }
    +  jenv_->SetByteArrayRegion(jba_columnToCheck, 0, columnToCheck.len, (const jbyte*)columnToCheck.val);
     
    -  if (jenv_->ExceptionCheck())
    -  {
    +  jbyteArray jba_columnValToCheck = jenv_->NewByteArray(columnValToCheck.len);
    +  if (jba_columnValToCheck == NULL) {
    +    GetCliGlobals()->setJniErrorStr(getErrorText(HBC_ERROR_CHECKANDUPDATEROW_PARAM));
    +    if (htc != NULL)
    +        NADELETE(htc, HTableClient_JNI, heap);
    +    jenv_->PopLocalFrame(NULL);
    +    return HBC_ERROR_CHECKANDUPDATEROW_PARAM;
    +  }
    +  jenv_->SetByteArrayRegion(jba_columnValToCheck, 0, columnValToCheck.len, (const
jbyte*)columnValToCheck.val);
    +  jlong j_htc = (long)htc;
    +  jboolean j_useTRex = useTRex;
    +  jlong j_tid = transID;  
    +  jlong j_ts = timestamp;
    +  jboolean j_asyncOperation = asyncOperation;
    + 
    +  if (hbs)
    +    hbs->getTimer().start();
    +  tsRecentJMFromJNI = JavaMethods_[JM_HBC_DIRECT_CHECKANDUPDATE_ROW].jm_full_name;
    --- End diff --
    
    What is line 3138 for?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message