Пример #1
0
/**
 * Apply the column delta on the rollback segment to the given tuple
 */
void TileGroup::ApplyRollbackSegment(char *rb_seg, const oid_t &tuple_slot_id) {
    auto seg_col_count = storage::RollbackSegmentPool::GetColCount(rb_seg);
    auto table_schema = GetAbstractTable()->GetSchema();

    for (size_t idx = 0; idx < seg_col_count; ++idx) {
        auto col_id =
            storage::RollbackSegmentPool::GetIdOffsetPair(rb_seg, idx)->col_id;
        Value col_value =
            storage::RollbackSegmentPool::GetValue(rb_seg, table_schema, idx);

        // Get target tile
        auto tile_id = GetTileIdFromColumnId(col_id);
        PL_ASSERT(tile_id < GetTileCount());
        storage::Tile *tile = GetTile(tile_id);
        PL_ASSERT(tile);

        // Get tile schema
        auto &tile_schema = tile_schemas[tile_id];

        // Get a tuple wrapper
        char *tile_tuple_location = tile->GetTupleLocation(tuple_slot_id);
        PL_ASSERT(tile_tuple_location);
        storage::Tuple tile_tuple(&tile_schema, tile_tuple_location);

        // Write the value to tuple
        auto tile_col_idx = GetTileColumnId(col_id);
        tile_tuple.SetValue(tile_col_idx, col_value, tile->GetPool());
    }
}
Пример #2
0
void
TiledTextureImage::BindTexture(GLenum aTextureUnit)
{
    if (!GetTileCount()) {
        return;
    }
    mImages[mCurrentImage]->BindTexture(aTextureUnit);
}
Пример #3
0
gfx::IntRect TiledTextureImage::GetTileRect()
{
    if (!GetTileCount()) {
        return gfx::IntRect();
    }
    gfx::IntRect rect = mImages[mCurrentImage]->GetTileRect();
    unsigned int xPos = (mCurrentImage % mColumns) * mTileSize;
    unsigned int yPos = (mCurrentImage / mColumns) * mTileSize;
    rect.MoveBy(xPos, yPos);
    return rect;
}
Пример #4
0
// Insert a logical tile into a table
TEST_F(MutateTests, InsertTest) {
  auto &txn_manager = concurrency::OptimisticTxnManager::GetInstance();
  // We are going to insert a tile group into a table in this test
  std::unique_ptr<storage::DataTable> source_data_table(
      ExecutorTestsUtil::CreateAndPopulateTable());
  std::unique_ptr<storage::DataTable> dest_data_table(
      ExecutorTestsUtil::CreateTable());
  const std::vector<storage::Tuple *> tuples;

  EXPECT_EQ(source_data_table->GetTileGroupCount(), 3);
  EXPECT_EQ(dest_data_table->GetTileGroupCount(), 1);

  auto txn = txn_manager.BeginTransaction();
  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  planner::InsertPlan node(dest_data_table.get(), nullptr);
  executor::InsertExecutor executor(&node, context.get());

  MockExecutor child_executor;
  executor.AddChild(&child_executor);

  // Uneventful init...
  EXPECT_CALL(child_executor, DInit()).WillOnce(Return(true));

  // Will return one tile.
  EXPECT_CALL(child_executor, DExecute())
      .WillOnce(Return(true))
      .WillOnce(Return(false));

  // Construct input logical tile
  auto physical_tile_group = source_data_table->GetTileGroup(0);
  auto tile_count = physical_tile_group->GetTileCount();
  std::vector<std::shared_ptr<storage::Tile> > physical_tile_refs;
  for (oid_t tile_itr = 0; tile_itr < tile_count; tile_itr++)
    physical_tile_refs.push_back(
        physical_tile_group->GetTileReference(tile_itr));

  std::unique_ptr<executor::LogicalTile> source_logical_tile(
      executor::LogicalTileFactory::WrapTiles(physical_tile_refs));

  EXPECT_CALL(child_executor, GetOutput())
      .WillOnce(Return(source_logical_tile.release()));

  EXPECT_TRUE(executor.Init());

  EXPECT_TRUE(executor.Execute());
  EXPECT_FALSE(executor.Execute());

  txn_manager.CommitTransaction();

  // We have inserted all the tuples in this logical tile
  EXPECT_EQ(dest_data_table->GetTileGroupCount(), 1);
}
Пример #5
0
TEST_F(TempTableTests, InsertTest) {
  const int tuple_count = TESTS_TUPLES_PER_TILEGROUP;
  auto pool = TestingHarness::GetInstance().GetTestingPool();

  catalog::Schema *schema = new catalog::Schema(
      {ExecutorTestsUtil::GetColumnInfo(0), ExecutorTestsUtil::GetColumnInfo(1),
       ExecutorTestsUtil::GetColumnInfo(2),
       ExecutorTestsUtil::GetColumnInfo(3)});

  // Create our TempTable
  storage::TempTable table(INVALID_OID, schema, true);
  EXPECT_EQ(0, table.GetTupleCount());

  std::vector<type::Value> values;

  // Then shove some tuples in it
  for (int i = 0; i < tuple_count; i++) {
    storage::Tuple *tuple = new storage::Tuple(table.GetSchema(), true);
    auto val1 = type::ValueFactory::GetIntegerValue(
        ExecutorTestsUtil::PopulatedValue(i, 0));
    auto val2 = type::ValueFactory::GetIntegerValue(
        ExecutorTestsUtil::PopulatedValue(i, 1));
    auto val3 = type::ValueFactory::GetDoubleValue(
        ExecutorTestsUtil::PopulatedValue(i, 2));
    auto val4 = type::ValueFactory::GetVarcharValue("12345");
    tuple->SetValue(0, val1, pool);
    tuple->SetValue(1, val2, pool);
    tuple->SetValue(2, val3, pool);
    tuple->SetValue(3, val4, pool);
    table.InsertTuple(tuple);

    // Copy the first value so that we can just check that we are able to
    // correctly get the values back.
    values.push_back(val1);

    delete tuple;
  }

  // Make sure that we have the correct count
  // and that we get back the correct values
  EXPECT_EQ(tuple_count, table.GetTupleCount());
  oid_t found_tile_group_count = table.GetTileGroupCount();
  oid_t found_tuple_count = 0;
  for (oid_t tile_group_itr = 0; tile_group_itr < found_tile_group_count;
       tile_group_itr++) {
    auto tile_group = table.GetTileGroup(tile_group_itr);
    auto tile_count = tile_group->GetTileCount();

    for (oid_t tile_itr = 0; tile_itr < tile_count; tile_itr++) {
      storage::Tile *tile = tile_group->GetTile(tile_itr);
      if (tile == nullptr) continue;
      storage::Tuple tuple(tile->GetSchema());
      storage::TupleIterator tuple_itr(tile);
      while (tuple_itr.Next(tuple)) {
        auto tupleVal = tuple.GetValue(0);
        EXPECT_FALSE(tupleVal.IsNull());

        // I have to do this because we can't put type::Value into a std::set
        bool found = false;
        for (auto val : values) {
          found = val.CompareEquals(tupleVal) == type::CMP_TRUE;
          if (found) break;
        }  // FOR
        EXPECT_TRUE(found);
        // EXPECT_NE(values.end(), values.find(val));

        found_tuple_count++;
      }
    }
  }  // FOR
  EXPECT_EQ(tuple_count, found_tuple_count);
}