int ObGetScanProxy::cs_get(const ObGetParam& get_param, ObScanner& scanner, 
                               ObIterator* it_out[],int64_t& it_size)
    {
      int ret = OB_SUCCESS;
      int64_t idx = 0;
      if (NULL == it_out || it_size <= 0)
      {
        ret = OB_INVALID_ARGUMENT;
      }

      if (OB_SUCCESS == ret)
      {
        ret = tablet_manager_.get(get_param, scanner);
      }

      //ms depend on OB_CS_TABLET_NOT_EXIST return value
      if (OB_SUCCESS != ret && OB_CS_TABLET_NOT_EXIST != ret)
      {
        TBSYS_LOG(WARN, "failed to get data from local chunk server, ret=%d", ret);
      }
      else
      {
        it_out[idx++] = &scanner;
      }

      if (OB_SUCCESS == ret)
      {
        ObScanner* compact_scanner = GET_TSI_MULT(ObScanner,TSI_CS_COMPACTSSTABLE_GET_SCANEER_1);
        if (NULL == compact_scanner)
        {
          TBSYS_LOG(WARN,"alloc scanner failed"); //just warn
        }
        else
        {
          compact_scanner->reset();
          if ((ret = get_compact_scanner(get_param,scanner,*compact_scanner)) != OB_SUCCESS )
          {
            TBSYS_LOG(WARN,"get data from compact sstable failed,err=%d",ret);
          }
          else if (idx < it_size)
          {
            if (!compact_scanner->is_empty())
            {
              it_out[idx++] = compact_scanner;
            }
            int64_t compact_version = compact_scanner->get_data_version();
            if (compact_version > 0)
            {
              scanner.set_data_version(compact_version);
            }            
          }
        }
      }

      it_size = idx;

      return ret;
    }
    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;
    }
