Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing return keyword... #104

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/index/flat/flat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FlatIndexNode : public IndexNode {
Search(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "search on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}

DataSetPtr results = std::make_shared<DataSet>();
Expand Down Expand Up @@ -130,7 +130,7 @@ class FlatIndexNode : public IndexNode {
RangeSearch(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "range search on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}

const FlatConfig& f_cfg = static_cast<const FlatConfig&>(cfg);
Expand Down Expand Up @@ -253,7 +253,7 @@ class FlatIndexNode : public IndexNode {
Serialize(BinarySet& binset) const override {
if (!index_) {
LOG_KNOWHERE_ERROR_ << "Can not serialize empty index.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}
try {
MemoryIOWriter writer;
Expand Down
10 changes: 5 additions & 5 deletions src/index/gpu/flat_gpu/flat_gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GpuFlatIndexNode : public IndexNode {
// need not copy index from CPU to GPU for IDMAP
} catch (const std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}
return Status::success;
}
Expand All @@ -56,7 +56,7 @@ class GpuFlatIndexNode : public IndexNode {
Search(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "index not empty, deleted old index.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}

const FlatConfig& f_cfg = static_cast<const FlatConfig&>(cfg);
Expand Down Expand Up @@ -114,7 +114,7 @@ class GpuFlatIndexNode : public IndexNode {
Serialize(BinarySet& binset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "serilalization on empty index.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}
try {
MemoryIOWriter writer;
Expand All @@ -124,7 +124,7 @@ class GpuFlatIndexNode : public IndexNode {
binset.Append(Type(), data, writer.tellg());
} catch (const std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}
return Status::success;
}
Expand All @@ -147,7 +147,7 @@ class GpuFlatIndexNode : public IndexNode {
res_ = gpu_res;
} catch (const std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}

return Status::success;
Expand Down
16 changes: 8 additions & 8 deletions src/index/gpu/ivf_gpu/ivf_gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class GpuIvfIndexNode : public IndexNode {
res_ = gpu_res;
} catch (std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}
index_ = std::move(index);
return Status::success;
Expand All @@ -111,11 +111,11 @@ class GpuIvfIndexNode : public IndexNode {
Add(const DataSet& dataset, const Config& cfg) override {
if (!index_) {
LOG_KNOWHERE_ERROR_ << "Can not add data to empty GpuIvfIndex.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}
if (!index_->is_trained) {
LOG_KNOWHERE_ERROR_ << "Can not add data to not trained GpuIvfIndex.";
expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
return Status::index_not_trained;
}
auto rows = dataset.GetRows();
auto tensor = dataset.GetTensor();
Expand All @@ -124,7 +124,7 @@ class GpuIvfIndexNode : public IndexNode {
index_->add(rows, (const float*)tensor);
} catch (std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}
return Status::success;
}
Expand Down Expand Up @@ -177,11 +177,11 @@ class GpuIvfIndexNode : public IndexNode {
Serialize(BinarySet& binset) const override {
if (!index_) {
LOG_KNOWHERE_ERROR_ << "Can not serialize empty GpuIvfIndex.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}
if (!index_->is_trained) {
LOG_KNOWHERE_ERROR_ << "Can not serialize not trained GpuIvfIndex.";
expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
return Status::index_not_trained;
}

try {
Expand All @@ -195,7 +195,7 @@ class GpuIvfIndexNode : public IndexNode {
binset.Append(Type(), data, writer.tellg());
} catch (std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}

return Status::success;
Expand All @@ -218,7 +218,7 @@ class GpuIvfIndexNode : public IndexNode {
res_ = gpu_res;
} catch (std::exception& e) {
LOG_KNOWHERE_WARNING_ << "faiss inner error, " << e.what();
return expected<DataSetPtr>::Err(Status::faiss_inner_error, e.what());
return Status::faiss_inner_error;
}
return Status::success;
}
Expand Down
7 changes: 4 additions & 3 deletions src/index/hnsw/hnsw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class HnswIndexNode : public IndexNode {
Add(const DataSet& dataset, const Config& cfg) override {
if (!index_) {
LOG_KNOWHERE_ERROR_ << "Can not add data to empty HNSW index.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}

knowhere::TimeRecorder build_time("Building HNSW cost");
Expand All @@ -98,7 +98,7 @@ class HnswIndexNode : public IndexNode {
Search(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "search on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}
auto nq = dataset.GetRows();
auto xq = dataset.GetTensor();
Expand Down Expand Up @@ -207,7 +207,8 @@ class HnswIndexNode : public IndexNode {
AnnIterator(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const override {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "creating iterator on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<std::vector<std::shared_ptr<IndexNode::iterator>>>::Err(Status::empty_index,
"index not loaded");
}
auto nq = dataset.GetRows();
auto xq = dataset.GetTensor();
Expand Down
14 changes: 7 additions & 7 deletions src/index/ivf/ivf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ Status
IvfIndexNode<T>::Add(const DataSet& dataset, const Config& cfg) {
if (!this->index_) {
LOG_KNOWHERE_ERROR_ << "Can not add data to empty IVF index.";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return Status::empty_index;
}
auto data = dataset.GetTensor();
auto rows = dataset.GetRows();
Expand All @@ -373,11 +373,11 @@ expected<DataSetPtr>
IvfIndexNode<T>::Search(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const {
if (!this->index_) {
LOG_KNOWHERE_WARNING_ << "search on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}
if (!this->index_->is_trained) {
LOG_KNOWHERE_WARNING_ << "index not trained";
expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
return expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
}

auto dim = dataset.GetDim();
Expand Down Expand Up @@ -454,11 +454,11 @@ expected<DataSetPtr>
IvfIndexNode<T>::RangeSearch(const DataSet& dataset, const Config& cfg, const BitsetView& bitset) const {
if (!this->index_) {
LOG_KNOWHERE_WARNING_ << "range search on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}
if (!this->index_->is_trained) {
LOG_KNOWHERE_WARNING_ << "index not trained";
expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
return expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
}

auto nq = dataset.GetRows();
Expand Down Expand Up @@ -544,7 +544,7 @@ template <typename T>
expected<DataSetPtr>
IvfIndexNode<T>::GetVectorByIds(const DataSet& dataset) const {
if (!this->index_) {
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}
if (!this->index_->is_trained) {
return expected<DataSetPtr>::Err(Status::index_not_trained, "index not trained");
Expand Down Expand Up @@ -622,7 +622,7 @@ expected<DataSetPtr>
IvfIndexNode<faiss::IndexIVFFlat>::GetIndexMeta(const Config& config) const {
if (!index_) {
LOG_KNOWHERE_WARNING_ << "get index meta on empty index";
expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
return expected<DataSetPtr>::Err(Status::empty_index, "index not loaded");
}

auto ivf_index = dynamic_cast<faiss::IndexIVF*>(index_.get());
Expand Down