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; 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. /** Store a single object.
Depending on the implementation this may happen immediately Depending on the implementation this may happen immediately
or deferred using a scheduled task. or deferred using a scheduled task.

View File

@@ -128,6 +128,19 @@ public:
return ok; 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 void
store (NodeObject::ref object) store (NodeObject::ref object)
{ {

View File

@@ -148,6 +148,19 @@ public:
return status; 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 void
do_insert (std::shared_ptr <NodeObject> const& no) do_insert (std::shared_ptr <NodeObject> const& no)
{ {

View File

@@ -53,6 +53,19 @@ public:
return notFound; 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 void
store (NodeObject::ref object) store (NodeObject::ref object)
{ {

View File

@@ -266,6 +266,19 @@ public:
return status; 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 void
store (NodeObject::ref object) store (NodeObject::ref object)
{ {

View File

@@ -250,12 +250,25 @@ public:
return status; return status;
} }
bool
canFetchBatch() override
{
return false;
}
void void
store (NodeObject::ref object) store (NodeObject::ref object)
{ {
storeBatch(Batch{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 void
storeBatch (Batch const& batch) storeBatch (Batch const& batch)
{ {