Skip to content

Commit

Permalink
Fast path for single Blob Put
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Apr 28, 2022
1 parent d2285f2 commit c14f1c6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/api/bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,35 @@ Status Bucket::Put(const std::string &name, const u8 *data, size_t size,
}

if (result.Succeeded()) {
#if 0
std::vector<std::string> names{name};
// TODO(chogan): Create a PreallocatedMemory allocator for std::vector so
// that a single-blob-Put doesn't perform a copy
std::vector<Blob> blobs{Blob{data, data + size}};
result = Put(names, blobs, ctx);
#else

if (!IsBlobNameTooLong(name)) {
std::vector<PlacementSchema> schemas;
std::vector<size_t> sizes;
sizes.push_back(size);
result = CalculatePlacement(&hermes_->context_, &hermes_->rpc_, sizes,
schemas, ctx);

if (result.Succeeded()) {
hermes::Blob hermes_blob = {};
hermes_blob.data = (u8 *)data;
hermes_blob.size = size;
result = PlaceBlob(&hermes_->context_, &hermes_->rpc_, schemas[0],
hermes_blob, name, id_, ctx);
} else {
LOG(ERROR) << result.Msg();
}
} else {
result = BLOB_NAME_TOO_LONG;
LOG(ERROR) << result.Msg();
}
#endif
}

return result;
Expand Down

0 comments on commit c14f1c6

Please sign in to comment.