db_tests.cpp 15.7 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h>
X
Xu Peng 已提交
7 8
#include <thread>
#include <easylogging++.h>
G
groot 已提交
9
#include <boost/filesystem.hpp>
G
groot 已提交
10

X
Xu Peng 已提交
11
#include "utils.h"
G
groot 已提交
12
#include "db/DB.h"
X
Xu Peng 已提交
13
#include "db/DBImpl.h"
X
Xu Peng 已提交
14
#include "db/MetaConsts.h"
Z
zhiru 已提交
15
#include "db/Factories.h"
G
groot 已提交
16

J
jinhai 已提交
17
using namespace zilliz::milvus;
G
groot 已提交
18

G
groot 已提交
19 20
namespace {

Z
zhiru 已提交
21 22
    static const std::string TABLE_NAME = "test_group";
    static constexpr int64_t TABLE_DIM = 256;
G
groot 已提交
23

Z
zhiru 已提交
24 25 26 27 28 29 30
    engine::meta::TableSchema BuildTableSchema() {
        engine::meta::TableSchema table_info;
        table_info.dimension_ = TABLE_DIM;
        table_info.table_id_ = TABLE_NAME;
        table_info.engine_type_ = (int)engine::EngineType::FAISS_IDMAP;
        return table_info;
    }
G
groot 已提交
31

Z
zhiru 已提交
32 33 34 35 36 37 38 39
    void BuildVectors(int64_t n, std::vector<float>& vectors) {
        vectors.clear();
        vectors.resize(n*TABLE_DIM);
        float* data = vectors.data();
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < TABLE_DIM; j++) data[TABLE_DIM * i + j] = drand48();
            data[TABLE_DIM * i] += i / 2000.;
        }
G
groot 已提交
40 41 42 43
    }

}

X
Xu Peng 已提交
44 45
TEST_F(DBTest, CONFIG_TEST) {
    {
46 47
        ASSERT_ANY_THROW(engine::ArchiveConf conf("wrong"));
        /* EXPECT_DEATH(engine::ArchiveConf conf("wrong"), ""); */
X
Xu Peng 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    }
    {
        engine::ArchiveConf conf("delete");
        ASSERT_EQ(conf.GetType(), "delete");
        auto criterias = conf.GetCriterias();
        ASSERT_TRUE(criterias.size() == 1);
        ASSERT_TRUE(criterias["disk"] == 512);
    }
    {
        engine::ArchiveConf conf("swap");
        ASSERT_EQ(conf.GetType(), "swap");
        auto criterias = conf.GetCriterias();
        ASSERT_TRUE(criterias.size() == 1);
        ASSERT_TRUE(criterias["disk"] == 512);
    }
    {
        ASSERT_ANY_THROW(engine::ArchiveConf conf1("swap", "disk:"));
        ASSERT_ANY_THROW(engine::ArchiveConf conf2("swap", "disk:a"));
        engine::ArchiveConf conf("swap", "disk:1024");
        auto criterias = conf.GetCriterias();
        ASSERT_TRUE(criterias.size() == 1);
        ASSERT_TRUE(criterias["disk"] == 1024);
    }
    {
        ASSERT_ANY_THROW(engine::ArchiveConf conf1("swap", "days:"));
        ASSERT_ANY_THROW(engine::ArchiveConf conf2("swap", "days:a"));
        engine::ArchiveConf conf("swap", "days:100");
        auto criterias = conf.GetCriterias();
        ASSERT_TRUE(criterias.size() == 1);
        ASSERT_TRUE(criterias["days"] == 100);
    }
    {
        ASSERT_ANY_THROW(engine::ArchiveConf conf1("swap", "days:"));
        ASSERT_ANY_THROW(engine::ArchiveConf conf2("swap", "days:a"));
        engine::ArchiveConf conf("swap", "days:100;disk:200");
        auto criterias = conf.GetCriterias();
        ASSERT_TRUE(criterias.size() == 2);
        ASSERT_TRUE(criterias["days"] == 100);
        ASSERT_TRUE(criterias["disk"] == 200);
    }
}

