diff --git a/src/engine/Server.cpp b/src/engine/Server.cpp index d9d1547a38..dd7a606b59 100644 --- a/src/engine/Server.cpp +++ b/src/engine/Server.cpp @@ -314,6 +314,10 @@ Awaitable Server::process( } else if (auto cmd = checkParameter("cmd", "get-settings")) { logCommand(cmd, "get server settings"); response = createJsonResponse(RuntimeParameters().toMap(), request); + } else if (auto cmd = checkParameter("cmd", "get-index-id")) { + logCommand(cmd, "get index ID"); + response = createOkResponse(index_.getIndexId(), request, + ad_utility::MediaType::textPlain); } // Ping with or without messsage. diff --git a/src/index/Index.cpp b/src/index/Index.cpp index d5ef9071ed..92e59337d2 100644 --- a/src/index/Index.cpp +++ b/src/index/Index.cpp @@ -281,6 +281,9 @@ const std::string& Index::getTextName() const { return pimpl_->getTextName(); } // ____________________________________________________________________________ const std::string& Index::getKbName() const { return pimpl_->getKbName(); } +// ____________________________________________________________________________ +const std::string& Index::getIndexId() const { return pimpl_->getIndexId(); } + // ____________________________________________________________________________ Index::NumNormalAndInternal Index::numTriples() const { return pimpl_->numTriples(); diff --git a/src/index/Index.h b/src/index/Index.h index a25766112b..f9a009f5cf 100644 --- a/src/index/Index.h +++ b/src/index/Index.h @@ -239,6 +239,8 @@ class Index { const std::string& getKbName() const; + const std::string& getIndexId() const; + NumNormalAndInternal numTriples() const; size_t getNofTextRecords() const; diff --git a/src/index/IndexImpl.cpp b/src/index/IndexImpl.cpp index b04835c589..b6f68438e1 100644 --- a/src/index/IndexImpl.cpp +++ b/src/index/IndexImpl.cpp @@ -897,6 +897,14 @@ void IndexImpl::readConfiguration() { loadRequestedDataMember("num-subjects-normal", numSubjectsNormal_); loadRequestedDataMember("num-objects-normal", numObjectsNormal_); loadRequestedDataMember("num-triples-normal", numTriplesNormal_); + + // Compute unique ID for this index. + // + // TODO: This is a simplistic way. It would be better to incorporate bytes + // from the index files. + indexId_ = absl::StrCat("#", getKbName(), ".", numTriplesNormal_, ".", + numSubjectsNormal_, ".", numPredicatesNormal_, ".", + numObjectsNormal_); } // ___________________________________________________________________________ diff --git a/src/index/IndexImpl.h b/src/index/IndexImpl.h index fae83d376d..2280923a3c 100644 --- a/src/index/IndexImpl.h +++ b/src/index/IndexImpl.h @@ -146,6 +146,7 @@ class IndexImpl { size_t numPredicatesNormal_ = 0; size_t numObjectsNormal_ = 0; size_t numTriplesNormal_ = 0; + string indexId_; /** * @brief Maps pattern ids to sets of predicate ids. */ @@ -387,6 +388,8 @@ class IndexImpl { const string& getKbName() const { return pso_.metaData().getName(); } + const string& getIndexId() const { return indexId_; } + size_t getNofTextRecords() const { return textMeta_.getNofTextRecords(); } size_t getNofWordPostings() const { return textMeta_.getNofWordPostings(); } size_t getNofEntityPostings() const {