int ObTransferSSTableQuery::get(const ObGetParam& get_param, 
                                    ObSSTableReader& reader,
                                    ObIterator* iterator)
    {
      int ret                         = OB_SUCCESS;
      int64_t cell_size               = get_param.get_cell_size();
      int64_t row_size                = get_param.get_row_size();
      ObSSTableGetter* sstable_getter = dynamic_cast<ObSSTableGetter*>(iterator);
      const ObGetParam::ObRowIndex* row_index = get_param.get_row_index();
      static __thread const ObSSTableReader* sstable_reader = NULL;

      if (!inited_)
      {
        TBSYS_LOG(WARN, "transfer sstable query has not inited");
        ret = OB_ERROR;
      }
      else if (cell_size <= 0 || NULL == row_index || row_size <= 0
               || row_size > OB_MAX_GET_ROW_NUMBER)
      {
        TBSYS_LOG(WARN, "invalid get param, cell_size=%ld, row_index=%p, row_size=%ld",
                  cell_size, row_index, row_size);
        ret = OB_INVALID_ARGUMENT;
      }
      else if (NULL == sstable_getter)
      {
        TBSYS_LOG(WARN, "get thread local instance of sstable getter failed");
        ret = OB_ERROR;
      }

      if (OB_SUCCESS == ret)
      {
        if (!reader.empty())
        {
          sstable_reader = &reader;
        }
        else
        {
          sstable_reader = NULL;
        }

        ret = sstable_getter->init(block_cache_, block_index_cache_, 
                                   get_param, &sstable_reader, 1, true,
                                   sstable_row_cache_);
        if (OB_SUCCESS != ret)
        {
          TBSYS_LOG(WARN, "failed to init sstable getter, ret=%d", ret);
        }
        else
        {
          // do nothing
        }
      }

      return ret;
    }
Ejemplo n.º 2
0
    int ObGetScanProxy::get_compact_scanner(const ObGetParam& get_param,
                                            ObScanner& orig_scanner,ObScanner& compact_scanner)
    {
      ObTabletManager::ObGetThreadContext*& get_context = tablet_manager_.get_cur_thread_get_contex();
      const ObGetParam::ObRowIndex* row_index           = get_param.get_row_index();      
      int64_t row_num                                   = orig_scanner.get_row_num();
      ColumnFilter* cf                                  = GET_TSI_MULT(ColumnFilter,TSI_CS_COLUMNFILTER_1);      
      ObTablet* tablet                                  = NULL;
      int ret                                           = OB_SUCCESS;      
      ObRowkey rowkey;

      if ((NULL == get_context) || (NULL == row_index) || (NULL == cf))
      {
        TBSYS_LOG(WARN,"get thread context of get failed");
        ret = OB_ERROR;
      }
      else
      {
        int64_t compactsstable_version = get_context->min_compactsstable_version_;
        if (ObVersion::compare(compactsstable_version,orig_scanner.get_data_version()) > 0)
        {
          compact_scanner.set_data_version(compactsstable_version);
          for(int64_t i=0; (i < row_num) && (OB_SUCCESS == ret); ++i)
          {
            tablet = get_context->tablets_[i];
            rowkey = get_param[row_index[i].offset_]->row_key_;

            build_get_column_filter(get_param,row_index[i].offset_,row_index[i].size_,*cf);

            if ((tablet != NULL) &&
                (ret = get_compact_row(*tablet,rowkey,compactsstable_version,cf,compact_scanner)) != OB_SUCCESS)
            {
              TBSYS_LOG(WARN,"get data from compactsstable failed,ret=%d",ret);
            }
          }
        }
      }
      return ret;
    }