ronantakizawa/codereview-bench huggingface dataset:
Repository: pytest-dev/pytest
File: src/_pytest/config/argparsing.py (Python)

Code before:
    This can simplify things since code only needs to inspect the ini option
    and not consider the CLI flag.
    """

    def __init__(
        self,
        option_strings: Sequence[str],
        dest: str,
        nargs: int | str | None = None,
        *args,
        ini_option: str,
        ini_value: str,
        **kwargs,
    ) -> None:
        super().__init__(option_strings, dest, 0, *args, **kwargs)
        self.ini_option = ini_option
        self.ini_value = ini_value

    def __call__(
        self,
        parser: argparse.ArgumentParser,
        namespace: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        setattr(namespace, self.dest, True)
        current_overrides = getattr(namespace, "override_ini", None)
        if current_overrides is None:
            current_overrides = []
        current_overrides.append(f"{self.ini_option}={self.ini_value}")
        setattr(namespace, "override_ini", current_overrides)


Review comment (suggestion):
This can be simplifed:


```suggestion
        current_overrides = getattr(namespace, "override_ini", [])
```

Code after:

    def __init__(
        self,
        option_strings: Sequence[str],
        dest: str,
        nargs: int | str | None = None,
        *args,
        ini_option: str,
        ini_value: str,
        **kwargs,
    ) -> None:
        super().__init__(option_strings, dest, 0, *args, **kwargs)
        self.ini_option = ini_option
        self.ini_value = ini_value

    def __call__(
        self,
        parser: argparse.ArgumentParser,
        namespace: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        setattr(namespace, self.dest, True)
        current_overrides = getattr(namespace, "override_ini", None)
        if current_overrides is None:
            current_overrides = []
        current_overrides.append(f"{self.ini_option}={self.ini_value}")
        setattr(namespace, "override_ini", current_overrides)
Repository: pytest-dev/pytest
File: testing/io/test_saferepr.py (Python)

Code before:
    assert saferepr(SomeClass()).startswith(
        "<[RuntimeError() raised in repr()] SomeClass object at 0x"
    )


def test_saferepr_unlimited():
    dict5 = {f"v{i}": i for i in range(5)}
    assert saferepr_unlimited(dict5) == "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4}"

    dict_long = {f"v{i}": i for i in range(1_000)}
    r = saferepr_unlimited(dict_long)
    assert "..." not in r
    assert "\n" not in r


def test_saferepr_unlimited_exc():
    class A:
        def __repr__(self):
            raise ValueError(42)

    assert saferepr_unlimited(A()).startswith(
        "<[ValueError(42) raised in repr()] A object at 0x"
    )


def test_saferepr_dict_preserves_insertion_order():
    d = {"b": 1, "a": 2}
    assert saferepr(d, maxsize=None) == "{'b': 1, 'a': 2}"


def test_saferepr_dict_truncation_preserves_insertion_order():
    from _pytest._io.saferepr import SafeRepr

    d = {"b": 1, "a": 2}
    s = SafeRepr(maxsize=None)
    s.maxdict = 1
    assert s.repr(d) == "{'b': 1, ...}"


def test_saferepr_dict_fillvalue_when_level_is_zero():
    from _pytest._io.saferepr import SafeRepr

    s = SafeRepr(maxsize=None)
    assert s.repr_dict({"a": 1}, level=0) == "{...}"


def test_saferepr_dict_empty():
    from _pytest._io.saferepr import SafeRepr

    s = SafeRepr(maxsize=None)
    assert s.repr_dict({}, level=1) == "{}"

Review comment (suggestion):
Please add type annotations to the tests (`-> None`).

Code after:

    assert saferepr(SomeClass()).startswith(
        "<[RuntimeError() raised in repr()] SomeClass object at 0x"
    )


def test_saferepr_unlimited():
    dict5 = {f"v{i}": i for i in range(5)}
    assert saferepr_unlimited(dict5) == "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4}"

    dict_long = {f"v{i}": i for i in range(1_000)}
    r = saferepr_unlimited(dict_long)
    assert "..." not in r
    assert "\n" not in r


def test_saferepr_unlimited_exc():
    class A:
        def __repr__(self):
            raise ValueError(42)

    assert saferepr_unlimited(A()).startswith(
        "<[ValueError(42) raised in repr()] A object at 0x"
    )


def test_saferepr_dict_preserves_insertion_order() -> None:
    d = {
        "b": 2,
        "a": 1,
        "d": 4,
        "e": 5,
        "c": 3,
    }
    s = SafeRepr(maxsize=None)
    s.maxdict = 10
    assert s.repr(d) == "{'b': 2, 'a': 1, 'd': 4, 'e': 5, 'c': 3}"


def test_saferepr_dict_truncation_preserves_insertion_order() -> None:
    d = {
        "b": 2,
        "a": 1,
        "d": 4,
        "e": 5,
        "c": 3,
    }
    s = SafeRepr(maxsize=None)
    s.maxdict = 1
    assert s.repr(d) == "{'b': 2, ...}"
Repository: pytest-dev/pytest
File: testing/io/test_saferepr.py (Python)

Code before:
        "<[RuntimeError() raised in repr()] SomeClass object at 0x"
    )


def test_saferepr_unlimited():
    dict5 = {f"v{i}": i for i in range(5)}
    assert saferepr_unlimited(dict5) == "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4}"

    dict_long = {f"v{i}": i for i in range(1_000)}
    r = saferepr_unlimited(dict_long)
    assert "..." not in r
    assert "\n" not in r


def test_saferepr_unlimited_exc():
    class A:
        def __repr__(self):
            raise ValueError(42)

    assert saferepr_unlimited(A()).startswith(
        "<[ValueError(42) raised in repr()] A object at 0x"
    )


def test_saferepr_dict_preserves_insertion_order():
    d = {"b": 1, "a": 2}
    assert saferepr(d, maxsize=None) == "{'b': 1, 'a': 2}"


def test_saferepr_dict_truncation_preserves_insertion_order():
    from _pytest._io.saferepr import SafeRepr

    d = {"b": 1, "a": 2}
    s = SafeRepr(maxsize=None)
    s.maxdict = 1
    assert s.repr(d) == "{'b': 1, ...}"


def test_saferepr_dict_fillvalue_when_level_is_zero():
    from _pytest._io.saferepr import SafeRepr

    s = SafeRepr(maxsize=None)
    assert s.repr_dict({"a": 1}, level=0) == "{...}"


def test_saferepr_dict_empty():
    from _pytest._io.saferepr import SafeRepr

    s = SafeRepr(maxsize=None)
    assert s.repr_dict({}, level=1) == "{}"


Review comment (suggestion):
Could we have more keys here just for safety?

```suggestion
d = {
    "b": 2,
    "a": 1,
    "d": 4,
    "e": 5,
    "c": 3,
}
```

Code after:
    assert saferepr(SomeClass()).startswith(
        "<[RuntimeError() raised in repr()] SomeClass object at 0x"
    )


def test_saferepr_unlimited():
    dict5 = {f"v{i}": i for i in range(5)}
    assert saferepr_unlimited(dict5) == "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4}"

    dict_long = {f"v{i}": i for i in range(1_000)}
    r = saferepr_unlimited(dict_long)
    assert "..." not in r
    assert "\n" not in r


def test_saferepr_unlimited_exc():
    class A:
        def __repr__(self):
            raise ValueError(42)

    assert saferepr_unlimited(A()).startswith(
        "<[ValueError(42) raised in repr()] A object at 0x"
    )


def test_saferepr_dict_preserves_insertion_order() -> None:
    d = {
        "b": 2,
        "a": 1,
        "d": 4,
        "e": 5,
        "c": 3,
    }
    s = SafeRepr(maxsize=None)
    s.maxdict = 10
    assert s.repr(d) == "{'b': 2, 'a': 1, 'd': 4, 'e': 5, 'c': 3}"


def test_saferepr_dict_truncation_preserves_insertion_order() -> None:
    d = {
        "b": 2,
        "a": 1,
        "d": 4,
        "e": 5,
        "c": 3,
    }
    s = SafeRepr(maxsize=None)
    s.maxdict = 1
    assert s.repr(d) == "{'b': 2, ...}"
Repository: qdrant/qdrant
File: lib/common/memory/src/checkfs.rs (Rust)

Code before:
        false,
    )?;

    mmap[MAGIC_BYTES_POSITION..MAGIC_BYTES_POSITION + MAGIC_QDRANT_BYTES.len()]
        .copy_from_slice(MAGIC_QDRANT_BYTES);

    mmap.flush()?;
    drop(mmap);
    drop(mmap_seq);

    if !magic_file_path.exists() {
        return Ok(false);
    }

    // Check the size of the file
    let file_size = magic_file_path.metadata()?.len() as usize;
    if file_size != MAGIC_FILE_SIZE {
        log::debug!("File size is not equal to MAGIC_FILE_SIZE: {file_size} != {MAGIC_FILE_SIZE}");
        return Ok(false);
    }

    let mmap = open_read_mmap(&magic_file_path, AdviceSetting::Global, false)?;
    let mut result = true;

    result &= mmap[MAGIC_BYTES_POSITION..MAGIC_BYTES_POSITION + MAGIC_QDRANT_BYTES.len()]
        == *MAGIC_QDRANT_BYTES;

    drop(mmap);

    if result {
        // If ok, we can remove the file
        // But if not, we might need to for further investigation
        std::fs::remove_file(&magic_file_path)?;
    }

    Ok(result)
}

#[cfg(test)]
mod tests {
    use tempfile::TempDir;

    use super::*;

    #[test]
    fn test_posix_fs_check() {
        let temp_dir = TempDir::new().unwrap();
        let result = check_fs_info(temp_dir.path());
        println!("Result: {result:?}");
        let result = check_mmap_functionality(temp_dir.path()).unwrap();
        println!("Result: {result}");

Review comment (suggestion):
```suggestion
    let result = mmap[MAGIC_BYTES_POSITION..MAGIC_BYTES_POSITION + MAGIC_QDRANT_BYTES.len()]
        == *MAGIC_QDRANT_BYTES;
```

Code after:
    let magic_file_path = path.join(MAGIC_FILE_NAME);

    // Remove file and folder if they exist
    if magic_file_path.exists() {
        std::fs::remove_file(&magic_file_path)?;
    }

    create_dir_all(path)?;

    create_and_ensure_length(&magic_file_path, MAGIC_FILE_SIZE)?;

    let mut mmap = open_write_mmap(&magic_file_path, AdviceSetting::Global, false)?;

    let mmap_seq = open_read_mmap(
        &magic_file_path,
        AdviceSetting::Advice(Advice::Sequential),
        false,
    )?;

    mmap[MAGIC_BYTES_POSITION..MAGIC_BYTES_POSITION + MAGIC_QDRANT_BYTES.len()]
        .copy_from_slice(MAGIC_QDRANT_BYTES);

    mmap.flush()?;
    drop(mmap);
    drop(mmap_seq);

    if !magic_file_path.exists() {
        return Ok(false);
    }

    // Check the size of the file
    let file_size = magic_file_path.metadata()?.len() as usize;
    if file_size != MAGIC_FILE_SIZE {
        log::debug!("File size is not equal to MAGIC_FILE_SIZE: {file_size} != {MAGIC_FILE_SIZE}");
        return Ok(false);
    }

    let mmap = open_read_mmap(&magic_file_path, AdviceSetting::Global, false)?;
    let result = mmap[MAGIC_BYTES_POSITION..MAGIC_BYTES_POSITION + MAGIC_QDRANT_BYTES.len()]
        == *MAGIC_QDRANT_BYTES;

    drop(mmap);

    if result {
        // If ok, we can remove the file
        // But if not, we might need to for further investigation
        std::fs::remove_file(&magic_file_path)?;
    }

    Ok(result)
}
Repository: qdrant/qdrant
File: lib/common/common/src/disk.rs (Rust)

Code before:
use std::path::{Path, PathBuf};

use walkdir::WalkDir;

/// How many bytes a directory takes.
pub fn dir_size(path: impl Into<PathBuf>) -> std::io::Result<u64> {
    fn dir_size(mut dir: std::fs::ReadDir) -> std::io::Result<u64> {
        dir.try_fold(0, |acc, file| {
            let file = file?;
            let size = match file.metadata()? {
                data if data.is_dir() => dir_size(std::fs::read_dir(file.path())?)?,
                data => data.len(),
            };
            Ok(acc + size)
        })
    }

    dir_size(std::fs::read_dir(path.into())?)
}

const BLOCK_SIZE: u64 = 512; // 512 bytes per block, aka DEV_BSIZE

/// How many bytes a directory takes on disk.
/// Notes:
/// - on non-unix systems, this is the same as `dir_size`
pub fn dir_disk_size(path: impl Into<PathBuf>) -> std::io::Result<u64> {
    fn dir_disk_size(mut dir: std::fs::ReadDir) -> std::io::Result<u64> {
        dir.try_fold(0, |acc, file| {
            let file = file?;
            let metadata = file.metadata()?;
            let size = if metadata.is_dir() {
                dir_disk_size(std::fs::read_dir(file.path())?)?
            } else {
                #[cfg(unix)]

Review comment (suggestion):
I propose to drop the old `fn dir_size()`. I don't see an use-case for the size of the directory in apparent bytes rather than disk usage.

Code after:
use std::path::{Path, PathBuf};

use walkdir::WalkDir;

/// How many bytes a directory takes on disk.
///
/// Note: on non-unix systems, this function returns the apparent/logical
/// directory size rather than actual disk usage.
pub fn dir_disk_size(path: impl Into<PathBuf>) -> std::io::Result<u64> {
    fn dir_disk_size(mut dir: std::fs::ReadDir) -> std::io::Result<u64> {
        dir.try_fold(0, |acc, file| {
            let file = file?;
            let metadata = file.metadata()?;
            let size = if metadata.is_dir() {
                dir_disk_size(std::fs::read_dir(file.path())?)?
            } else {
                #[cfg(unix)]
                {
                    const BLOCK_SIZE: u64 = 512; // aka DEV_BSIZE
                    use std::os::unix::fs::MetadataExt;
                    metadata.blocks() * BLOCK_SIZE
                }
                #[cfg(not(unix))]
                {
                    metadata.len()
                }
            };
            Ok(acc + size)
        })
    }

    dir_disk_size(std::fs::read_dir(path.into())?)
}
Repository: qdrant/qdrant
File: lib/segment/src/vector_storage/quantized/quantized_chunked_mmap_storage.rs (Rust)

Code before:
        let advice = if in_ram {
            AdviceSetting::from(Advice::Normal)
        } else {
            AdviceSetting::Global
        };
        let data = ChunkedMmapVectors::<u8>::open(
            path,
            quantized_vector_size,
            advice,
            Some(in_ram), // populate
        )?;
        Ok(Self {
            data,
            hw_counter: HardwareCounterCell::disposable(),
        })
    }
}

impl quantization::EncodedStorageBuilder for QuantizedChunkedMmapStorageBuilder {
    type Storage = QuantizedChunkedMmapStorage;

    fn build(self) -> std::io::Result<QuantizedChunkedMmapStorage> {
        self.data.flusher()().map_err(|e| {
            std::io::Error::other(format!("Failed to flush quantization storage: {e}"))
        })?;
        Ok(QuantizedChunkedMmapStorage { data: self.data })
    }

    fn push_vector_data(&mut self, other: &[u8]) -> std::io::Result<()> {
        self.data
            .push(other, &self.hw_counter)
            .map(|_| ())
            .map_err(|e| std::io::Error::other(format!("Failed to push vector data: {e}")))
    }
}


Review comment (bug):
```suggestion
        let Self {
            data,
            hw_counter: _,
        } = self;

        data.flusher()().map_err(|e| {
            std::io::Error::other(format!("Failed to flush quantization storage: {e}"))
        })?;

        Ok(QuantizedChunkedMmapStorage { data })
```

Code after:
        let advice = if in_ram {
            AdviceSetting::from(Advice::Normal)
        } else {
            AdviceSetting::Global
        };
        let data = ChunkedMmapVectors::<u8>::open(
            path,
            quantized_vector_size,
            advice,
            Some(in_ram), // populate
        )?;
        Ok(Self {
            data,
            hw_counter: HardwareCounterCell::disposable(),
        })
    }
}

impl quantization::EncodedStorageBuilder for QuantizedChunkedMmapStorageBuilder {
    type Storage = QuantizedChunkedMmapStorage;

    fn build(self) -> std::io::Result<QuantizedChunkedMmapStorage> {
        let Self {
            data,
            hw_counter: _,
        } = self;

        data.flusher()().map_err(|e| {
            std::io::Error::other(format!("Failed to flush quantization storage: {e}"))
        })?;

        Ok(QuantizedChunkedMmapStorage { data })
    }

    fn push_vector_data(&mut self, other: &[u8]) -> std::io::Result<()> {
        self.data
            .push(other, &self.hw_counter)
            .map(|_| ())
            .map_err(|e| std::io::Error::other(format!("Failed to push vector data: {e}")))
    }
}
Repository: qdrant/qdrant
File: lib/collection/src/grouping/types.rs (Rust)

Code before:
                .hits
                .into_iter()
                .map(api::rest::ScoredPoint::from)
                .collect(),
            id: group.key,
            lookup: None,
        }
    }
}

#[derive(Clone)]
pub struct QueryGroupRequest {
    /// Query request to use
    pub source: ShardQueryRequest,

    /// Path to the field to group by
    pub group_by: JsonPath,

    /// Limit of points to return per group
    pub group_size: usize,

    /// Limit of groups to return
    pub groups: usize,

    /// Options for specifying how to use the group id to lookup points in another collection
    pub with_lookup: Option<WithLookup>,
}

#[cfg(test)]
mod test {
    use segment::data_types::groups::GroupId;

    #[test]
    fn group_key_from_values() {
        use std::convert::TryFrom;

        use serde_json::json;

        let string = GroupId::try_from(&json!("string")).unwrap();
        let int = GroupId::try_from(&json!(1)).unwrap();

        assert!(GroupId::try_from(&json!(2.42)).is_err());

        assert!(GroupId::try_from(&json!([5, 6, 7])).is_err());
        assert!(GroupId::try_from(&json!(["a", "b", "c"])).is_err());

        assert_eq!(string, GroupId::String("string".to_string()));
        assert_eq!(int.as_u64().unwrap(), 1);

        let bad_key = GroupId::try_from(&json!(true));
        assert!(bad_key.is_err());

Review comment (suggestion):
we didn't need `with_lookup` here, it was not used and lookup was resolved before creating this structure

Code after:
                .into_iter()
                .map(api::rest::ScoredPoint::from)
                .collect(),
            id: group.key,
            lookup: None,
        }
    }
}

#[derive(Clone)]
pub struct QueryGroupRequest {
    /// Query request to use
    pub source: ShardQueryRequest,

    /// Path to the field to group by
    pub group_by: JsonPath,

    /// Limit of points to return per group
    pub group_size: usize,

    /// Limit of groups to return
    pub groups: usize,
}

#[cfg(test)]
mod test {
    use segment::data_types::groups::GroupId;

    #[test]
    fn group_key_from_values() {
        use std::convert::TryFrom;

        use serde_json::json;

        let string = GroupId::try_from(&json!("string")).unwrap();
        let int = GroupId::try_from(&json!(1)).unwrap();

        assert!(GroupId::try_from(&json!(2.42)).is_err());

        assert!(GroupId::try_from(&json!([5, 6, 7])).is_err());
        assert!(GroupId::try_from(&json!(["a", "b", "c"])).is_err());

        assert_eq!(string, GroupId::String("string".to_string()));
        assert_eq!(int.as_u64().unwrap(), 1);

        let bad_key = GroupId::try_from(&json!(true));
        assert!(bad_key.is_err());

        let empty_array = GroupId::try_from(&json!([]));
        assert!(empty_array.is_err());
Repository: qdrant/qdrant
File: lib/collection/src/operations/loggable.rs (Rust)

Code before:
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.as_ref().hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for Arc<PointRequestInternal> {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self.as_ref()).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "retrieve"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.as_ref().hash(&mut hasher);
        hasher.finish()
    }
}


Review comment (refactor):
If we apply the change above, we can simplify these too:


```suggestion
impl Loggable for &CountRequestInternal {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "count"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for &PointRequestInternal {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "retrieve"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}
```

Code after:
        self.hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for CountRequestInternal {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "count"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for PointRequestInternal {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "retrieve"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}
Repository: qdrant/qdrant
File: lib/collection/src/shards/local_shard/shard_ops.rs (Rust)

Code before:
            if let Some(filter) = &request.filter {
                cost += filter_rate_cost(filter);
            }
            cost
        })?;

        let start_time = Instant::now();
        let hits = if request.exact {
            self.exact_facet(
                request.clone(),
                search_runtime_handle,
                timeout,
                hw_measurement_acc,
            )
            .await?
        } else {
            self.approx_facet(
                request.clone(),
                search_runtime_handle,
                timeout,
                hw_measurement_acc,
            )
            .await?
        };
        let elapsed = start_time.elapsed();
        log_request_to_collector(&self.collection_name, elapsed, || request.clone());
        Ok(FacetResponse { hits })
    }
}


Review comment (suggestion):
No need to clone here:

```suggestion
        log_request_to_collector(&self.collection_name, elapsed, || request);
```

Code after:
                .chain(planned_query.scrolls.iter().map(|s| s.scroll_rate_cost()))
                .sum()
        })?;

        let result = self
            .do_planned_query(
                planned_query,
                search_runtime_handle,
                timeout,
                hw_measurement_acc,
            )
            .await;

        let elapsed = start_time.elapsed();
        log_request_to_collector(&self.collection_name, elapsed, || requests.remove_details());

        result
    }

    /// This call is rate limited by the read rate limiter.
    async fn facet(
        &self,
        request: Arc<FacetParams>,
        search_runtime_handle: &Handle,
        timeout: Option<Duration>,
        hw_measurement_acc: HwMeasurementAcc,
    ) -> CollectionResult<FacetResponse> {
        // Check read rate limiter before proceeding
        self.check_read_rate_limiter(&hw_measurement_acc, "facet", || {
            let mut cost = BASE_COST;
            if let Some(filter) = &request.filter {
                cost += filter_rate_cost(filter);
            }
            cost
        })?;

        let start_time = Instant::now();
        let hits = if request.exact {
            self.exact_facet(
                request.clone(),
                search_runtime_handle,
                timeout,
                hw_measurement_acc,
            )
            .await?
        } else {
            self.approx_facet(
                request.clone(),
                search_runtime_handle,
                timeout,
                hw_measurement_acc,