Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SWIG][mmlspark] allow allocating more than int max array #2859

Merged
merged 1 commit into from
Apr 19, 2020
Merged
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
35 changes: 30 additions & 5 deletions swig/lightgbmlib.i
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@
%pointer_cast(int32_t *, void *, int32_t_to_voidp_ptr)
%pointer_cast(int64_t *, void *, int64_t_to_voidp_ptr)

%array_functions(double, doubleArray)
%array_functions(float, floatArray)
%array_functions(int, intArray)
%array_functions(long, longArray)

/* Custom pointer manipulation template */
%define %pointer_manipulation(TYPE, NAME)
%{
Expand Down Expand Up @@ -278,6 +273,36 @@ TYPE *NAME##_handle();

%enddef

%define %long_array_functions(TYPE,NAME)
%{
static TYPE *new_##NAME(int64_t nelements) { %}
%{ return new TYPE[nelements](); %}
imatiach-msft marked this conversation as resolved.
Show resolved Hide resolved
%{}

static void delete_##NAME(TYPE *ary) { %}
%{ delete [] ary; %}
%{}

static TYPE NAME##_getitem(TYPE *ary, int64_t index) {
return ary[index];
}
static void NAME##_setitem(TYPE *ary, int64_t index, TYPE value) {
ary[index] = value;
}
%}

TYPE *new_##NAME(int64_t nelements);
void delete_##NAME(TYPE *ary);
TYPE NAME##_getitem(TYPE *ary, int64_t index);
void NAME##_setitem(TYPE *ary, int64_t index, TYPE value);

%enddef

%long_array_functions(double, doubleArray)
%long_array_functions(float, floatArray)
%long_array_functions(int, intArray)
%long_array_functions(long, longArray)

%pointer_manipulation(void*, voidpp)

/* Allow dereferencing of void** to void* */
Expand Down