X
Xu Peng 已提交
90

91
TEST_F(DBTest, DB_TEST) {
G
groot 已提交
92
    engine::meta::TableSchema table_info = BuildTableSchema();
G
groot 已提交
93 94 95
    engine::Status stat = db_->CreateTable(table_info);

    engine::meta::TableSchema table_info_get;
G
groot 已提交
96
    table_info_get.table_id_ = TABLE_NAME;
G
groot 已提交
97
    stat = db_->DescribeTable(table_info_get);
G
groot 已提交
98
    ASSERT_STATS(stat);
G
groot 已提交
99
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
G
groot 已提交
100 101

    engine::IDNumbers vector_ids;
X
Xu Peng 已提交
102 103
    engine::IDNumbers target_ids;

G
groot 已提交
104 105 106
    int64_t nb = 50;
    std::vector<float> xb;
    BuildVectors(nb, xb);
G
groot 已提交
107

G
groot 已提交
108 109 110
    int64_t qb = 5;
    std::vector<float> qxb;
    BuildVectors(qb, qxb);
X
Xu Peng 已提交
111

X
Xu Peng 已提交
112 113 114 115 116 117 118
    std::thread search([&]() {
        engine::QueryResults results;
        int k = 10;
        std::this_thread::sleep_for(std::chrono::seconds(2));

        INIT_TIMER;
        std::stringstream ss;
G
groot 已提交
119 120
        uint64_t count = 0;
        uint64_t prev_count = 0;
X
Xu Peng 已提交
121

X
Xu Peng 已提交
122
        for (auto j=0; j<10; ++j) {
X
Xu Peng 已提交
123
            ss.str("");
X
Xu Peng 已提交
124
            db_->Size(count);
X
Xu Peng 已提交
125
            prev_count = count;
X
Xu Peng 已提交
126 127

            START_TIMER;
G
groot 已提交
128
            stat = db_->Query(TABLE_NAME, k, qb, qxb.data(), results);
129
            ss << "Search " << j << " With Size " << count/engine::meta::M << " M";
X
Xu Peng 已提交
130 131 132
            STOP_TIMER(ss.str());

            ASSERT_STATS(stat);
X
Xu Peng 已提交
133
            for (auto k=0; k<qb; ++k) {
G
groot 已提交
134
                ASSERT_EQ(results[k][0].first, target_ids[k]);
X
Xu Peng 已提交
135 136 137
                ss.str("");
                ss << "Result [" << k << "]:";
                for (auto result : results[k]) {
G
groot 已提交
138
                    ss << result.first << " ";
X
Xu Peng 已提交
139
                }
140
                /* LOG(DEBUG) << ss.str(); */
X
Xu Peng 已提交
141
            }
X
Xu Peng 已提交
142
            ASSERT_TRUE(count >= prev_count);
X
Xu Peng 已提交
143 144 145 146
            std::this_thread::sleep_for(std::chrono::seconds(1));
        }
    });

X
Xu Peng 已提交
147
    int loop = 100000;
X
Xu Peng 已提交
148 149 150

    for (auto i=0; i<loop; ++i) {
        if (i==40) {
G
groot 已提交
151
            db_->InsertVectors(TABLE_NAME, qb, qxb.data(), target_ids);
152
            ASSERT_EQ(target_ids.size(), qb);
X
Xu Peng 已提交
153
        } else {
G
groot 已提交
154
            db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
X
Xu Peng 已提交
155
        }
X
Xu Peng 已提交
156
        std::this_thread::sleep_for(std::chrono::microseconds(1));
X
Xu Peng 已提交
157
    }
X
xj.lin 已提交
158

X
Xu Peng 已提交
159
    search.join();
160
};
X
xj.lin 已提交
161