Example #3
0
TEST(TestObScanner, add_cell)
{
  ObScanner fem;
  fem.set_is_req_fullfilled(true, 1011);
  fem.set_data_version(170);

  char buf[BUFSIZ];
  int64_t pospos = 0;
  fem.serialize(buf, BUFSIZ, pospos);

  FILE *fd;
  fd = fopen("tmptest", "w+");
  fwrite(buf, 1, pospos, fd);
  fclose(fd);

  ObScanner os;
  ObScanner ost;
  /*** added by wushi ***/
  int64_t fullfilled_item = 0;
  int64_t tmp = 0;
  bool is_fullfilled = true;
  bool tmp_bool = false;
  /// initialize
  ASSERT_EQ(os.get_is_req_fullfilled(tmp_bool, fullfilled_item),0);
  EXPECT_FALSE(tmp_bool);
  ASSERT_EQ(fullfilled_item,0);
  /// set fullfilled
  is_fullfilled = true;
  fullfilled_item = 1000;
  os.set_is_req_fullfilled(is_fullfilled,fullfilled_item);
  ASSERT_EQ(os.get_is_req_fullfilled(tmp_bool, tmp),0);
  ASSERT_EQ(tmp_bool,is_fullfilled);
  ASSERT_EQ(tmp,fullfilled_item);

  /*** added by wushi ***/

  ObCellInfo oci;

  oci.table_name_.assign((char*)"table1", 6);
  oci.row_key_.assign((char*)"row1", 4);
  oci.column_name_.assign((char*)"column1", 7);
  oci.value_.set_int(0xff);

  ost.set_mem_size_limit(20);
  ASSERT_EQ(OB_SIZE_OVERFLOW, ost.add_cell(oci));
  os.set_mem_size_limit(1024 * 1024 * 2);
  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  oci.column_name_.assign((char*)"column2", 7);
  oci.value_.set_int(0xfe);
  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  ObScannerIterator iter = os.begin();
  ObCellInfo tci;
  ASSERT_EQ(OB_SUCCESS, iter.get_cell(tci));

  ASSERT_EQ(string("table1"), string(tci.table_name_.ptr(), tci.table_name_.length()));
  ASSERT_EQ(string("row1"), string(tci.row_key_.ptr(), tci.row_key_.length()));
  ASSERT_EQ(string("column1"), string(tci.column_name_.ptr(), tci.column_name_.length()));
  ASSERT_EQ(OB_SUCCESS, tci.value_.get_int(tmp));
  ASSERT_EQ(0xff, tmp);

  iter++;
  ASSERT_EQ(OB_SUCCESS, iter.get_cell(tci));

  ASSERT_EQ(string("table1"), string(tci.table_name_.ptr(), tci.table_name_.length()));
  ASSERT_EQ(string("row1"), string(tci.row_key_.ptr(), tci.row_key_.length()));
  ASSERT_EQ(string("column2"), string(tci.column_name_.ptr(), tci.column_name_.length()));
  ASSERT_EQ(OB_SUCCESS, tci.value_.get_int(tmp));
  ASSERT_EQ(0xfe, tmp);

  iter++;

  ASSERT_EQ(true, os.end() == iter);

  //ObCellInfo oci;
  char row_key_buffer[1024];

  oci.table_name_.assign((char*)"table1", 6);
  sprintf(row_key_buffer, "row1");
  oci.row_key_.assign(row_key_buffer, 4);
  oci.column_name_.assign((char*)"column1", 7);
  oci.value_.set_int(0xff);

  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  oci.table_name_.assign((char*)"table1", 6);
  sprintf(row_key_buffer, "row1");
  oci.row_key_.assign(row_key_buffer, 4);
  oci.column_name_.assign((char*)"column2", 7);
  oci.value_.set_int(0xee);

  os.set_mem_size_limit(20);
  ASSERT_EQ(OB_SIZE_OVERFLOW, os.add_cell(oci));
  os.set_mem_size_limit(1024 * 1024 * 2);
  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  oci.table_name_.assign((char*)"table1", 6);
  sprintf(row_key_buffer, "row2");
  oci.row_key_.assign(row_key_buffer, 4);
  oci.column_name_.assign((char*)"column1", 7);
  oci.value_.set_int(0xdd);

  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  oci.table_name_.assign((char*)"table2", 6);
  sprintf(row_key_buffer, "row2");
  oci.row_key_.assign(row_key_buffer, 4);
  oci.column_name_.assign((char*)"column1", 7);
  oci.value_.set_int(0xcc);

  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  oci.table_name_.assign((char*)"table3", 6);
  sprintf(row_key_buffer, "row2");
  oci.row_key_.assign(row_key_buffer, 4);
  oci.column_name_.assign((char*)"column1", 7);
  oci.value_.set_int(0xbb);

  ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));

  fprintf(stdout, "size=%ld\n", os.get_serialize_size());
  char buffer[2048];
  int64_t pos = 0;
  ASSERT_EQ(OB_SUCCESS, os.serialize(buffer, 1024, pos));
  ASSERT_EQ(pos, os.get_serialize_size());
  fd = fopen("./test.data.before_rollback", "w+");
  fwrite(buffer, 1, 1024, fd);
  fclose(fd);

  for (iter = os.begin(); iter != os.end(); iter++)
  {
    ObCellInfo ci;
    ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
        ci.table_name_.length(), ci.table_name_.ptr(),
        ci.row_key_.length(), ci.row_key_.ptr(),
        ci.column_name_.length(), ci.column_name_.ptr());
  }
  fprintf(stdout, "==============================\n");
  while (OB_SUCCESS == os.next_cell())
  {
    ObCellInfo *ci = NULL;
    bool is_row_changed;
    ASSERT_EQ(OB_SUCCESS, os.get_cell(&ci, &is_row_changed));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s] "
            "table_id=[%lu] column_id=[%lu] row_changed=[%d]\n",
            ci->table_name_.length(), ci->table_name_.ptr(),
            ci->row_key_.length(), ci->row_key_.ptr(),
            ci->column_name_.length(),ci->column_name_.ptr(),
            ci->table_id_, ci->column_id_, is_row_changed);
  }
  os.reset_iter();
  fprintf(stdout, "==============================\n");

  ASSERT_EQ(OB_SUCCESS, os.rollback());

  fprintf(stdout, "size=%ld\n", os.get_serialize_size());
  pos = 0;
  ASSERT_EQ(OB_SUCCESS, os.serialize(buffer, 1024, pos));
  ASSERT_EQ(pos, os.get_serialize_size());
  fd = fopen("./test.data.after_rollback", "w+");
  fwrite(buffer, 1, 1024, fd);
  fclose(fd);

  for (iter = os.begin(); iter != os.end(); iter++)
  {
    ObCellInfo ci;
    ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
        ci.table_name_.length(), ci.table_name_.ptr(),
        ci.row_key_.length(), ci.row_key_.ptr(),
        ci.column_name_.length(), ci.column_name_.ptr());
    ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
        ci.table_name_.length(), ci.table_name_.ptr(),
        ci.row_key_.length(), ci.row_key_.ptr(),
        ci.column_name_.length(), ci.column_name_.ptr());
  }
  fprintf(stdout, "==============================\n");
  while (OB_SUCCESS == os.next_cell())
  {
    ObCellInfo *ci = NULL;
    bool is_row_changed;
    ASSERT_EQ(OB_SUCCESS, os.get_cell(&ci, &is_row_changed));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s] "
            "table_id=[%lu] column_id=[%lu] row_changed=[%d]\n",
            ci->table_name_.length(), ci->table_name_.ptr(),
            ci->row_key_.length(), ci->row_key_.ptr(),
            ci->column_name_.length(),ci->column_name_.ptr(),
            ci->table_id_, ci->column_id_, is_row_changed);
    ASSERT_EQ(OB_SUCCESS, os.get_cell(&ci, &is_row_changed));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s] "
            "table_id=[%lu] column_id=[%lu] row_changed=[%d]\n",
            ci->table_name_.length(), ci->table_name_.ptr(),
            ci->row_key_.length(), ci->row_key_.ptr(),
            ci->column_name_.length(),ci->column_name_.ptr(),
            ci->table_id_, ci->column_id_, is_row_changed);
  }
  os.reset_iter();
  fprintf(stdout, "==============================\n");

  pos = 0;
  ASSERT_EQ(OB_SUCCESS, os.deserialize(buffer, os.get_serialize_size(), pos));
  ASSERT_EQ(pos, os.get_serialize_size());

  for (iter = os.begin(); iter != os.end(); iter++)
  {
    ObCellInfo ci;
    ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
        ci.table_name_.length(), ci.table_name_.ptr(),
        ci.row_key_.length(), ci.row_key_.ptr(),
        ci.column_name_.length(), ci.column_name_.ptr());
    ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
        ci.table_name_.length(), ci.table_name_.ptr(),
        ci.row_key_.length(), ci.row_key_.ptr(),
        ci.column_name_.length(), ci.column_name_.ptr());
  }
  fprintf(stdout, "==============================\n");
  while (OB_SUCCESS == os.next_cell())
  {
    ObCellInfo *ci = NULL;
    bool is_row_changed;
    ASSERT_EQ(OB_SUCCESS, os.get_cell(&ci, &is_row_changed));
    fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s] "
            "table_id=[%lu] column_id=[%lu] row_changed=[%d]\n",
            ci->table_name_.length(), ci->table_name_.ptr(),
            ci->row_key_.length(), ci->row_key_.ptr(),
            ci->column_name_.length(),ci->column_name_.ptr(),
            ci->table_id_, ci->column_id_, is_row_changed);
  }
  os.reset_iter();

  /// set fullfilled
