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

Code before:
        request: &FacetParams,
        is_stopped: &AtomicBool,
        hw_counter: &HardwareCounterCell,
    ) -> OperationResult<HashMap<FacetValue, usize>> {
        self.approximate_facet(request, is_stopped, hw_counter)
    }

    fn segment_uuid(&self) -> OperationResult<String> {
        let id = self
            .current_path
            .file_stem()
            .and_then(|segment_dir| segment_dir.to_str())
            .ok_or_else(|| {
                OperationError::service_error(format!(
                    "failed to extract segment ID from segment path {}",
                    self.current_path.display(),
                ))
            })?;

        debug_assert!(
            Uuid::try_parse(id).is_ok(),
            "segment ID {id} is not a valid UUID",
        );

        Ok(id.to_string())
    }

    fn segment_type(&self) -> SegmentType {
        self.segment_type
    }

    fn size_info(&self) -> SegmentInfo {
        let segment_id = self.segment_uuid().ok();
        let num_vectors = self
            .vector_data
            .values()
            .map(|data| data.vector_storage.borrow().available_vector_count())
            .sum();

        let mut total_average_vectors_size_bytes: usize = 0;

        let vector_data_info: HashMap<_, _> = self
            .vector_data
            .iter()
            .map(|(key, vector_data)| {
                let vector_storage = vector_data.vector_storage.borrow();
                let num_vectors = vector_storage.available_vector_count();
                let vector_index = vector_data.vector_index.borrow();
                let is_indexed = vector_index.is_index();

                let average_vector_size_bytes = if num_vectors > 0 {

Review comment (suggestion):
I don't really like this is fallible. Also, this would now try to parse the path on every UUID request.

I suggest to modify [`Segment`](https://github.com/qdrant/qdrant/blob/037c27200f4a0c40d8e0e4f987a33a9905ca3bd9/lib/segment/src/segment/mod.rs#L63) and add a `uuid` field in there. We can populate when loading or building a segment. Then we always have a UUID.

Code after:
        }
    }

    fn read_random_filtered(
        &self,
        limit: usize,
        filter: Option<&Filter>,
        is_stopped: &AtomicBool,
        hw_counter: &HardwareCounterCell,
    ) -> Vec<PointIdType> {
        match filter {
            None => self.read_by_random_id(limit),
            Some(condition) => {
                if self.should_pre_filter(condition, Some(limit), hw_counter) {
                    self.filtered_read_by_index_shuffled(limit, condition, is_stopped, hw_counter)
                } else {
                    self.filtered_read_by_random_stream(limit, condition, is_stopped, hw_counter)
                }
            }
        }
    }

    fn read_range(&self, from: Option<PointIdType>, to: Option<PointIdType>) -> Vec<PointIdType> {
        let id_tracker = self.id_tracker.borrow();
        let iterator = id_tracker.iter_from(from).map(|x| x.0);
        match to {
            None => iterator.collect(),
            Some(to_id) => iterator.take_while(|x| *x < to_id).collect(),
        }
    }

    fn has_point(&self, point_id: PointIdType) -> bool {
        self.id_tracker.borrow().internal_id(point_id).is_some()
    }

    fn is_empty(&self) -> bool {
        self.id_tracker.borrow().total_point_count() == 0
    }

    fn available_point_count(&self) -> usize {
        self.id_tracker.borrow().available_point_count()
    }

    fn deleted_point_count(&self) -> usize {
        self.id_tracker.borrow().deleted_point_count()
    }

    fn available_vectors_size_in_bytes(&self, vector_name: &VectorName) -> OperationResult<usize> {
        check_vector_name(vector_name, &self.segment_config)?;
        let vector_data = self
            .vector_data