Skip to content

Commit

Permalink
Support empty strings (as distinct from null values)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmichaud committed May 1, 2018
1 parent b2e8c58 commit 6f47601
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions packages/perspective/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ namespace arrow {
for (t_uint32 i = 0; i < dsize; ++i) {
t_int32 bidx = offsets[i];
std::size_t es = offsets[i+1] - bidx;
assert(es > 0);
elem.assign(reinterpret_cast<char*>(data.data())+bidx, es);
t_uindex idx = vocab->get_interned(elem);
// Make sure there are no duplicates in the arrow dictionary
assert(idx == i);
}

Expand Down Expand Up @@ -385,12 +385,8 @@ _fill_col<std::string>(val dcol, t_col_sptr col, t_bool is_arrow)
for (t_int32 i = 0; i < nrows; ++i) {
t_int32 bidx = offsets[i];
std::size_t es = offsets[i+1] - bidx;
if (es > 0) {
elem.assign(reinterpret_cast<char*>(data.data())+bidx, es);
col->set_nth(i, elem);
} else {
col->clear(i);
}
elem.assign(reinterpret_cast<char*>(data.data())+bidx, es);
col->set_nth(i, elem);
}
}
} else {
Expand Down
Binary file modified packages/perspective/test/arrow/test-null.arrow
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/perspective/test/js/constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var arrow_result = [
"datetime(ms)": +(new Date("2018-01-26")), "datetime(us)": +(new Date("2018-01-26")), "datetime(ns)": +(new Date("2018-01-26"))},
{"f32": 3.5, "f64": 3.5, "i64": 3, "i32": 3, "i16": 3, "i8": 3, "bool": true, "char": "c", "dict": "c",
"datetime(ms)": +(new Date("2018-01-27")), "datetime(us)": +(new Date("2018-01-27")), "datetime(ns)": +(new Date("2018-01-27"))},
{"f32": 4.5, "f64": 4.5, "i64": 4, "i32": 4, "i16": 4, "i8": 4, "bool": false, "char": "d", "dict": "d",
{"f32": 4.5, "f64": 4.5, "i64": 4, "i32": 4, "i16": 4, "i8": 4, "bool": false, "char": "", "dict": "",
"datetime(ms)": +(new Date("2018-01-28")), "datetime(us)": +(new Date("2018-01-28")), "datetime(ns)": +(new Date("2018-01-28"))},
{"f32": null, "f64": null, "i64": null, "i32": null, "i16": null, "i8": null, "bool": null, "char": null, "dict": null,
"datetime(ms)": null, "datetime(us)": null, "datetime(ns)": null}
Expand Down

0 comments on commit 6f47601

Please sign in to comment.