Skip to content

Commit 8c2cc06

Browse files
committed
[HSTACK] feat: add ability to build Kernel Snapshot and Table Configuration manually
- This is used to pass in schemas
1 parent 8ed0903 commit 8c2cc06

4 files changed

Lines changed: 46 additions & 15 deletions

File tree

kernel/src/hacks.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::sync::OnceLock;
2+
use crate::schema::SchemaRef;
3+
use crate::Snapshot;
4+
use crate::table_configuration::{PhysicalSchemas, TableConfiguration};
5+
6+
pub fn new_kernel_table_configuration(
7+
input: &TableConfiguration, logical: &SchemaRef, physical: SchemaRef) -> TableConfiguration {
8+
TableConfiguration {
9+
metadata: input.metadata.clone(),
10+
protocol: input.protocol.clone(),
11+
logical_schema: logical.clone(),
12+
physical_schemas: PhysicalSchemas {
13+
full: physical.clone(),
14+
without_partition: OnceLock::new(),
15+
},
16+
table_properties: Default::default(),
17+
column_mapping_mode: input.column_mapping_mode.clone(),
18+
table_root: input.table_root.clone(),
19+
version: input.version.clone(),
20+
}
21+
}
22+
23+
pub fn new_kernel_snapshot(input: &Snapshot, table_configuration: TableConfiguration) -> Snapshot {
24+
Snapshot {
25+
span: input.span.clone(),
26+
log_segment: input.log_segment.clone(),
27+
table_configuration,
28+
lazy_crc: input.lazy_crc.clone(),
29+
}
30+
}

kernel/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub mod table_features;
112112
pub mod table_properties;
113113
pub mod transaction;
114114
pub mod transforms;
115+
pub mod hacks;
115116

116117
pub use crc::{FileSizeHistogram, FileStats};
117118
pub use log_path::LogPath;

kernel/src/snapshot/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ pub enum CheckpointWriteResult {
6363
/// have a defined schema (which may change over time for any given table), specific version, and
6464
/// frozen log segment.
6565
pub struct Snapshot {
66-
span: tracing::Span,
67-
log_segment: LogSegment,
68-
table_configuration: TableConfiguration,
69-
lazy_crc: Arc<LazyCrc>,
66+
pub span: tracing::Span,
67+
pub log_segment: LogSegment,
68+
pub table_configuration: TableConfiguration,
69+
pub lazy_crc: Arc<LazyCrc>,
7070
}
7171

7272
impl PartialEq for Snapshot {

kernel/src/table_configuration.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ fn strip_metadata(schema: SchemaRef) -> SchemaRef {
7474
/// - `full`: physical representations of all columns from [`TableConfiguration::logical_schema`].
7575
/// - `without_partition`: lazily computed variant that excludes partition columns.
7676
#[derive(Debug, Clone, Eq)]
77-
struct PhysicalSchemas {
78-
full: SchemaRef,
79-
without_partition: OnceLock<SchemaRef>,
77+
pub struct PhysicalSchemas {
78+
pub full: SchemaRef,
79+
pub without_partition: OnceLock<SchemaRef>,
8080
}
8181

8282
impl PhysicalSchemas {
@@ -111,15 +111,15 @@ impl PartialEq for PhysicalSchemas {
111111
#[internal_api]
112112
#[derive(Debug, Clone, PartialEq, Eq)]
113113
pub(crate) struct TableConfiguration {
114-
metadata: Metadata,
115-
protocol: Protocol,
114+
pub metadata: Metadata,
115+
pub protocol: Protocol,
116116
/// Logical schema: field names are the user-facing (logical) column names.
117-
logical_schema: SchemaRef,
118-
physical_schemas: PhysicalSchemas,
119-
table_properties: TableProperties,
120-
column_mapping_mode: ColumnMappingMode,
121-
table_root: Url,
122-
version: Version,
117+
pub logical_schema: SchemaRef,
118+
pub physical_schemas: PhysicalSchemas,
119+
pub table_properties: TableProperties,
120+
pub column_mapping_mode: ColumnMappingMode,
121+
pub table_root: Url,
122+
pub version: Version,
123123
}
124124

125125
impl TableConfiguration {

0 commit comments

Comments
 (0)