Exemple #1
0
// if there is no group columns, is_same_group returns true
int ObMergeGroupBy::is_same_group(const ObRow &row1, const ObRow &row2, bool &result)
{
  int ret = OB_SUCCESS;
  result = true;
  const ObObj *cell1 = NULL;
  const ObObj *cell2 = NULL;
  for (int64_t i = 0; i < group_columns_.count(); ++i)
  {
    const ObGroupColumn &group_col = group_columns_.at(i);
    if (OB_SUCCESS != (ret = row1.get_cell(group_col.table_id_, group_col.column_id_, cell1)))
    {
      TBSYS_LOG(WARN, "failed to get cell, err=%d tid=%lu cid=%lu",
                ret, group_col.table_id_, group_col.column_id_);
      break;
    }
    else if (OB_SUCCESS != (ret = row2.get_cell(group_col.table_id_, group_col.column_id_, cell2)))
    {
      TBSYS_LOG(WARN, "failed to get cell, err=%d tid=%lu cid=%lu",
                ret, group_col.table_id_, group_col.column_id_);
      break;
    }
    else if (*cell1 != *cell2)
    {
      result = false;
      break;
    }
  } // end for
  return ret;
}
Exemple #2
0
int ObTabletJoin::get_right_table_rowkey(const ObRow &row, uint64_t &right_table_id, ObString &rowkey) const
{
  int ret = OB_SUCCESS;
  const ObObj *cell = NULL;
  JoinInfo join_info;

  if(OB_SUCCESS != (ret = table_join_info_.join_condition_.at(0, join_info)))
  {
    TBSYS_LOG(WARN, "get join condition fail:ret[%d]", ret);
  }

  if(OB_SUCCESS == ret)
  {
    right_table_id = join_info.right_table_id_;

    if(OB_SUCCESS != (ret = row.get_cell(table_join_info_.left_table_id_, join_info.left_column_id_, cell)))
    {
      TBSYS_LOG(WARN, "row get cell fail:ret[%d]", ret);
    }
    else if(OB_SUCCESS != (ret = cell->get_varchar(rowkey)))
    {
      TBSYS_LOG(WARN, "get_varchar fail:ret[%d]", ret);
    }
  }

  return ret;
}
// ObRow.reset
TEST_F(ObRowTest, reset_test)
{
  ObRow row;
  ObRowDesc row_desc;
  const uint64_t TABLE_ID = 1001;
  const int64_t COLUMN_NUM = 8;
  ObObj cell;
  const ObObj *value = NULL;
  uint64_t table_id = 0;
  uint64_t column_id = 0;
  int64_t int_value = 0;

  row_desc.set_rowkey_cell_count(2);

  for (int i = 0; i < COLUMN_NUM; i ++)
  {
    row_desc.add_column_desc(TABLE_ID, OB_APP_MIN_COLUMN_ID + i);
  }
  row.set_row_desc(row_desc);

  for (int i = 0; i < COLUMN_NUM; i ++)
  {
    cell.set_int(i);
    row.raw_set_cell(i, cell);
  }

  row.reset(true, ObRow::DEFAULT_NULL);
  for (int i = 0; i < row_desc.get_rowkey_cell_count(); i ++)
  {
    row.raw_get_cell(i, value, table_id, column_id);
    value->get_int(int_value);
    ASSERT_EQ(i, int_value);
  }

  for (int64_t i = row_desc.get_rowkey_cell_count(); i < COLUMN_NUM; i ++)
  {
    row.raw_get_cell(i, value, table_id, column_id);
    ASSERT_TRUE( ObNullType == value->get_type() );
  }

  row_desc.add_column_desc(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID);
  cell.set_ext(ObActionFlag::OP_DEL_ROW);
  row.set_cell(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID, cell);

  row.reset(true, ObRow::DEFAULT_NOP);

  for (int i = 0; i < row_desc.get_rowkey_cell_count(); i ++)
  {
    row.raw_get_cell(i, value, table_id, column_id);
    value->get_int(int_value);
    ASSERT_EQ(i, int_value);
  }

  for (int64_t i = row_desc.get_rowkey_cell_count(); i < COLUMN_NUM; i ++)
  {
    row.raw_get_cell(i, value, table_id, column_id);
    ASSERT_TRUE( ObActionFlag::OP_NOP == value->get_ext() ) << "ext value: " << value->get_ext();
  }

  row.get_cell(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID, value);
  ASSERT_TRUE( ObActionFlag::OP_ROW_DOES_NOT_EXIST == value->get_ext() );
}