Skip to content

Commit

Permalink
[ENH] Deprecate FetchSegmentOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sicheng Pan committed Dec 6, 2024
1 parent e02d7a5 commit 23661c7
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 521 deletions.
39 changes: 38 additions & 1 deletion rust/types/src/collection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{Metadata, MetadataValueConversionError};
use crate::chroma_proto;
use crate::{chroma_proto, ConversionError, Segment};
use chroma_error::{ChromaError, ErrorCodes};
use thiserror::Error;
use uuid::Uuid;
Expand Down Expand Up @@ -89,6 +89,43 @@ impl TryFrom<chroma_proto::Collection> for Collection {
}
}

#[derive(Clone, Debug)]
pub struct CollectionSegments {
pub collection: Collection,
pub metadata_segment: Segment,
pub record_segment: Segment,
pub vector_segment: Segment,
}

impl TryFrom<chroma_proto::ScanOperator> for CollectionSegments {
type Error = ConversionError;

fn try_from(value: chroma_proto::ScanOperator) -> Result<Self, ConversionError> {
Ok(Self {
collection: value
.collection
.ok_or(ConversionError::DecodeError)?
.try_into()
.map_err(|_| ConversionError::DecodeError)?,
metadata_segment: value
.metadata
.ok_or(ConversionError::DecodeError)?
.try_into()
.map_err(|_| ConversionError::DecodeError)?,
record_segment: value
.record
.ok_or(ConversionError::DecodeError)?
.try_into()
.map_err(|_| ConversionError::DecodeError)?,
vector_segment: value
.knn
.ok_or(ConversionError::DecodeError)?
.try_into()
.map_err(|_| ConversionError::DecodeError)?,
})
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion rust/types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum ConversionError {
impl ChromaError for ConversionError {
fn code(&self) -> ErrorCodes {
match self {
ConversionError::DecodeError => ErrorCodes::Internal,
ConversionError::DecodeError => ErrorCodes::InvalidArgument,
}
}
}
Expand Down
137 changes: 0 additions & 137 deletions rust/worker/src/execution/operators/fetch_segment.rs

This file was deleted.

1 change: 0 additions & 1 deletion rust/worker/src/execution/operators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(super) mod write_segments;

// Required for benchmark
pub mod fetch_log;
pub mod fetch_segment;
pub mod filter;
pub mod knn;
pub mod knn_hnsw;
Expand Down
17 changes: 4 additions & 13 deletions rust/worker/src/execution/operators/prefetch_record.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::collections::HashSet;

use chroma_blockstore::provider::BlockfileProvider;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_types::{Chunk, LogRecord, Segment};
use thiserror::Error;
use tonic::async_trait;
use tracing::{trace, Instrument, Span};
Expand All @@ -16,16 +14,15 @@ use crate::{
},
};

use super::projection::ProjectionInput;

/// The `PrefetchRecordOperator` prefetches the relevant records from the record segments to the cache
///
/// # Parameters
/// None
///
/// # Inputs
/// - `logs`: The latest logs of the collection
/// - `blockfile_provider`: The blockfile provider
/// - `record_segment`: The record segment information
/// - `offset_ids`: The offset ids of the records to prefetch
/// Identical to ProjectionInput
///
/// # Outputs
/// None
Expand All @@ -35,13 +32,7 @@ use crate::{
#[derive(Debug)]
pub struct PrefetchRecordOperator {}

#[derive(Debug)]
pub struct PrefetchRecordInput {
pub logs: Chunk<LogRecord>,
pub blockfile_provider: BlockfileProvider,
pub record_segment: Segment,
pub offset_ids: Vec<u32>,
}
pub type PrefetchRecordInput = ProjectionInput;

pub type PrefetchRecordOutput = ();

Expand Down
2 changes: 1 addition & 1 deletion rust/worker/src/execution/operators/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct ProjectionOperator {
pub metadata: bool,
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct ProjectionInput {
pub logs: Chunk<LogRecord>,
pub blockfile_provider: BlockfileProvider,
Expand Down
Loading

0 comments on commit 23661c7

Please sign in to comment.