MCPcopy Create free account
hub / github.com/alibaba/zvec / TEST_F

Function TEST_F

tests/core/algorithm/flat/flat_streamer_test.cc:65–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65TEST_F(FlatStreamerTest, TestAddVector) {
66 IndexStreamer::Pointer streamer =
67 IndexFactory::CreateStreamer("FlatStreamer");
68 ASSERT_TRUE(streamer != nullptr);
69
70 Params params;
71 ASSERT_EQ(0, streamer->init(*index_meta_ptr_, params));
72 auto storage = IndexFactory::CreateStorage("MMapFileStorage");
73 ASSERT_NE(nullptr, storage);
74 Params stg_params;
75 ASSERT_EQ(0, storage->init(stg_params));
76 ASSERT_EQ(0, storage->open(dir_ + "Test/AddVector", true));
77 ASSERT_EQ(0, streamer->open(storage));
78
79 auto ctx = streamer->create_context();
80 auto provider = streamer->create_provider();
81 ASSERT_TRUE(!!ctx);
82
83 IndexQueryMeta qmeta(IndexMeta::DT_FP32, dim);
84 for (size_t i = 0; i < 1000UL; i++) {
85 NumericalVector<float> vec(dim);
86 for (size_t j = 0; j < dim; ++j) {
87 vec[j] = i;
88 }
89 streamer->add_impl(i, vec.data(), qmeta, ctx);
90 const float *data = (float *)provider->get_vector(i);
91 for (size_t j = 0; j < dim; ++j) {
92 ASSERT_FLOAT_EQ(data[j], i);
93 }
94 }
95
96 streamer->flush(0UL);
97 streamer.reset();
98}
99
100TEST_F(FlatStreamerTest, TestLinearSearch) {
101 IndexStreamer::Pointer streamer =

Callers

nothing calls this directly

Calls 15

ParamsClass · 0.85
waitMethod · 0.80
push_backMethod · 0.80
initMethod · 0.45
openMethod · 0.45
create_contextMethod · 0.45
create_providerMethod · 0.45
add_implMethod · 0.45
dataMethod · 0.45
get_vectorMethod · 0.45
flushMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected