Skip to content

Commit

Permalink
addressing review comments, not to throw on c4indexupdater_count, _va…
Browse files Browse the repository at this point in the history
…lueAt, _setVector, _skipVector
  • Loading branch information
jianminzhao committed Jun 21, 2024
1 parent ca5f271 commit 62fb91a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions C/c4Index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,32 @@ C4IndexUpdater::~C4IndexUpdater() = default;

size_t C4IndexUpdater::count() const {
if ( hasFinished() ) {
WarnError("C4IndexUpdater::count() called on finished updater.");
Warn("C4IndexUpdater::count() called on finished updater.");
return 0;
}
return _update->count();
}

FLValue C4IndexUpdater::valueAt(size_t i) const {
if ( hasFinished() ) {
litecore::error::_throw(litecore::error::NotOpen, "C4IndexUpdater::valueAt() called on finished updater.");
Warn("C4IndexUpdater::valueAt() called on finished updater.");
return FLValue{};
}
return _update->valueAt(i);
}

void C4IndexUpdater::setVectorAt(size_t i, const float* vector, size_t dimension) {
if ( hasFinished() ) {
litecore::error::_throw(litecore::error::NotOpen, "C4IndexUpdater::setVectorAt() called on finished updater.");
Warn("C4IndexUpdater::setVectorAt() called on finished updater.");
return;
}
_update->setVectorAt(i, vector, dimension);
}

void C4IndexUpdater::skipVectorAt(size_t i) {
if ( hasFinished() ) {
litecore::error::_throw(litecore::error::NotOpen, "C4IndexUpdater::SkipVectorAt() called on finished updater.");
Warn("C4IndexUpdater::SkipVectorAt() called on finished updater.");
return;
}
return _update->skipVectorAt(i);
}
Expand Down
5 changes: 2 additions & 3 deletions LiteCore/tests/LazyVectorAPITest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,11 @@ TEST_CASE_METHOD(LazyVectorAPITest, "IndexUpdater Call After Already Finished",
// c4indexupdater_setVectorAt after finished
err.code = 0;
auto succ = c4indexupdater_setVectorAt(updater, 0, vectors.data(), 300, &err);
CHECK(!succ);
CHECK(err.code == kC4ErrorNotOpen);
CHECK(succ);

// c4indexupdater_skipVectorAt after finished
succ = c4indexupdater_skipVectorAt(updater, 0);
CHECK(!succ);
CHECK(succ);

c4indexupdater_release(updater);
c4index_release(index);
Expand Down

0 comments on commit 62fb91a

Please sign in to comment.