Skip to content

Commit

Permalink
Enable the 3rd argument of grnxx:map::BytesArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jul 18, 2013
1 parent 244d3f7 commit 505f353
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lib/grnxx/map/bytes_array.cpp
Expand Up @@ -49,12 +49,12 @@ BytesArrayHeader::BytesArrayHeader()
BytesArray::~BytesArray() {}

BytesArray *BytesArray::create(Storage *storage, uint32_t storage_node_id,
uint64_t) {
return create(storage, storage_node_id, 0, "");
uint64_t size) {
return create(storage, storage_node_id, size, "");
}

BytesArray *BytesArray::create(Storage *storage, uint32_t storage_node_id,
uint64_t, ValueArg default_value) {
uint64_t size, ValueArg default_value) {
if (!storage) {
GRNXX_ERROR() << "invalid argument: storage = nullptr";
throw LogicError();
Expand All @@ -64,7 +64,7 @@ BytesArray *BytesArray::create(Storage *storage, uint32_t storage_node_id,
GRNXX_ERROR() << "new grnxx::map::BytesArray failed";
throw MemoryError();
}
array->create_array(storage, storage_node_id, default_value);
array->create_array(storage, storage_node_id, size, default_value);
return array.release();
}

Expand Down Expand Up @@ -123,7 +123,7 @@ BytesArray::BytesArray()
pool_() {}

void BytesArray::create_array(Storage *storage, uint32_t storage_node_id,
ValueArg default_value) {
uint64_t size, ValueArg default_value) {
storage_ = storage;
uint64_t storage_node_size = sizeof(BytesArrayHeader) + default_value.size();
StorageNode storage_node =
Expand All @@ -135,7 +135,7 @@ void BytesArray::create_array(Storage *storage, uint32_t storage_node_id,
header_->default_value_size = default_value.size();
std::memcpy(header_ + 1, default_value.data(), default_value.size());
default_value_ = Value(header_ + 1, default_value.size());
ids_.reset(IDArray::create(storage, storage_node_id_, ID_ARRAY_SIZE,
ids_.reset(IDArray::create(storage, storage_node_id_, size,
INVALID_BYTES_ID));
pool_.reset(BytesPool::create(storage, storage_node_id_));
header_->ids_storage_node_id = ids_->storage_node_id();
Expand Down
8 changes: 3 additions & 5 deletions lib/grnxx/map/bytes_array.hpp
Expand Up @@ -45,16 +45,14 @@ class BytesArray {

using IDArray = Array<uint64_t, 65536, 4096>;

static constexpr uint64_t ID_ARRAY_SIZE = 1ULL << 40;

~BytesArray();

// Create an array.
static BytesArray *create(Storage *storage, uint32_t storage_node_id,
uint64_t dummy);
uint64_t size);
// Create an array with default value.
static BytesArray *create(Storage *storage, uint32_t storage_node_id,
uint64_t dummy, ValueArg default_value);
uint64_t size, ValueArg default_value);
// Open an array.
static BytesArray *open(Storage *storage, uint32_t storage_node_id);

Expand Down Expand Up @@ -91,7 +89,7 @@ class BytesArray {

// Create an array with the default value.
void create_array(Storage *storage, uint32_t storage_node_id,
ValueArg default_value);
uint64_t size, ValueArg default_value);
// Open an array.
void open_array(Storage *storage, uint32_t storage_node_id);
};
Expand Down

0 comments on commit 505f353

Please sign in to comment.