162
TEST_F(DBTest, SEARCH_TEST) {
G
groot 已提交
163
    engine::meta::TableSchema table_info = BuildTableSchema();
G
groot 已提交
164
    engine::Status stat = db_->CreateTable(table_info);
X
xj.lin 已提交
165

G
groot 已提交
166
    engine::meta::TableSchema table_info_get;
G
groot 已提交
167
    table_info_get.table_id_ = TABLE_NAME;
G
groot 已提交
168
    stat = db_->DescribeTable(table_info_get);
X
xj.lin 已提交
169
    ASSERT_STATS(stat);
G
groot 已提交
170
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
X
xj.lin 已提交
171 172

    // prepare raw data
X
xj.lin 已提交
173
    size_t nb = 250000;
X
xj.lin 已提交
174 175
    size_t nq = 10;
    size_t k = 5;
G
groot 已提交
176 177
    std::vector<float> xb(nb*TABLE_DIM);
    std::vector<float> xq(nq*TABLE_DIM);
X
xj.lin 已提交
178 179 180 181 182
    std::vector<long> ids(nb);

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<> dis_xt(-1.0, 1.0);
G
groot 已提交
183
    for (size_t i = 0; i < nb*TABLE_DIM; i++) {
X
xj.lin 已提交
184 185 186 187 188
        xb[i] = dis_xt(gen);
        if (i < nb){
            ids[i] = i;
        }
    }
G
groot 已提交
189
    for (size_t i = 0; i < nq*TABLE_DIM; i++) {
X
xj.lin 已提交
190 191 192 193 194 195 196 197 198 199 200 201
        xq[i] = dis_xt(gen);
    }

    // result data
    //std::vector<long> nns_gt(k*nq);
    std::vector<long> nns(k*nq);  // nns = nearst neg search
    //std::vector<float> dis_gt(k*nq);
    std::vector<float> dis(k*nq);

    // insert data
    const int batch_size = 100;
    for (int j = 0; j < nb / batch_size; ++j) {
G
groot 已提交
202
        stat = db_->InsertVectors(TABLE_NAME, batch_size, xb.data()+batch_size*j*TABLE_DIM, ids);
X
xj.lin 已提交
203
        if (j == 200){ sleep(1);}
X
xj.lin 已提交
204 205 206
        ASSERT_STATS(stat);
    }

X
Xu Peng 已提交
207
    sleep(2); // wait until build index finish
X
xj.lin 已提交
208

G
groot 已提交
209
    engine::QueryResults results;
G
groot 已提交
210
    stat = db_->Query(TABLE_NAME, k, nq, xq.data(), results);
G
groot 已提交
211
    ASSERT_STATS(stat);
X
xj.lin 已提交
212 213

    // TODO(linxj): add groundTruth assert
214
};
Y
c  
yu yunfeng 已提交
215

G
groot 已提交
216
TEST_F(DBTest2, ARHIVE_DISK_CHECK) {
Z
zhiru 已提交
217

G
groot 已提交
218 219
    engine::meta::TableSchema table_info = BuildTableSchema();
    engine::Status stat = db_->CreateTable(table_info);
Z
zhiru 已提交
220

G
groot 已提交
221 222 223 224 225 226 227 228 229 230 231 232
    std::vector<engine::meta::TableSchema> table_schema_array;
    stat = db_->AllTables(table_schema_array);
    ASSERT_STATS(stat);
    bool bfound = false;
    for(auto& schema : table_schema_array) {
        if(schema.table_id_ == TABLE_NAME) {
            bfound = true;
            break;
        }
    }
    ASSERT_TRUE(bfound);

G
groot 已提交
233 234 235
    engine::meta::TableSchema table_info_get;
    table_info_get.table_id_ = TABLE_NAME;
    stat = db_->DescribeTable(table_info_get);
Z
zhiru 已提交
236
    ASSERT_STATS(stat);
G
groot 已提交
237
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
Z
zhiru 已提交
238 239 240 241

    engine::IDNumbers vector_ids;
    engine::IDNumbers target_ids;

G
groot 已提交
242
    uint64_t size;
Z
zhiru 已提交
243 244
    db_->Size(size);

G
groot 已提交
245 246 247
    int64_t nb = 10;
    std::vector<float> xb;
    BuildVectors(nb, xb);
Z
zhiru 已提交
248

G
groot 已提交
249
    int loop = 100000;
Z
zhiru 已提交
250
    for (auto i=0; i<loop; ++i) {
G
groot 已提交
251
        db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
Z
zhiru 已提交
252 253 254
        std::this_thread::sleep_for(std::chrono::microseconds(1));
    }

G
groot 已提交
255
    std::this_thread::sleep_for(std::chrono::seconds(1));
Z
zhiru 已提交
256 257 258

    db_->Size(size);
    LOG(DEBUG) << "size=" << size;
G
groot 已提交
259 260
    ASSERT_LE(size, 1 * engine::meta::G);
};
Z
zhiru 已提交
261

