Repository: qdrant/qdrant
File: lib/segment/src/entry/entry_point.rs (Rust)

Code before:
                    return Err(OperationError::service_error(format!(
                        "Incompatible schema for field index on field {key}",
                    )));
                }
                BuildFieldIndexResult::Built { schema, indexes } => (schema, indexes),
            };

        self.apply_field_index(op_num, key.to_owned(), schema, indexes)
    }

    /// Get indexed fields
    fn get_indexed_fields(&self) -> HashMap<PayloadKeyType, PayloadFieldSchema>;

    /// Checks if segment errored during last operations
    fn check_error(&self) -> Option<SegmentFailedState>;

    // Get collected telemetry data of segment
    fn get_telemetry_data(&self, detail: TelemetryDetail) -> SegmentTelemetry;

    fn fill_query_context(&self, query_context: &mut QueryContext);
}

/// Defines in what order multiple segments must be flushed.
///
/// To achieve data consistency with our point copy on write mechanism, we must flush segments in a
/// strict order. Appendalbe segments muts be flushed first, non-appendable segments last. Proxy
/// segments fall in between.
///
/// When flush the segment holder, we effectively flush in four stages defined by the enum variants
/// below.
#[derive(PartialEq, Eq, Debug, Clone, Copy, Ord, PartialOrd)]
pub enum SegmentFlushOrdering {
    // Must always be flushed first
    // - Point-CoW moves points into this segment
    Appendable,
    // - Point-CoW may have moved points into this segment before proxying, might be pending flush
    // - Point-CoW may have moved out and deleted points from this segment, these are not persisted
    ProxyWithAppendable,
    // - Point-CoW may have moved out and deleted points from here, these are not persisted
    ProxyWithNonAppendable,
    // Must always be flushed last
    // - Point-CoW moves out and deletes points from this segment
    NonAppendable,
}

impl SegmentFlushOrdering {
    pub fn proxy(self) -> Self {
        match self {
            SegmentFlushOrdering::Appendable => SegmentFlushOrdering::ProxyWithAppendable,
            SegmentFlushOrdering::NonAppendable => SegmentFlushOrdering::ProxyWithNonAppendable,
            proxy @ SegmentFlushOrdering::ProxyWithAppendable => proxy,

Review comment (suggestion):
```suggestion
/// strict order. Appendable segments must be flushed first, non-appendable segments last. Proxy
```

Code after:
                    return Err(OperationError::service_error(format!(
                        "Incompatible schema for field index on field {key}",
                    )));
                }
                BuildFieldIndexResult::Built { schema, indexes } => (schema, indexes),
            };

        self.apply_field_index(op_num, key.to_owned(), schema, indexes)
    }

    /// Get indexed fields
    fn get_indexed_fields(&self) -> HashMap<PayloadKeyType, PayloadFieldSchema>;

    /// Checks if segment errored during last operations
    fn check_error(&self) -> Option<SegmentFailedState>;

    // Get collected telemetry data of segment
    fn get_telemetry_data(&self, detail: TelemetryDetail) -> SegmentTelemetry;

    fn fill_query_context(&self, query_context: &mut QueryContext);
}

/// Defines in what order multiple segments must be flushed.
///
/// To achieve data consistency with our point copy on write mechanism, we must flush segments in a
/// strict order. Appendable segments must be flushed first, non-appendable segments last. Proxy
/// segments fall in between.
///
/// When flush the segment holder, we effectively flush in four stages defined by the enum variants
/// below.
#[derive(PartialEq, Eq, Debug, Clone, Copy, Ord, PartialOrd)]
pub enum SegmentFlushOrdering {
    // Must always be flushed first
    // - Point-CoW moves points into this segment
    Appendable,
    // - Point-CoW may have moved points into this segment before proxying, might be pending flush
    // - Point-CoW may have moved out and deleted points from this segment, these are not persisted
    ProxyWithAppendable,
    // - Point-CoW may have moved out and deleted points from here, these are not persisted
    ProxyWithNonAppendable,
    // Must always be flushed last
    // - Point-CoW moves out and deletes points from this segment
    NonAppendable,
}

impl SegmentFlushOrdering {
    pub fn proxy(self) -> Self {
        match self {
            SegmentFlushOrdering::Appendable => SegmentFlushOrdering::ProxyWithAppendable,
            SegmentFlushOrdering::NonAppendable => SegmentFlushOrdering::ProxyWithNonAppendable,
            proxy @ SegmentFlushOrdering::ProxyWithAppendable => proxy,