Skip to content
This repository was archived by the owner on Jan 17, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion node-eclib.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,16 @@ ECLib.prototype = {
hd: 0,
ct: 0
};
}
},

/**
* Get alignement size corresponding to a size
* @param {Number} objSize - object size
* @return {Number} aligned size
*/
getAlignedDataSize: function(objSize) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have the mandatory documentation.

return addon.EclGetAlignedDataSize(this.ins_id, objSize);
},
}

module.exports = ECLib;
Expand Down
19 changes: 17 additions & 2 deletions src/cpp/libmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,23 @@ NAN_METHOD(EclVerifyStripeMetadata) {

NAN_METHOD(EclGetAlignedDataSize) {
Nan::HandleScope scope;
info.GetReturnValue()
.Set(Nan::New("C++ GetAlignedDataSize ").ToLocalChecked());

if (info.Length() != 2) {
Nan::ThrowTypeError("Wrong number of arguments EclGetAlignedDataSize");
return ;
}

ec_backend_t instance;
uint32_t aligned_size;

int desc = Nan::To<int>(info[0]).FromJust();
int64_t obj_size = Nan::To<int64_t>(info[1]).FromJust();

instance = liberasurecode_backend_instance_get_by_desc(desc);

aligned_size = get_aligned_data_size(instance, obj_size);

info.GetReturnValue().Set(aligned_size);
}

NAN_METHOD(EclGetMinimumEncodeSize) {
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/libmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <nan.h>
#include <liberasurecode/erasurecode.h>
#include <liberasurecode/erasurecode_helpers.h>
extern "C" {
#include <liberasurecode/erasurecode_helpers_ext.h>
#include <liberasurecode/erasurecode_postprocessing.h>
}

NAN_METHOD(EclCreate);
NAN_METHOD(EclDestroy);
Expand Down