Skip to content

Commit

Permalink
Merge pull request #24 from jpmorganchase/arrow-binary-type
Browse files Browse the repository at this point in the history
Support binary type (for non-unicode string data)
  • Loading branch information
nmichaud authored Feb 6, 2018
2 parents e3e85c2 + 5907055 commit 2cca325
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/perspective/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,20 @@ _fill_col<std::string>(val dcol, t_col_sptr col, t_bool is_arrow)
default:
break;
}
} else if (dcol["constructor"]["name"].as<t_str>() == "Utf8Vector") {
val values = dcol["values"];
} else if (dcol["constructor"]["name"].as<t_str>() == "Utf8Vector" ||
dcol["constructor"]["name"].as<t_str>() == "BinaryVector") {
if (dcol["constructor"]["name"].as<t_str>() == "Utf8Vector") {
dcol = dcol["values"];
}

val vdata = values["data"];
val vdata = dcol["data"];
t_int32 vsize = vdata["length"].as<t_int32>();
std::vector<t_uint8> data;
data.reserve(vsize);
data.resize(vsize);
arrow::vecFromTypedArray(vdata, data.data(), vsize);

val voffsets = values["offsets"];
val voffsets = dcol["offsets"];
t_int32 osize = voffsets["length"].as<t_int32>();
std::vector<t_int32> offsets;
offsets.reserve(osize);
Expand Down
1 change: 1 addition & 0 deletions packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function load_arrow_buffer(data, names, types) {
let cdata = [];
for (let column of arrow.columns) {
switch (column.type) {
case 'Binary':
case 'Utf8':
types.push(__MODULE__.t_dtype.DTYPE_STR);
break;
Expand Down

0 comments on commit 2cca325

Please sign in to comment.