Skip to content

Commit

Permalink
dnd + alp info
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Dec 18, 2024
1 parent 08b8c42 commit 7f6d618
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 91 deletions.
203 changes: 178 additions & 25 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dioxus = { version = "0.6.0" }
humansize = "2.1.3"

# Needed for running Vortex operations
vortex = { git = "https://github.com/spiraldb/vortex.git", rev = "49bd8d6a" }
vortex = { git = "https://github.com/spiraldb/vortex.git", rev = "e64ab4a" }

[features]
default = ["web"]
Expand Down
58 changes: 32 additions & 26 deletions assets/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,6 @@ video {
display: block;
}

.inline-block {
display: inline-block;
}

.flex {
display: flex;
}
Expand All @@ -596,6 +592,14 @@ video {
height: 0.125rem;
}

.h-full {
height: 100%;
}

.h-screen {
height: 100vh;
}

.max-h-8 {
max-height: 2rem;
}
Expand All @@ -608,16 +612,8 @@ video {
width: 100%;
}

.w-1\/2 {
width: 50%;
}

.w-7\/12 {
width: 58.333333%;
}

.w-96 {
width: 24rem;
.w-screen {
width: 100vw;
}

.min-w-max {
Expand All @@ -629,22 +625,10 @@ video {
max-width: 2rem;
}

.max-w-96 {
max-width: 24rem;
}

.max-w-80 {
max-width: 20rem;
}

.table-auto {
table-layout: auto;
}

.table-fixed {
table-layout: fixed;
}

.border-collapse {
border-collapse: collapse;
}
Expand Down Expand Up @@ -695,6 +679,10 @@ video {
border-width: 1px;
}

.border-2 {
border-width: 2px;
}

.border-b {
border-bottom-width: 1px;
}
Expand All @@ -703,6 +691,14 @@ video {
border-top-width: 0px;
}

.border-dashed {
border-style: dashed;
}

.border-double {
border-style: double;
}

.border-gray-100\/10 {
border-color: rgb(243 244 246 / 0.1);
}
Expand All @@ -716,6 +712,16 @@ video {
border-color: rgb(250 250 250 / 0.1);
}

.border-white {
--tw-border-opacity: 1;
border-color: rgb(255 255 255 / var(--tw-border-opacity, 1));
}

.border-teal-200 {
--tw-border-opacity: 1;
border-color: rgb(153 246 228 / var(--tw-border-opacity, 1));
}

.bg-lime-800 {
--tw-bg-opacity: 1;
background-color: rgb(63 98 18 / var(--tw-bg-opacity, 1));
Expand Down
16 changes: 6 additions & 10 deletions src/components/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ pub fn ArrayView(
// If there are previous history elements, we present a Back button which allows us to
// pop the stack and go back up to the parent element.
if history_stack().len() > 1 {
div {
class: "flex flex-row items-center",
div { class: "flex flex-row items-center",
button {
class: "btn btn-primary bg-lime-800 text-lime-400 hover:bg-lime-600/75 px-4 py-2 rounded-md",
onclick: move |_| {
// Pop the stack to go back to the parent.
history_stack.write().pop_front();
},
"Back"
Expand Down Expand Up @@ -144,17 +142,17 @@ fn ArraySummary(array: SharedPtr<ArrayData>, file_name: String) -> Element {
#[component]
pub fn ArrayChildren(mut history_stack: Signal<VecDeque<SharedPtr<ArrayData>>>) -> Element {
let array = history_stack()[0].clone();

rsx! {
Heading { text: "Child Arrays" }

p {
class: "p-4 font-regular font-sans text-sm italic text-slate-300/30",
p { class: "p-4 font-regular font-sans text-sm italic text-slate-300/30",
"Click one of the Child Arrays to explore further"
}

table { class: "table-auto w-full min-w-max max-h-96 overflow-y-scroll text-left border-collapse",
tbody { class: "border-b border-1 border-zinc-50/10",
for (idx , child) in array.children().iter().cloned().enumerate() {
for (idx , (name , child)) in array.named_children().into_iter().enumerate() {
tr {
class: "font-normal border-b border-1 border-zinc-50/10",
// Interactivity
Expand All @@ -164,13 +162,11 @@ pub fn ArrayChildren(mut history_stack: Signal<VecDeque<SharedPtr<ArrayData>>>)
onclick: move |_| {
let child = child.clone();
tracing::info!("descending into the {idx} child");
history_stack
.write()
.push_front(SharedPtr(Arc::new(child)));
history_stack.write().push_front(SharedPtr(Arc::new(child)));
},
td { class: "p-2",
p { class: "block font-sans text-sm antialiased leading-normal",
"Child {idx}"
"{name}"
}
}
td { class: "p-2",
Expand Down
46 changes: 46 additions & 0 deletions src/components/array_info/alp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use crate::components::Heading;
use crate::SharedPtr;
use dioxus::prelude::*;
use vortex::alp::{ALPArray, Exponents};

#[component]
pub fn ALPInfo(array: SharedPtr<ALPArray>) -> Element {
let Exponents { e, f } = array.exponents();

rsx! {
Heading { text: "ALP Encoding Parameters" }

div { class: "relative flex flex-col max-w-7/12 bg-clip-border",
table { class: "table-auto w-full min-w-max text-left border-collapse",
tbody { class: "border-b border-1 border-zinc-50/10",
tr { class: "font-normal hover:bg-neutral-800/75 border-b border-1 border-zinc-50/10",
td { class: "p-1",
p { class: "block font-sans font-bold text-sm antialiased leading-normal",
"Exponent (e)"
}
}
td { class: "p-1",
p { class: "block font-mono text-sm antialiased leading-normal",
"{e}"
}
}
}
tr { class: "font-normal hover:bg-neutral-800/75 border-b border-1 border-zinc-50/10",
td { class: "p-1",
p { class: "block font-sans font-bold text-sm antialiased leading-normal",
"Factor (f)"
}
}
td { class: "p-1",
p { class: "block font-mono text-sm antialiased leading-normal",
"{f}"
}
}
}
}
}
}
}
}

// TODO(aduffy): ALP-RD
11 changes: 9 additions & 2 deletions src/components/array_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ use vortex::{
runend::{RunEndArray, RunEndEncoding},
ArrayData,
};

use vortex::alp::{ALPArray, ALPEncoding};
use crate::components::array_info::alp::ALPInfo;
use crate::SharedPtr;

pub mod alp;
pub mod bitpacked;
pub mod constant;
pub mod dict;
Expand Down Expand Up @@ -66,10 +68,15 @@ pub fn EncodingInfo(array: SharedPtr<ArrayData>) -> Element {
rsx! {
ConstantInfo { array }
}
} else if encoding == ALPEncoding::ID {
let array = SharedPtr(Arc::new(ALPArray::try_from(array)?));
rsx! {
ALPInfo { array }
}
}
// Fallback
else {
// Empty component
rsx! {}
rsx! { }
}
}
2 changes: 1 addition & 1 deletion src/components/array_info/runend.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dioxus::prelude::*;
use vortex::{compute::try_cast, dtype::PType, runend::RunEndArray, ArrayLen, IntoArrayVariant};
use vortex::{compute::try_cast, dtype::PType, runend::RunEndArray, IntoArrayVariant};

use crate::SharedPtr;

Expand Down
5 changes: 2 additions & 3 deletions src/components/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ pub fn SchemaTable(dtype: DType) -> Element {
rsx! {
div { class: "relative flex flex-col max-w-7/12 bg-clip-border",
table { class: "table-auto w-full min-w-max text-left border-collapse",
thead {
class: "bg-neutral-700 border-b border-1 border-zinc-50/10",
thead { class: "bg-neutral-700 border-b border-1 border-zinc-50/10",
tr {
th { class: "p-4",
p { class: "block font-sans text-sm antialiased font-normal leading-none opacity-70",
Expand All @@ -56,7 +55,7 @@ pub fn SchemaTable(dtype: DType) -> Element {
}

tbody {
for (field_name, field_type) in names_and_types {
for (field_name , field_type) in names_and_types {
tr { class: "font-normal hover:bg-neutral-800/75 border-b border-1 border-zinc-50/10",
td { class: "p-1",
p { class: "block font-sans font-bold text-sm antialiased leading-normal",
Expand Down
2 changes: 1 addition & 1 deletion src/components/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn StatsTable(stats: StatsSet) -> Element {
div { class: "relative flex flex-col max-w-7/12 bg-clip-border",
table { class: "table-auto w-full min-w-max text-left border-collapse",
tbody {
for (stat , value) in stats.clone().into_iter().map(|(s, v)| (s, v.into_value())) {
for (stat , value) in stats.clone().into_iter().map(|(s, v)| (s, v)) {
tr { class: "font-normal hover:bg-neutral-800/75 border-b border-1 border-zinc-50/10",
td { class: "p-2",
p { class: "block font-sans text-sm antialiased leading-normal",
Expand Down
Loading

0 comments on commit 7f6d618

Please sign in to comment.