Add fetchBatch Backend interface

This commit is contained in:
Vinnie Falco
2015-03-18 12:23:36 -07:00
committed by Nik Bougalis
parent 41c68f4bbc
commit 1b49776819
6 changed files with 75 additions and 0 deletions

View File

@@ -65,6 +65,16 @@ public:
*/
virtual Status fetch (void const* key, NodeObject::Ptr* pObject) = 0;
/** Return `true` if batch fetches are optimized. */
virtual
bool
canFetchBatch() = 0;
/** Fetch a batch synchronously. */
virtual
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) = 0;
/** Store a single object.
Depending on the implementation this may happen immediately
or deferred using a scheduled task.

View File

@@ -128,6 +128,19 @@ public:
return ok;
}
bool
canFetchBatch() override
{
return false;
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
store (NodeObject::ref object)
{

View File

@@ -148,6 +148,19 @@ public:
return status;
}
bool
canFetchBatch() override
{
return false;
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
do_insert (std::shared_ptr <NodeObject> const& no)
{

View File

@@ -53,6 +53,19 @@ public:
return notFound;
}
bool
canFetchBatch() override
{
return false;
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
store (NodeObject::ref object)
{

View File

@@ -266,6 +266,19 @@ public:
return status;
}
bool
canFetchBatch() override
{
return false;
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
store (NodeObject::ref object)
{

View File

@@ -250,12 +250,25 @@ public:
return status;
}
bool
canFetchBatch() override
{
return false;
}
void
store (NodeObject::ref object)
{
storeBatch(Batch{object});
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
storeBatch (Batch const& batch)
{