//  ASSERT_EQ(os.get_is_req_fullfilled(tmp_bool, tmp),0);
//  ASSERT_EQ(tmp_bool,is_fullfilled);
//  ASSERT_EQ(tmp,fullfilled_item);
  {
    ObRange range;
    range.border_flag_.set_inclusive_start();
    range.start_key_.assign((char*)"11111", 5);
    range.end_key_.assign((char*)"22222", 5);
    ObRange range2;
    range2.border_flag_.set_inclusive_start();
    range2.start_key_.assign((char*)"11111", 5);
    range2.end_key_.assign((char*)"22222", 5);

    int64_t pos = 0;
    int64_t data_len = 0;
    is_fullfilled = true;
    fullfilled_item = 1212;
    ObScanner os1;
    ObScanner os2;
    ASSERT_EQ(os1.set_is_req_fullfilled(is_fullfilled, fullfilled_item),0);
    os1.set_data_version(100);
    ASSERT_EQ(os1.set_range(range),0);
    range.border_flag_.set_inclusive_end();
    char buf[1024];
    ASSERT_EQ(os1.serialize(buf,sizeof(buf),pos),0);
    data_len = pos;
    pos = 0;
    ASSERT_EQ(os2.deserialize(buf, data_len, pos),0);
    memset(buf, 0x00, 1024);

    ASSERT_EQ(os2.get_is_req_fullfilled(tmp_bool, tmp),0);
    EXPECT_EQ(is_fullfilled, tmp_bool);
    ASSERT_EQ(fullfilled_item, tmp);
    ASSERT_EQ(os1.get_data_version(),100);

    ObRange range3;
    ASSERT_EQ(OB_SUCCESS, os2.get_range(range3));
    ASSERT_EQ(range2.border_flag_.get_data(), range3.border_flag_.get_data());
    ASSERT_EQ(string(range3.start_key_.ptr(), range3.start_key_.length()),
              string(range2.start_key_.ptr(), range2.start_key_.length()));
    ASSERT_EQ(string(range3.end_key_.ptr(), range3.end_key_.length()),
              string(range2.end_key_.ptr(), range2.end_key_.length()));

    const int times = 1000000;
    ObScanner os3;
    ObCellInfo cinull;
    cinull.table_name_.assign((char*)"hello", 5);
    cinull.value_.set_ext(ObActionFlag::OP_INSERT);
    ASSERT_EQ(OB_ERROR, os3.add_cell(cinull));
    cinull.value_.set_ext(ObActionFlag::OP_DEL_ROW);
    ASSERT_EQ(OB_SUCCESS, os3.add_cell(cinull));
    cinull.value_.set_ext(ObActionFlag::OP_ROW_DOES_NOT_EXIST);
    ASSERT_EQ(OB_SUCCESS, os3.add_cell(cinull));
    int i = 0;
    for (; i < times; i++)
    {
      if (OB_SUCCESS != os3.add_cell(oci))
      {
        break;
      }
    }
    const int64_t buf_len = 1 << 22;
    char* buff = (char*)ob_malloc(buf_len);
    int64_t ppos = 0;
    int64_t len = os3.get_serialize_size();
    ASSERT_EQ(OB_BUF_NOT_ENOUGH, os3.serialize(buff, len - 4, ppos));
    ASSERT_EQ(OB_SUCCESS, os3.serialize(buff, buf_len, ppos));

    int64_t npos = 0;
    ObScanner os4;
    ASSERT_EQ(OB_ERROR, os4.deserialize(buff, 10, npos));
    ASSERT_EQ(OB_SUCCESS, os4.deserialize(buff, ppos, npos));
    ASSERT_EQ(npos, ppos);
    int64_t otmp;
    oci.value_.get_int(otmp);
    ObCellInfo *oo;
    int t = 0;
    ASSERT_EQ(OB_SUCCESS, os4.next_cell());
    ASSERT_EQ(OB_SUCCESS, os4.get_cell(&oo));
    ASSERT_EQ(0, oo->row_key_.length());
    ASSERT_EQ(string(cinull.table_name_.ptr(), cinull.table_name_.length()), string(oo->table_name_.ptr(), oo->table_name_.length()));
    ASSERT_EQ(OB_SUCCESS, oo->value_.get_ext(tmp));
    ASSERT_EQ(+ObActionFlag::OP_DEL_ROW, tmp);

    ASSERT_EQ(OB_SUCCESS, os4.next_cell());
    ASSERT_EQ(OB_SUCCESS, os4.get_cell(&oo));
    ASSERT_EQ(string(cinull.table_name_.ptr(), cinull.table_name_.length()), string(oo->table_name_.ptr(), oo->table_name_.length()));
    ASSERT_EQ(OB_SUCCESS, oo->value_.get_ext(tmp));
    ASSERT_EQ(+ObActionFlag::OP_ROW_DOES_NOT_EXIST, tmp);

    while (OB_SUCCESS == os4.next_cell())
    {
      ASSERT_EQ(OB_SUCCESS, os4.get_cell(&oo));

      t++;

      ASSERT_EQ(string(oci.table_name_.ptr(), oci.table_name_.length()), string(oo->table_name_.ptr(), oo->table_name_.length()));
      ASSERT_EQ(string(oci.row_key_.ptr(), oci.row_key_.length()), string(oo->row_key_.ptr(), oo->row_key_.length()));
      ASSERT_EQ(string(oci.column_name_.ptr(), oci.column_name_.length()), string(oo->column_name_.ptr(), oo->column_name_.length()));
      ASSERT_EQ(OB_SUCCESS, oo->value_.get_int(tmp));
      ASSERT_EQ(otmp, tmp);
    }

    ASSERT_EQ(t, i);

    ob_free(buff);
  }

  ObCellInfo st;

  st.table_name_.assign((char*)"table1", 6);
  st.row_key_.assign((char*)"row1", 4);
  st.column_name_.assign((char*)"column1", 7);
  st.value_.set_int(0xff);

  ObScanner ss;
  ss.add_cell(st);

  st.table_name_.assign((char*)"table2", 6);
  st.row_key_.assign((char*)"row1", 4);
  st.column_name_.assign((char*)"column1", 7);
  st.value_.set_int(0xff);

  ss.add_cell(st);

  ObCellInfo *sto;
  bool is_row_changed;

  ASSERT_EQ(OB_SUCCESS, ss.next_cell());
  ASSERT_EQ(OB_SUCCESS, ss.get_cell(&sto, &is_row_changed));
  ASSERT_EQ(true, is_row_changed);
  ASSERT_EQ(OB_SUCCESS, ss.next_cell());
  ASSERT_EQ(OB_SUCCESS, ss.get_cell(&sto, &is_row_changed));
  ASSERT_EQ(true, is_row_changed);
  ASSERT_EQ(OB_ITER_END, ss.next_cell());
}
    int ObGetScanProxy::cs_scan(const ObScanParam& scan_param, ObScanner& scanner, 
                                ObIterator* it_out[],int64_t& it_size)
    {
      int ret = OB_SUCCESS;
      int64_t it_num = 0;

      if ((NULL == it_out) || it_size <= 0)
      {
        ret = OB_INVALID_ARGUMENT;
      }

      if ((OB_SUCCESS == ret) && ((ret = tablet_manager_.scan(scan_param, scanner)) != OB_SUCCESS))
      {
        TBSYS_LOG(WARN, "failed to scan data from local chunk server, ret=%d", ret);        
      }

      if (OB_SUCCESS == ret)
      {
        ObSSTableScanner *sstable_scanner = 
          GET_TSI_MULT(ObSSTableScanner, TSI_CS_SSTABLE_SCANNER_1);
        if (NULL == sstable_scanner)
        {
          TBSYS_LOG(ERROR, "failed to get thread local sstable scanner, "
                           "sstable_scanner=%p", 
                    sstable_scanner);
          ret = OB_ALLOCATE_MEMORY_FAILED;
        }
        else
        {
          tablet_range_.reset();
          ret = scanner.get_range(tablet_range_);
          if (OB_SUCCESS == ret)
          {
            it_out[it_num++] = sstable_scanner;
          }
          else 
          {
            TBSYS_LOG(WARN, "failed to get tablet range from scanner, ret=%d", ret);
          }
        }
      }

      if (OB_SUCCESS == ret)
      {
        int64_t query_version = 0;
        const ObVersionRange version_range = scan_param.get_version_range();
        if (!version_range.border_flag_.is_max_value() && version_range.end_version_ != 0)
        {
          query_version = version_range.end_version_;
        }
        ObTablet*& scan_tablet            = tablet_manager_.get_cur_thread_scan_tablet();
        int32_t compactsstable_num        = scan_tablet->get_compactsstable_num();

        if (compactsstable_num > 0)
        {
          ObCompactSSTableMemNode* mem_node = scan_tablet->get_compactsstable_list();
          ObCompactMemIteratorArray *its    = GET_TSI_MULT(ObCompactMemIteratorArray,TSI_CS_COMPACTSSTABLE_ITERATOR_1);
          ColumnFilter* cf                  = GET_TSI_MULT(ColumnFilter,TSI_CS_COLUMNFILTER_1);          
          ObCompactSSTableMem* mem          = NULL;          
          int64_t major_version             = 0;
          int32_t i                         = 0;          

          if ((NULL == mem_node) || (NULL == cf) || (NULL == its))
          {
            TBSYS_LOG(WARN,"unexpect error,mem_node=%p,cf=%p,its=%p",mem_node,cf,its);
            ret = OB_ALLOCATE_MEMORY_FAILED;
          }
          else
          {
            cf->clear();
          }

          if ((OB_SUCCESS == ret) && (NULL == (cf = ColumnFilter::build_columnfilter(scan_param, cf))))
          {
            TBSYS_LOG(WARN,"build columnfilter failed");
            ret = OB_ERROR;
          }

          for(i=0; (mem_node != NULL) && (i < compactsstable_num) && (OB_SUCCESS == ret) && (it_num < it_size);++i)
          {
            mem = &mem_node->mem_;
            if (NULL == mem)
            {
              TBSYS_LOG(WARN,"unexpect error,compact mem is null");
              ret = OB_ERROR;
            }
            else
            {
              //query version just have major version
              major_version = mem->get_version_range().major_version_;
              if ((0 == query_version) || (query_version > 0 && major_version <= query_version))
              {
                if ((ret = its->iters_[i].init(mem)) != OB_SUCCESS)
                {
                  TBSYS_LOG(WARN,"init iterator of compact mem failed,ret=%d",ret);
                }
                else if ((ret = its->iters_[i].set_scan_param(*scan_param.get_range(),cf,
                                                              scan_param.get_scan_direction() == ScanFlag::BACKWARD))
                         != OB_SUCCESS)
                {
                  TBSYS_LOG(WARN,"set scan param failed,ret=%d",ret);
                }
                else
                {
                  it_out[it_num++] = &its->iters_[i];
                  //set data version to the last compact sstable version
                  scanner.set_data_version(mem->get_data_version());
                  FILL_TRACE_LOG("add compact iterator to merger,it_num:%ld,version:%ld",it_num,mem->get_data_version());
                }
              }
              else
              {
                break; //got enough data
              }
            }
            mem_node = mem_node->next_;
          } //end for
        } //end compactsstable_num > 0
      }

      if (OB_SUCCESS == ret)
      {
        it_size = it_num;
      }

      return ret;
    }
