microsoft / ALEX

A library for building an in-memory, Adaptive Learned indEX
MIT License
656 stars 112 forks source link

Key is correct but payload is wrong #5

Closed zhczhong closed 3 years ago

zhczhong commented 3 years ago

I modify the unit test of alex as follow:

TEST(Alex, TestInsertFromEmpty) {
  Alex<int, int> index;

  Alex<int, int>::V values[200];
  for (int i = 0; i < 200; i++) {
    values[i].first = rand() % 500;
    values[i].second = i;
  }

  for (int i = 0; i < 200; i++) {
    auto ret = index.insert(values[i].first, values[i].second);
    EXPECT_EQ(ret.first.key(), values[i].first);
  }

  // Check that getting the key is correct.
  for (int i = 0; i < 200; i++) {
    auto it = index.find(values[i].first);
    EXPECT_TRUE(!it.is_end());
    EXPECT_EQ(values[i].first, it.key());
    EXPECT_EQ(values[i].second, it.payload());
  }
}

I just add a line

EXPECT_EQ(values[i].second, it.payload());

But it will lead to the failure of the test. image