Skip to content

Commit

Permalink
Charwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemartinlogan committed Dec 3, 2024
1 parent b8fbb9d commit 5910373
Show file tree
Hide file tree
Showing 57 changed files with 94 additions and 8,390 deletions.
2 changes: 1 addition & 1 deletion hermes_adapters/filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Filesystem : public FilesystemIoClient {
HILOG(kDebug, "File not opened before by adapter")
// Normalize path strings
stat.path_ = stdfs::absolute(path).string();
auto path_shm = hipc::make_uptr<chi::charbuf>(stat.path_);
auto path_shm = hipc::make_uptr<chi::string>(stat.path_);
// Verify the bucket exists if not in CREATE mode
if (stat.adapter_mode_ == AdapterMode::kScratch &&
!stat.hflags_.Any(HERMES_FS_EXISTS) &&
Expand Down
2 changes: 1 addition & 1 deletion hermes_adapters/filesystem/filesystem_io_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class FilesystemIoClient {
virtual ~FilesystemIoClient() = default;

/** Get initial statistics from the backend */
virtual size_t GetBackendSize(const chi::charbuf &bkt_name) = 0;
virtual size_t GetBackendSize(const chi::string &bkt_name) = 0;

/** Write blob to backend */
virtual void WriteBlob(const std::string &bkt_name,
Expand Down
8 changes: 4 additions & 4 deletions hermes_adapters/mapper/abstract_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ struct BlobPlacement {
size_t blob_size_; /**< Size after offset to read */

/** create a BLOB name from index. */
static chi::charbuf CreateBlobName(size_t page) {
chi::charbuf buf(sizeof(page));
static chi::string CreateBlobName(size_t page) {
chi::string buf(sizeof(page));
hipc::LocalSerialize srl(buf);
srl << page;
return buf;
}

/** create a BLOB name from index. */
chi::charbuf CreateBlobName() const {
chi::charbuf buf(sizeof(page_));
chi::string CreateBlobName() const {
chi::string buf(sizeof(page_));
hipc::LocalSerialize srl(buf);
srl << page_;
return buf;
Expand Down
2 changes: 1 addition & 1 deletion hermes_adapters/mpiio/mpiio_fs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class MpiioFs : public Filesystem {
}

/** Get initial statistics from the backend */
size_t GetBackendSize(const chi::charbuf &bkt_name) override {
size_t GetBackendSize(const chi::string &bkt_name) override {
size_t true_size = 0;
std::string filename = bkt_name.str();
int fd = open(filename.c_str(), O_RDONLY);
Expand Down
2 changes: 1 addition & 1 deletion hermes_adapters/posix/posix_fs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class PosixFs : public hermes::adapter::Filesystem {
}

/** Get initial statistics from the backend */
size_t GetBackendSize(const chi::charbuf &bkt_name) override {
size_t GetBackendSize(const chi::string &bkt_name) override {
size_t true_size = 0;
std::string filename = bkt_name.str();
int fd = real_api_->open(filename.c_str(), O_RDONLY);
Expand Down
2 changes: 1 addition & 1 deletion hermes_adapters/stdio/stdio_fs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class StdioFs : public hermes::adapter::Filesystem {
}

/** Get initial statistics from the backend */
size_t GetBackendSize(const chi::charbuf &bkt_name) override {
size_t GetBackendSize(const chi::string &bkt_name) override {
size_t true_size = 0;
std::string filename = bkt_name.str();
int fd = open(filename.c_str(), O_RDONLY);
Expand Down
30 changes: 15 additions & 15 deletions include/hermes/bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Bucket {
mdm_ = &HERMES_CONF->mdm_;
id_ = mdm_->GetOrCreateTag(
mctx_, chi::DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
chi::charbuf(bkt_name), true,
chi::string(bkt_name), true,
backend_size, flags);
name_ = bkt_name;
}
Expand All @@ -65,11 +65,11 @@ class Bucket {
u32 flags = 0) {
mctx_ = mctx;
mdm_ = &HERMES_CONF->mdm_;
chi::charbuf x;
chi::string x;
id_ = mdm_->GetOrCreateTag(
mctx_,
chi::DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
chi::charbuf(bkt_name), true,
chi::string(bkt_name), true,
backend_size, flags, ctx);
name_ = bkt_name;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ class Bucket {
* Rename this bucket
* */
void Rename(const std::string &new_bkt_name) {
// mdm_->RenameTag(id_, chi::charbuf(new_bkt_name));
// mdm_->RenameTag(id_, chi::string(new_bkt_name));
}

/**
Expand Down Expand Up @@ -191,7 +191,7 @@ class Bucket {
BlobId GetBlobId(const std::string &blob_name) {
return mdm_->GetBlobId(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(blob_name));
id_, chi::string(blob_name));
}

/**
Expand Down Expand Up @@ -246,7 +246,7 @@ class Bucket {
BlobId blob_id = orig_blob_id;
bitfield32_t hermes_flags;
// Put to shared memory
chi::charbuf blob_name_buf(blob_name);
chi::string blob_name_buf(blob_name);
if constexpr (!ASYNC) {
if (blob_id.IsNull()) {
hermes_flags.SetBits(HERMES_GET_BLOB_ID);
Expand Down Expand Up @@ -435,7 +435,7 @@ class Bucket {
const Context &ctx = Context()) {
mdm_->AsyncReorganizeBlob(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(name), BlobId::GetNull(), score, true, ctx);
id_, chi::string(name), BlobId::GetNull(), score, true, ctx);
}

/**
Expand All @@ -446,7 +446,7 @@ class Bucket {
const Context &ctx = Context()) {
mdm_->AsyncReorganizeBlob(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(""), blob_id, score, true, ctx);
id_, chi::string(""), blob_id, score, true, ctx);
}

/**
Expand All @@ -461,7 +461,7 @@ class Bucket {
ctx.node_id_ = node_id;
mdm_->AsyncReorganizeBlob(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(""), blob_id, score, true, ctx);
id_, chi::string(""), blob_id, score, true, ctx);
}

/**
Expand All @@ -470,7 +470,7 @@ class Bucket {
size_t GetBlobSize(const BlobId &blob_id) {
return mdm_->GetBlobSize(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(""), blob_id);
id_, chi::string(""), blob_id);
}

/**
Expand All @@ -479,7 +479,7 @@ class Bucket {
size_t GetBlobSize(const std::string &name) {
return mdm_->GetBlobSize(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(name), BlobId::GetNull());
id_, chi::string(name), BlobId::GetNull());
}

/**
Expand All @@ -502,7 +502,7 @@ class Bucket {
LPointer<GetBlobTask> task;
task = mdm_->AsyncGetBlob(
mctx_, chi::DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(blob_name),
id_, chi::string(blob_name),
blob_id, blob_off,
blob_size, blob.shm_,
hermes_flags.bits_, ctx);
Expand Down Expand Up @@ -564,7 +564,7 @@ class Bucket {
if (blob.size() == 0) {
data_size = mdm_->GetBlobSize(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(blob_name),
id_, chi::string(blob_name),
orig_blob_id);
blob.resize(data_size);
}
Expand Down Expand Up @@ -697,7 +697,7 @@ class Bucket {
bool ContainsBlob(const std::string &blob_name) {
BlobId new_blob_id = mdm_->GetBlobId(
mctx_, DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
id_, chi::charbuf(blob_name));
id_, chi::string(blob_name));
return !new_blob_id.IsNull();
}

Expand All @@ -707,7 +707,7 @@ class Bucket {
void RenameBlob(const BlobId &blob_id,
std::string new_blob_name,
Context &ctx) {
// mdm_->RenameBlob(id_, blob_id, chi::charbuf(new_blob_name));
// mdm_->RenameBlob(id_, blob_id, chi::string(new_blob_name));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions include/hermes/data_stager/binary_stager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BinaryFileStager : public AbstractStager {
static std::string BuildFileParams(size_t page_size,
u32 flags = 0,
size_t elmt_size = 1) {
chi::charbuf params(32);
chi::string params(32);
page_size = (page_size / elmt_size) * elmt_size;
hipc::LocalSerialize srl(params);
srl << std::string("file");
Expand Down Expand Up @@ -103,7 +103,7 @@ class BinaryFileStager : public AbstractStager {
client.PutBlob(
mctx, chi::DomainQuery::GetDirectHash(chi::SubDomainId::kLocalContainers, 0),
tag_id,
chi::charbuf(blob_name),
chi::string(blob_name),
hermes::BlobId::GetNull(),
0, real_size, blob.shm_, score,
TASK_DATA_OWNER, 0, ctx);
Expand Down
2 changes: 1 addition & 1 deletion include/hermes/data_stager/stager_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StagerFactory {
srl >> protocol;

std::unique_ptr<AbstractStager> stager;
if (protocol == "file") {
if (protocol == "file" || protocol == "") {
stager = std::make_unique<BinaryFileStager>();
} else if (protocol == "parquet") {
} else if (protocol == "hdf5") {
Expand Down
14 changes: 7 additions & 7 deletions include/hermes/hermes_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ enum class TraitType {
};

/** Represents a blob */
typedef chi::charbuf Blob;
typedef chi::charwrap Blob;

/** Supported data placement policies */
enum class PlacementPolicy {
Expand Down Expand Up @@ -239,7 +239,7 @@ struct BufferInfo : public chi::Block {
struct BlobInfo {
TagId tag_id_; /**< Tag the blob is on */
BlobId blob_id_; /**< Unique ID of the blob */
chi::charbuf name_; /**< Name of the blob (without tag_id) */
chi::string name_; /**< Name of the blob (without tag_id) */
std::vector<BufferInfo> buffers_; /**< Set of buffers */
std::vector<TagId> tags_; /**< Set of tags */
size_t blob_size_; /**< The overall size of the blob */
Expand Down Expand Up @@ -295,26 +295,26 @@ struct BlobInfo {
}

/** Get the globally unique blob name */
static const chi::charbuf GetBlobNameWithBucket(
static const chi::string GetBlobNameWithBucket(
const TagId &tag_id,
const chi::charbuf &blob_name) {
chi::charbuf new_name(sizeof(TagId) + blob_name.size());
const chi::string &blob_name) {
chi::string new_name(sizeof(TagId) + blob_name.size());
hipc::LocalSerialize srl(new_name);
srl << tag_id;
srl << blob_name;
return new_name;
}

/** Return the unique blob name for blob_id_map */
chi::charbuf GetBlobNameWithBucket() {
chi::string GetBlobNameWithBucket() {
return GetBlobNameWithBucket(tag_id_, name_);
}
};

/** Data structure used to store Bucket information */
struct TagInfo {
TagId tag_id_;
chi::charbuf name_;
chi::string name_;
std::list<BlobId> blobs_;
std::list<Task *> traits_;
size_t internal_size_;
Expand Down
26 changes: 13 additions & 13 deletions tasks/hermes_core/include/hermes_core/hermes_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Client : public ModuleClient {
HSHM_ALWAYS_INLINE
TagId GetOrCreateTag(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const chi::charbuf &tag_name,
const chi::string &tag_name,
bool blob_owner,
size_t backend_size,
u32 flags,
Expand All @@ -78,7 +78,7 @@ class Client : public ModuleClient {
/** Get tag ID */
TagId GetTagId(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const chi::charbuf &tag_name) {
const chi::string &tag_name) {
LPointer<GetTagIdTask> task =
AsyncGetTagId(mctx, dom_query, tag_name);
task->Wait();
Expand All @@ -89,13 +89,13 @@ class Client : public ModuleClient {
CHI_TASK_METHODS(GetTagId);

/** Get tag name */
hshm::string GetTagName(const hipc::MemContext &mctx,
chi::string GetTagName(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const TagId &tag_id) {
LPointer<GetTagNameTask> task =
AsyncGetTagName(mctx, dom_query, tag_id);
task->Wait();
hshm::string tag_name(task->tag_name_.str());
chi::string tag_name(task->tag_name_.str());
CHI_CLIENT->DelTask(mctx, task);
return tag_name;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ class Client : public ModuleClient {
BlobId GetOrCreateBlob(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const TagId &tag_id,
const chi::charbuf &blob_name) {
const chi::string &blob_name) {
LPointer<GetOrCreateBlobIdTask> task =
AsyncGetOrCreateBlobId(mctx, dom_query, tag_id, blob_name);
task->Wait();
Expand All @@ -208,7 +208,7 @@ class Client : public ModuleClient {
size_t PutBlob(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
TagId tag_id,
const chi::charbuf &blob_name,
const chi::string &blob_name,
const BlobId &blob_id,
size_t blob_off, size_t blob_size,
const hipc::Pointer &blob,
Expand Down Expand Up @@ -239,7 +239,7 @@ class Client : public ModuleClient {
u32 hermes_flags,
const Context &ctx = Context()) {
LPointer<GetBlobTask> task =
AsyncGetBlob(mctx, dom_query, tag_id, chi::charbuf(""),
AsyncGetBlob(mctx, dom_query, tag_id, chi::string(""),
blob_id, off, data_size, data, hermes_flags, ctx);
task->Wait();
data = task->data_;
Expand Down Expand Up @@ -299,7 +299,7 @@ class Client : public ModuleClient {
BlobId GetBlobId(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const TagId &tag_id,
const chi::charbuf &blob_name) {
const chi::string &blob_name) {
LPointer<GetBlobIdTask> task =
AsyncGetBlobId(mctx, dom_query, tag_id, blob_name);
task->Wait();
Expand Down Expand Up @@ -331,7 +331,7 @@ class Client : public ModuleClient {
size_t GetBlobSize(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const TagId &tag_id,
const chi::charbuf &blob_name,
const chi::string &blob_name,
const BlobId &blob_id) {
LPointer<GetBlobSizeTask> task =
AsyncGetBlobSize(mctx, dom_query, tag_id, blob_name, blob_id);
Expand Down Expand Up @@ -461,8 +461,8 @@ class Client : public ModuleClient {
void RegisterStager(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const hermes::BucketId &bkt_id,
const chi::charbuf &tag_name,
const chi::charbuf &params) {
const chi::string &tag_name,
const chi::string &params) {
LPointer<RegisterStagerTask> task =
AsyncRegisterStager(mctx, dom_query, bkt_id, tag_name, params);
task->Wait();
Expand All @@ -487,7 +487,7 @@ class Client : public ModuleClient {
void StageIn(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const BucketId &bkt_id,
const chi::charbuf &blob_name,
const chi::string &blob_name,
float score) {
LPointer<StageInTask> task =
AsyncStageIn(mctx, dom_query, bkt_id, blob_name, score);
Expand All @@ -501,7 +501,7 @@ class Client : public ModuleClient {
void StageOut(const hipc::MemContext &mctx,
const DomainQuery &dom_query,
const BucketId &bkt_id,
const chi::charbuf &blob_name,
const chi::string &blob_name,
const hipc::Pointer &data,
size_t data_size,
u32 task_flags) {
Expand Down
Loading

0 comments on commit 5910373

Please sign in to comment.