G
groot 已提交
262
TEST_F(DBTest2, DELETE_TEST) {
Z
zhiru 已提交
263

G
groot 已提交
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295

    engine::meta::TableSchema table_info = BuildTableSchema();
    engine::Status stat = db_->CreateTable(table_info);

    engine::meta::TableSchema table_info_get;
    table_info_get.table_id_ = TABLE_NAME;
    stat = db_->DescribeTable(table_info_get);
    ASSERT_STATS(stat);

    ASSERT_TRUE(boost::filesystem::exists(table_info_get.location_));

    engine::IDNumbers vector_ids;

    uint64_t size;
    db_->Size(size);

    int64_t nb = 100000;
    std::vector<float> xb;
    BuildVectors(nb, xb);

    int loop = 20;
    for (auto i=0; i<loop; ++i) {
        db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
        std::this_thread::sleep_for(std::chrono::microseconds(1));
    }

    std::vector<engine::meta::DateT> dates;
    stat = db_->DeleteTable(TABLE_NAME, dates);
    std::this_thread::sleep_for(std::chrono::seconds(2));
    ASSERT_TRUE(stat.ok());
    ASSERT_FALSE(boost::filesystem::exists(table_info_get.location_));
};
Z
zhiru 已提交
296 297 298 299 300 301

TEST_F(MySQLDBTest, DB_TEST) {

    auto options = GetOptions();
    auto db_ = engine::DBFactory::Build(options);

Z
update  
zhiru 已提交
302
    engine::meta::TableSchema table_info = BuildTableSchema();
Z
zhiru 已提交
303
    engine::Status stat = db_->CreateTable(table_info);
Z
zhiru 已提交
304

Z
zhiru 已提交
305
    engine::meta::TableSchema table_info_get;
Z
update  
zhiru 已提交
306
    table_info_get.table_id_ = TABLE_NAME;
Z
zhiru 已提交
307
    stat = db_->DescribeTable(table_info_get);
Z
zhiru 已提交
308
    ASSERT_STATS(stat);
Z
update  
zhiru 已提交
309
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
Z
zhiru 已提交
310 311 312 313

    engine::IDNumbers vector_ids;
    engine::IDNumbers target_ids;

Z
zhiru 已提交
314 315 316
    int64_t nb = 50;
    std::vector<float> xb;
    BuildVectors(nb, xb);
Z
zhiru 已提交
317

Z
zhiru 已提交
318 319 320
    int64_t qb = 5;
    std::vector<float> qxb;
    BuildVectors(qb, qxb);
Z
zhiru 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337

    std::thread search([&]() {
        engine::QueryResults results;
        int k = 10;
        std::this_thread::sleep_for(std::chrono::seconds(2));

        INIT_TIMER;
        std::stringstream ss;
        uint64_t count = 0;
        uint64_t prev_count = 0;

        for (auto j=0; j<10; ++j) {
            ss.str("");
            db_->Size(count);
            prev_count = count;

            START_TIMER;
Z
update  
zhiru 已提交
338
            stat = db_->Query(TABLE_NAME, k, qb, qxb.data(), results);
Z
zhiru 已提交
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
            ss << "Search " << j << " With Size " << count/engine::meta::M << " M";
            STOP_TIMER(ss.str());

            ASSERT_STATS(stat);
            for (auto k=0; k<qb; ++k) {
                ASSERT_EQ(results[k][0].first, target_ids[k]);
                ss.str("");
                ss << "Result [" << k << "]:";
                for (auto result : results[k]) {
                    ss << result.first << " ";
                }
                /* LOG(DEBUG) << ss.str(); */
            }
            ASSERT_TRUE(count >= prev_count);
            std::this_thread::sleep_for(std::chrono::seconds(1));
        }
    });

    int loop = 100000;

    for (auto i=0; i<loop; ++i) {
        if (i==40) {
Z
update  
zhiru 已提交
361
            db_->InsertVectors(TABLE_NAME, qb, qxb.data(), target_ids);
Z
zhiru 已提交
362 363
            ASSERT_EQ(target_ids.size(), qb);
        } else {
Z
update  
zhiru 已提交
364
            db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
Z
zhiru 已提交
365 366 367 368 369
        }
        std::this_thread::sleep_for(std::chrono::microseconds(1));
    }

    search.join();
Z
update  
zhiru 已提交
370

Z
zhiru 已提交
371 372 373 374 375
    delete db_;

    auto dummyDB = engine::DBFactory::Build(options);
    dummyDB->DropAll();
    delete dummyDB;
Z
zhiru 已提交
376 377 378 379 380 381
};

