Skip to content

Commit 68d7250

Browse files
committed
fixup! Add edge crate
Create appendable segment when loading/initializing edge shard
1 parent 621c940 commit 68d7250

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

lib/edge/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{fmt, fs};
66

77
use common::counter::hardware_accumulator::HwMeasurementAcc;
88
use common::counter::hardware_counter::HardwareCounterCell;
9+
use common::save_on_disk::SaveOnDisk;
910
use parking_lot::Mutex;
1011
use segment::common::operation_error::{OperationError, OperationResult};
1112
use segment::data_types::query_context::QueryContext;
@@ -125,6 +126,31 @@ impl Shard {
125126
segments.add_new(segment);
126127
}
127128

129+
if !segments.has_appendable_segment() {
130+
let Some(config) = &config else {
131+
return Err(OperationError::service_error(
132+
"segment config is not provided and no segments were loaded",
133+
));
134+
};
135+
136+
let payload_index_schema_path = path.join("payload_index.json");
137+
let payload_index_schema = SaveOnDisk::load_or_init_default(&payload_index_schema_path)
138+
.map_err(|err| {
139+
OperationError::service_error(format!(
140+
"failed to initialize temporary payload index schema file {}: {err}",
141+
payload_index_schema_path.display(),
142+
))
143+
})?;
144+
145+
segments.create_appendable_segment(
146+
&segments_path,
147+
config.clone(),
148+
Arc::new(payload_index_schema),
149+
)?;
150+
151+
debug_assert!(segments.has_appendable_segment());
152+
}
153+
128154
let shard = Self {
129155
_path: path.into(),
130156
config: config.expect("config was provided or at least one segment was loaded"),

lib/segment/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ impl VectorDataConfig {
16191619
fn is_opt_compatible<T, F: Fn(T, T) -> bool>(this: Option<T>, other: Option<T>, check: F) -> bool {
16201620
match (this, other) {
16211621
(Some(this), Some(other)) => check(this, other),
1622+
(None, None) => true,
16221623
_ => false,
16231624
}
16241625
}

0 commit comments

Comments
 (0)