Skip to content

Commit

Permalink
Update vis, fix edge case with builders and slice
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Mar 16, 2021
1 parent e0d3713 commit 104158d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ import Standard.Database.Data.Column as Database_Column
# TODO add an initial offset to fully support lazy visualizations
## PRIVATE
prepare_visualization x max_rows = case x of
Dataframe_Table.Table _ -> here.make_json x
Dataframe_Column.Column _ -> here.make_json x.to_table
Dataframe_Table.Table _ ->
dataframe = x.take_start max_rows
all_rows_count = x.row_count
here.make_json dataframe all_rows_count
Dataframe_Column.Column _ ->
here.prepare_visualization x.to_table max_rows
Database_Table.Table _ _ _ _ ->
here.make_json <| x.to_dataframe max_rows
dataframe = x.to_dataframe max_rows
all_rows_count = x.row_count
here.make_json dataframe all_rows_count
Database_Column.Column _ _ _ _ _ ->
here.make_json <| x.to_table.to_dataframe max_rows
here.prepare_visualization x.to_table max_rows
_ -> x . to_json . to_text

## PRIVATE
make_json dataframe all_rows_count =
header = ["header", dataframe.columns.map .name]
data = ["data", dataframe.columns.map .to_vector . map (x -> x.take_start 2000) ]
pairs = [header,data]
columns = dataframe.columns
header = ["header", columns.map .name]
data = ["data", columns.map .to_vector]
all_rows = ["all_rows_count", all_rows_count]
pairs = [header, data, all_rows]
Json.from_pairs pairs . to_text
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public Storage run(DoubleStorage storage) {

@Override
public DoubleStorage slice(int offset, int limit) {
int newSize = Math.min(data.length - offset, limit);
int newSize = Math.min(size - offset, limit);
long[] newData = new long[newSize];
System.arraycopy(data, offset, newData, 0, newSize);
BitSet newMask = isMissing.get(offset, offset + limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public Storage run(LongStorage storage) {

@Override
public LongStorage slice(int offset, int limit) {
int newSize = Math.min(data.length - offset, limit);
int newSize = Math.min(size - offset, limit);
long[] newData = new long[newSize];
System.arraycopy(data, offset, newData, 0, newSize);
BitSet newMask = isMissing.get(offset, offset + limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected Storage run(ObjectStorage storage) {

@Override
public ObjectStorage slice(int offset, int limit) {
int newSize = Math.min(data.length - offset, limit);
int newSize = Math.min(size - offset, limit);
Object[] newData = new Object[newSize];
System.arraycopy(data, offset, newData, 0, newSize);
return new ObjectStorage(newData, newSize);
Expand Down
1 change: 1 addition & 0 deletions test/Table_Tests/src/Table_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ spec =
t_1 = Table.new [i_1, c_1, c_2, c_3] . set_index 'ix'

t_1.take_start 10 . at 'col' . to_vector . should_equal (t_1.at 'col' . to_vector)
t_1.at 'col' . take_start 10 . to_vector . should_equal (t_1.at 'col' . to_vector)

t_2 = t_1.take_start 2
t_2.index.to_vector . should_equal (t_1.index.to_vector . take_start 2)
Expand Down

0 comments on commit 104158d

Please sign in to comment.