Hermes
0.9.5-beta
Hierarchical Distributed I/O Buffering System
|
A container for Blobs. More...
#include <bucket.h>
Public Member Functions | |
Bucket () | |
Default constructor. More... | |
Bucket (const std::string &initial_name, std::shared_ptr< Hermes > const &h, Context ctx=Context()) | |
Constructor. More... | |
~Bucket () | |
Releases the Bucket, decrementing its reference count. More... | |
std::string | GetName () const |
Get the user-facing name of the Bucket. More... | |
u64 | GetId () const |
Get the internal ID of the bucket. More... | |
bool | IsValid () const |
Return true if the Bucket is valid. More... | |
size_t | GetTotalBlobSize () |
Return the total size in bytes of all Blobs in this Bucket. More... | |
template<typename T > | |
Status | Put (const std::string &name, const std::vector< T > &data) |
Put a Blob in this Bucket. More... | |
template<typename T > | |
Status | Put (const std::string &name, const std::vector< T > &data, Context &ctx) |
Put a Blob in this Bucket using context. More... | |
Status | Put (const std::string &name, const u8 *data, size_t size) |
Put a Blob in this Bucket. More... | |
Status | Put (const std::string &name, const u8 *data, size_t size, const Context &ctx) |
template<typename T > | |
Status | Put (const std::vector< std::string > &names, const std::vector< std::vector< T >> &blobs) |
Put a vector of Blobs. More... | |
template<typename T > | |
Status | Put (const std::vector< std::string > &names, const std::vector< std::vector< T >> &blobs, const Context &ctx) |
size_t | GetBlobSize (const std::string &name, const Context &ctx) |
Get the size in bytes of the Blob referred to by name . More... | |
size_t | GetBlobSize (Arena *arena, const std::string &name, const Context &ctx) |
size_t | Get (const std::string &name, Blob &user_blob) |
Get a blob from this Bucket. More... | |
size_t | Get (const std::string &name, Blob &user_blob, const Context &ctx) |
std::vector< size_t > | Get (const std::vector< std::string > &names, std::vector< Blob > &blobs, const Context &ctx) |
Retrieve multiple Blobs in one call. More... | |
size_t | Get (const std::string &name, void *user_blob, size_t blob_size, const Context &ctx) |
size_t | GetNext (u64 blob_index, Blob &user_blob) |
Given an ordering of Blobs, retrieves the Blob at index blob_index + 1. More... | |
size_t | GetNext (u64 blob_index, Blob &user_blob, const Context &ctx) |
size_t | GetNext (u64 blob_index, void *user_blob, size_t blob_size, const Context &ctx) |
std::vector< size_t > | GetNext (u64 blob_index, u64 count, std::vector< Blob > &blobs, const Context &ctx) |
Retrieves multiple blobs from the Bucket. More... | |
template<class Predicate > | |
Status | GetV (void *user_blob, Predicate pred, Context &ctx) |
Get Blob%(s) from this Bucket according to a predicate. More... | |
Status | DeleteBlob (const std::string &name) |
Delete a Blob from this Bucket. More... | |
Status | DeleteBlob (const std::string &name, const Context &ctx) |
Status | RenameBlob (const std::string &old_name, const std::string &new_name) |
Rename a Blob in this Bucket. More... | |
Status | RenameBlob (const std::string &old_name, const std::string &new_name, const Context &ctx) |
bool | ContainsBlob (const std::string &name) |
Returns true if the Bucket contains a Blob called name . More... | |
bool | BlobIsInSwap (const std::string &name) |
Return true if the Blob name is in swap space. More... | |
template<class Predicate > | |
std::vector< std::string > | GetBlobNames (Predicate pred, Context &ctx) |
Get a list of blob names filtered by pred . More... | |
Status | Rename (const std::string &new_name) |
Rename this Bucket. More... | |
Status | Rename (const std::string &new_name, const Context &ctx) |
Status | Persist (const std::string &file_name) |
Save this Bucket's Blobs to persistent storage. More... | |
Status | Persist (const std::string &file_name, const Context &ctx) |
void | OrganizeBlob (const std::string &blob_name, f32 epsilon, f32 custom_importance=-1.f) |
Allign blob_name 's access speed to its importance. More... | |
Status | Release () |
Release this Bucket. More... | |
Status | Release (const Context &ctx) |
Status | Destroy () |
Destroy this Bucket. More... | |
Status | Destroy (const Context &ctx) |
Public Attributes | |
std::shared_ptr< Hermes > | hermes_ |
Context | ctx_ |
Private Member Functions | |
template<typename T > | |
Status | PutInternal (const std::vector< std::string > &names, const std::vector< size_t > &sizes, const std::vector< std::vector< T >> &blobs, const Context &ctx) |
Internal version of Put, called by all overloads. More... | |
template<typename T > | |
Status | PlaceBlobs (std::vector< PlacementSchema > &schemas, const std::vector< std::vector< T >> &blobs, const std::vector< std::string > &names, const Context &ctx) |
Low-level version of Put. More... | |
Private Attributes | |
std::string | name_ |
hermes::BucketID | id_ |
A container for Blobs.
|
inline |
Default constructor.
Creates the "NULL" Bucket.
hermes::api::Bucket::~Bucket | ( | ) |
Releases the Bucket, decrementing its reference count.
This does not free any resources. To remove the Bucket's metadata and free its stored Blobs, see Bucket::Destroy.
std::string hermes::api::Bucket::GetName | ( | ) | const |
u64 hermes::api::Bucket::GetId | ( | ) | const |
bool hermes::api::Bucket::IsValid | ( | ) | const |
Return true if the Bucket is valid.
A valid Bucket is one that was successfully created, contains metadata entries, has a valid ID, and has not been destroyed. An invalid Bucket cannot be used.
size_t hermes::api::Bucket::GetTotalBlobSize | ( | ) |
Status hermes::api::Bucket::Put | ( | const std::string & | name, |
const std::vector< T > & | data | ||
) |
Status hermes::api::Bucket::Put | ( | const std::string & | name, |
const u8 * | data, | ||
size_t | size, | ||
const Context & | ctx | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
name | BLOB name |
data | BLOB data |
size | BLOB size |
ctx | context |
Status hermes::api::Bucket::Put | ( | const std::vector< std::string > & | names, |
const std::vector< std::vector< T >> & | blobs | ||
) |
Status hermes::api::Bucket::Put | ( | const std::vector< std::string > & | names, |
const std::vector< std::vector< T >> & | blobs, | ||
const Context & | ctx | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
names | BLOB names |
blobs | BLOB data |
ctx | context |
size_t hermes::api::Bucket::GetBlobSize | ( | const std::string & | name, |
const Context & | ctx | ||
) |
size_t hermes::api::Bucket::Get | ( | const std::string & | name, |
Blob & | user_blob | ||
) |
size_t hermes::api::Bucket::Get | ( | const std::string & | name, |
void * | user_blob, | ||
size_t | blob_size, | ||
const Context & | ctx | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Given an ordering of Blobs, retrieves the Blob at index blob_index
+ 1.
By default Blobs are arranged in the order in which they were Put. If user_blob.size() == 0, return the minimum buffer size needed. If user_blob.size() > 0, copy user_blob.size() bytes to user_blob and return user_blob.size()
blob_index | The starting index. |
user_blob | User-provided memory for the Blob. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
blob_index | The starting index. |
user_blob | User-provided memory for the Blob. |
ctx | context |
std::vector< size_t > hermes::api::Bucket::GetNext | ( | u64 | blob_index, |
u64 | count, | ||
std::vector< Blob > & | blobs, | ||
const Context & | ctx | ||
) |
Retrieves multiple blobs from the Bucket.
The Blobs retrieved are the next ones from the passed blob_index
Status hermes::api::Bucket::DeleteBlob | ( | const std::string & | name | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
name | The name of the Blob to delete. |
ctx | context |
Status hermes::api::Bucket::RenameBlob | ( | const std::string & | old_name, |
const std::string & | new_name | ||
) |
bool hermes::api::Bucket::ContainsBlob | ( | const std::string & | name | ) |
bool hermes::api::Bucket::BlobIsInSwap | ( | const std::string & | name | ) |
std::vector< std::string > hermes::api::Bucket::GetBlobNames | ( | Predicate | pred, |
Context & | ctx | ||
) |
Get a list of blob names filtered by pred
.
Status hermes::api::Bucket::Rename | ( | const std::string & | new_name | ) |
Rename this Bucket.
new_name | A new name for the Bucket. |
new_name
in bytes should be less than kMaxBucketNameSize.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
new_name | A new name for the Bucket. |
ctx | context |
Status hermes::api::Bucket::Persist | ( | const std::string & | file_name | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
file_name | The name of the file to persist the Blob's to. |
ctx | context |
void hermes::api::Bucket::OrganizeBlob | ( | const std::string & | blob_name, |
f32 | epsilon, | ||
f32 | custom_importance = -1.f |
||
) |
Allign blob_name
's access speed to its importance.
blob_name | The name of the Blob to organize. |
epsilon | The threshold within which the Blob's access time should match its importance. Constraint: 0 < epsilon <= 1. |
custom_importance | A measure of importance that overrides the internal importance of a Blob. Constraint: 0 <= custom_importance <= 1, where 1 signifies the most important Blob. By default the internal, statistics-based measure of importance is used. |
Status hermes::api::Bucket::Release | ( | ) |
Release this Bucket.
This function simply decrements the refcount to this Bucket in the Hermes metadata. To free resources associated with this Bucket, call Bucket::Destroy.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ctx | The Context for this call. |
Status hermes::api::Bucket::Destroy | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ctx | The Context for this call.. |
|
private |
Internal version of Put, called by all overloads.
|
private |
Low-level version of Put.
|
private |
The user-facing descriptor of this Bucket.
|
private |
The internal descriptor of this Bucket.
std::shared_ptr<Hermes> hermes::api::Bucket::hermes_ |
Context hermes::api::Bucket::ctx_ |
The api::Context that controls all operations on this Bucket.