From 0eff725822d87664ff38a6c042c71e664952a6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 30 Jul 2024 13:35:26 +0200 Subject: [PATCH] Implement Debug on the Sorter --- src/sorter.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/sorter.rs b/src/sorter.rs index 8f022ed..fda2d23 100644 --- a/src/sorter.rs +++ b/src/sorter.rs @@ -1,6 +1,7 @@ use std::alloc::{alloc, dealloc, Layout}; use std::borrow::Cow; use std::convert::Infallible; +use std::fmt::Debug; #[cfg(feature = "tempfile")] use std::fs::File; use std::io::{Cursor, Read, Seek, SeekFrom, Write}; @@ -669,6 +670,28 @@ where } } +impl Debug for Sorter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Sorter") + .field("chunks_count", &self.chunks.len()) + .field("remaining_entries", &self.entries.remaining()) + .field("chunks_total_size", &self.chunks_total_size) + .field("allow_realloc", &self.allow_realloc) + .field("dump_threshold", &self.dump_threshold) + .field("max_nb_chunks", &self.max_nb_chunks) + .field("chunk_compression_type", &self.chunk_compression_type) + .field("chunk_compression_level", &self.chunk_compression_level) + .field("index_key_interval", &self.index_key_interval) + .field("block_size", &self.block_size) + .field("index_levels", &self.index_levels) + .field("chunk_creator", &"[chunck creator]") + .field("sort_algorithm", &self.sort_algorithm) + .field("sort_in_parallel", &self.sort_in_parallel) + .field("merge", &"[merge function]") + .finish() + } +} + /// A trait that represent a `ChunkCreator`. pub trait ChunkCreator { /// The generated chunk by this `ChunkCreator`.