TEST_F(MySQLDBTest, SEARCH_TEST) {
    auto options = GetOptions();
    auto db_ = engine::DBFactory::Build(options);

Z
zhiru 已提交
382 383
    engine::meta::TableSchema table_info = BuildTableSchema();
    engine::Status stat = db_->CreateTable(table_info);
Z
zhiru 已提交
384

Z
zhiru 已提交
385 386 387
    engine::meta::TableSchema table_info_get;
    table_info_get.table_id_ = TABLE_NAME;
    stat = db_->DescribeTable(table_info_get);
Z
zhiru 已提交
388
    ASSERT_STATS(stat);
Z
zhiru 已提交
389
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
Z
zhiru 已提交
390 391 392 393 394

    // prepare raw data
    size_t nb = 250000;
    size_t nq = 10;
    size_t k = 5;
Z
zhiru 已提交
395 396
    std::vector<float> xb(nb*TABLE_DIM);
    std::vector<float> xq(nq*TABLE_DIM);
Z
zhiru 已提交
397 398 399 400 401
    std::vector<long> ids(nb);

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<> dis_xt(-1.0, 1.0);
Z
zhiru 已提交
402
    for (size_t i = 0; i < nb*TABLE_DIM; i++) {
Z
zhiru 已提交
403 404 405 406 407
        xb[i] = dis_xt(gen);
        if (i < nb){
            ids[i] = i;
        }
    }
Z
zhiru 已提交
408
    for (size_t i = 0; i < nq*TABLE_DIM; i++) {
Z
zhiru 已提交
409 410 411 412 413 414 415 416 417 418 419 420
        xq[i] = dis_xt(gen);
    }

    // result data
    //std::vector<long> nns_gt(k*nq);
    std::vector<long> nns(k*nq);  // nns = nearst neg search
    //std::vector<float> dis_gt(k*nq);
    std::vector<float> dis(k*nq);

    // insert data
    const int batch_size = 100;
    for (int j = 0; j < nb / batch_size; ++j) {
Z
zhiru 已提交
421
        stat = db_->InsertVectors(TABLE_NAME, batch_size, xb.data()+batch_size*j*TABLE_DIM, ids);
Z
zhiru 已提交
422 423 424 425 426 427 428
        if (j == 200){ sleep(1);}
        ASSERT_STATS(stat);
    }

    sleep(2); // wait until build index finish

    engine::QueryResults results;
Z
zhiru 已提交
429
    stat = db_->Query(TABLE_NAME, k, nq, xq.data(), results);
Z
zhiru 已提交
430 431
    ASSERT_STATS(stat);

Z
zhiru 已提交
432 433 434 435 436
    delete db_;

    auto dummyDB = engine::DBFactory::Build(options);
    dummyDB->DropAll();
    delete dummyDB;
Z
update  
zhiru 已提交
437

Z
zhiru 已提交
438
    // TODO(linxj): add groundTruth assert
Z
zhiru 已提交
439 440 441 442 443 444 445 446 447 448 449
};

