Skip to content

Commit

Permalink
1-sided contexts cannot be column_only
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Mar 14, 2019
1 parent 6986ed2 commit 0b06ac5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cpp/perspective/src/cpp/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ t_config::t_config(const std::vector<std::string>& row_pivots, const t_aggspec&

t_config::t_config(const std::vector<t_pivot>& row_pivots,
const std::vector<t_aggspec>& aggregates, t_filter_op combiner,
const std::vector<t_fterm>& fterms, bool column_only)
const std::vector<t_fterm>& fterms)
: m_row_pivots(row_pivots)
, m_column_only(column_only)
, m_aggregates(aggregates)
, m_totals(TOTALS_BEFORE)
, m_combiner(combiner)
Expand Down
8 changes: 4 additions & 4 deletions cpp/perspective/src/cpp/data_slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ t_data_slice<CTX_T>::get_column_indices() const {
template <typename CTX_T>
bool
t_data_slice<CTX_T>::is_column_only() const {
auto config = m_ctx->get_config();
return config.is_column_only();
return false;
}

template <>
bool
t_data_slice<t_ctx0>::is_column_only() const {
return false;
t_data_slice<t_ctx2>::is_column_only() const {
auto config = m_ctx->get_config();
return config.is_column_only();
}

template <typename CTX_T>
Expand Down
9 changes: 4 additions & 5 deletions cpp/perspective/src/cpp/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,6 @@ namespace binding {
auto schema = gnode->get_tblschema();
t_config view_config = make_view_config<val>(schema, separator, date_parser, config);

bool column_only = view_config.is_column_only();
auto aggregates = view_config.get_aggregates();
auto row_pivots = view_config.get_row_pivots();
auto filter_op = view_config.get_combiner();
Expand All @@ -1676,7 +1675,7 @@ namespace binding {
}

auto ctx = make_context_one(schema, row_pivots, filter_op, filters, aggregates, sorts,
pivot_depth, column_only, pool, gnode, name);
pivot_depth, pool, gnode, name);

auto view_ptr
= std::make_shared<View<t_ctx1>>(pool, ctx, gnode, name, separator, view_config);
Expand Down Expand Up @@ -1765,9 +1764,9 @@ namespace binding {
std::shared_ptr<t_ctx1>
make_context_one(t_schema schema, std::vector<t_pivot> pivots, t_filter_op combiner,
std::vector<t_fterm> filters, std::vector<t_aggspec> aggregates,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, bool column_only, t_pool* pool,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, t_pool* pool,
std::shared_ptr<t_gnode> gnode, std::string name) {
auto cfg = t_config(pivots, aggregates, combiner, filters, column_only);
auto cfg = t_config(pivots, aggregates, combiner, filters);
auto ctx1 = std::make_shared<t_ctx1>(schema, cfg);

ctx1->init();
Expand Down Expand Up @@ -2110,7 +2109,7 @@ EMSCRIPTEN_BINDINGS(perspective) {
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx0>>>("shared_ptr<t_data_slice<t_ctx0>>>")
.function<const std::vector<std::string>&>(
"get_column_names", &t_data_slice<t_ctx0>::get_column_names);

class_<t_data_slice<t_ctx1>>("t_data_slice_ctx1")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx1>>>("shared_ptr<t_data_slice<t_ctx1>>>")
.function<const std::vector<std::string>&>(
Expand Down
3 changes: 1 addition & 2 deletions cpp/perspective/src/cpp/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ View<CTX_T>::View(t_pool* pool, std::shared_ptr<CTX_T> ctx, std::shared_ptr<t_gn
m_aggregates = m_config.get_aggregates();
m_filters = m_config.get_fterms();
m_sorts = m_config.get_sortspecs();
m_column_only = m_config.is_column_only();
}

template <typename CTX_T>
Expand Down Expand Up @@ -411,7 +410,7 @@ View<CTX_T>::get_step_delta(t_index bidx, t_index eidx) const {
template <typename CTX_T>
bool
View<CTX_T>::is_column_only() const {
return m_column_only;
return m_config.is_column_only();
}

/******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion cpp/perspective/src/include/perspective/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ namespace binding {
*/
std::shared_ptr<t_ctx1> make_context_one(t_schema schema, std::vector<t_pivot> pivots,
t_filter_op combiner, std::vector<t_fterm> filters, std::vector<t_aggspec> aggregates,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, bool column_only, t_pool* pool,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, t_pool* pool,
std::shared_ptr<t_gnode> gnode, std::string name);

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/perspective/src/include/perspective/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PERSPECTIVE_EXPORT t_config {
t_config(const std::vector<std::string>& row_pivots, const t_aggspec& agg);

t_config(const std::vector<t_pivot>& row_pivots, const std::vector<t_aggspec>& aggregates,
t_filter_op combiner, const std::vector<t_fterm>& fterms, bool column_only);
t_filter_op combiner, const std::vector<t_fterm>& fterms);

t_config(const std::vector<std::string>& row_pivots,
const std::vector<t_aggspec>& aggregates, t_filter_op combiner,
Expand Down
6 changes: 2 additions & 4 deletions packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,13 @@ export default function(Module) {
for (let cidx = start_col; cidx < end_col; cidx++) {
const col_name = col_names[cidx];
if (cidx === 0) {
if (!this.column_only) {
let row_path = slice.get_row_path(ridx);
const row_path = slice.get_row_path(ridx);
formatter.initColumnValue(data, row, col_name);
for (let i = 0; i < row_path.size(); i++) {
const value = clean_data(__MODULE__.scalar_vec_to_val(row_path, i));
const value = __MODULE__.scalar_vec_to_val(row_path, i);
formatter.addColumnValue(data, row, col_name, value);
}
row_path.delete();
}
} else {
const value = __MODULE__.get_from_data_slice_one(slice, ridx, cidx);
formatter.setColumnValue(data, row, col_name, value);
Expand Down

0 comments on commit 0b06ac5

Please sign in to comment.