int ObScannerLoader::get_decoded_scanner(ObScanner &param)
{
  ObNewRange range;
  ObString column;
  ObString table_name;
  char value[4096];

  if (config_loaded_)
  {
    TBSYS_LOG(INFO, "creating scanner");

    param.reset();

    range.reset();
    range.table_id_ = table_id_;

    TBSYS_LOG(DEBUG, "range_start_=%s", to_cstring(range_start_));
    TBSYS_LOG(DEBUG, "range_end_=%s", to_cstring(range_end_));

    range.start_key_ = range_start_;
    if (range_start_inclusive_)
      range.border_flag_.set_inclusive_start();
    else
      range.border_flag_.unset_inclusive_start();
    if (range_start_min_)
      range.start_key_.set_min_row();

    range.end_key_ = range_end_;
    if (range_end_inclusive_)
      range.border_flag_.set_inclusive_end();
    else
      range.border_flag_.unset_inclusive_end();
    if (range_end_max_)
      range.end_key_.set_max_row();

    param.set_range(range);
    //param.set_is_req_fullfilled(is_fullfilled_, actual_fullfilled_item_num_);
    param.set_is_req_fullfilled(is_fullfilled_, fullfilled_item_num_);
    param.set_data_version(data_version_);

    FILE *fp = NULL;
    if ((fp = fopen(data_file_name_, "rb")) == NULL) {
      TBSYS_LOG(ERROR, "Fail to open %s", data_file_name_);
    }
    else
    {
      while(fgets(value, 4096, fp))
      {
        /* only digit and string accepted. if not dig, then string */
        int start = 0;
        int end = 0;
        int cnt = 0;
        char buf[4096];
        int table_id = 0;
        int column_cnt = 0;
        ObRowkey row_key;

        while(true)
        {
          while(isspace(value[start]))
          {
            start++;
          }

          end = start;
          while(!isspace(value[end]) && value[end] != '\0')
          {
            end++;
          }


          if (start != end)
          {
            memset(buf, 0, 4096);
            cnt = end - start;
            strncpy(buf, &value[start], cnt);
            buf[cnt] = '\0';
            if (column_cnt == 0)
            {
              table_id = atoi(buf);
            }
            else if(column_cnt == 1)
            {
              // TODO build rowkey
              //strcpy(row_key_buf, buf);
              //row_key.assign(row_key_buf, cnt);
            }
            else
            {
              build_cell_info(table_id, row_key, buf, param);
            }
            column_cnt++;
            start = end;
          }

          if (value[end] == '\0')
          {
            break;
          }
        }
      }
      fclose(fp);
    }
  }
  return OB_SUCCESS;
}