TEST_F(MySQLDBTest, ARHIVE_DISK_CHECK) {

    auto options = GetOptions();
    options.meta.archive_conf = engine::ArchiveConf("delete", "disk:1");
    auto db_ = engine::DBFactory::Build(options);

    engine::meta::TableSchema table_info = BuildTableSchema();
    engine::Status stat = db_->CreateTable(table_info);

Z
update  
zhiru 已提交
450 451 452 453 454 455 456 457 458 459 460 461
    std::vector<engine::meta::TableSchema> table_schema_array;
    stat = db_->AllTables(table_schema_array);
    ASSERT_STATS(stat);
    bool bfound = false;
    for(auto& schema : table_schema_array) {
        if(schema.table_id_ == TABLE_NAME) {
            bfound = true;
            break;
        }
    }
    ASSERT_TRUE(bfound);

Z
zhiru 已提交
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
    engine::meta::TableSchema table_info_get;
    table_info_get.table_id_ = TABLE_NAME;
    stat = db_->DescribeTable(table_info_get);
    ASSERT_STATS(stat);
    ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);

    engine::IDNumbers vector_ids;
    engine::IDNumbers target_ids;

    uint64_t size;
    db_->Size(size);

    int64_t nb = 10;
    std::vector<float> xb;
    BuildVectors(nb, xb);

    int loop = 100000;
    for (auto i=0; i<loop; ++i) {
        db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
        std::this_thread::sleep_for(std::chrono::microseconds(1));
    }

Z
zhiru 已提交
484
    std::this_thread::sleep_for(std::chrono::seconds(1));
Z
zhiru 已提交
485 486 487 488

    db_->Size(size);
    LOG(DEBUG) << "size=" << size;
    ASSERT_LE(size, 1 * engine::meta::G);
Z
update  
zhiru 已提交
489

Z
zhiru 已提交
490 491 492 493 494
    delete db_;

    auto dummyDB = engine::DBFactory::Build(options);
    dummyDB->DropAll();
    delete dummyDB;
Z
zhiru 已提交
495 496 497 498 499 500 501 502 503 504
};

TEST_F(MySQLDBTest, DELETE_TEST) {

    auto options = GetOptions();
    options.meta.archive_conf = engine::ArchiveConf("delete", "disk:1");
    auto db_ = engine::DBFactory::Build(options);

    engine::meta::TableSchema table_info = BuildTableSchema();
    engine::Status stat = db_->CreateTable(table_info);
Z
zhiru 已提交
505
//    std::cout << stat.ToString() << std::endl;
Z
zhiru 已提交
506 507 508 509 510 511

    engine::meta::TableSchema table_info_get;
    table_info_get.table_id_ = TABLE_NAME;
    stat = db_->DescribeTable(table_info_get);
    ASSERT_STATS(stat);

Z
zhiru 已提交
512
//    std::cout << "location: " << table_info_get.location_ << std::endl;
Z
zhiru 已提交
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
    ASSERT_TRUE(boost::filesystem::exists(table_info_get.location_));

    engine::IDNumbers vector_ids;

    uint64_t size;
    db_->Size(size);

    int64_t nb = 100000;
    std::vector<float> xb;
    BuildVectors(nb, xb);

    int loop = 20;
    for (auto i=0; i<loop; ++i) {
        db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
        std::this_thread::sleep_for(std::chrono::microseconds(1));
    }

    std::vector<engine::meta::DateT> dates;
    stat = db_->DeleteTable(TABLE_NAME, dates);
Z
zhiru 已提交
532 533 534
//    std::cout << "5 sec start" << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(5));
//    std::cout << "5 sec finish" << std::endl;
Z
zhiru 已提交
535
    ASSERT_TRUE(stat.ok());
Z
zhiru 已提交
536
//    ASSERT_FALSE(boost::filesystem::exists(table_info_get.location_));
Z
update  
zhiru 已提交
537

Z
zhiru 已提交
538 539 540 541 542
    delete db_;

    auto dummyDB = engine::DBFactory::Build(options);
    dummyDB->DropAll();
    delete dummyDB;
Z
zhiru 已提交
543
};