Compare commits

...

1 Commits

Author SHA1 Message Date
Paul Masurel
3a8a83da80 tracing 2023-10-16 19:23:47 +09:00
4 changed files with 10 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ oneshot = "0.1.5"
base64 = "0.21.0"
byteorder = "1.4.3"
crc32fast = "1.3.2"
tracing = "0.1"
once_cell = "1.10.0"
regex = { version = "1.5.5", default-features = false, features = ["std", "unicode"] }
aho-corasick = "1.0"

View File

@@ -13,7 +13,8 @@ description = "sstables for tantivy"
common = {version= "0.6", path="../common", package="tantivy-common"}
tantivy-fst = "0.4"
# experimental gives us access to Decompressor::upper_bound
zstd = { version = "0.12", features = ["experimental"] }
zstd = { version = "0.13", features = ["experimental"] }
tracing = "0.1"
[dev-dependencies]
proptest = "1"

View File

@@ -3,6 +3,7 @@ use std::io;
use std::marker::PhantomData;
use std::ops::{Bound, RangeBounds};
use std::sync::Arc;
use tracing::instrument;
use common::file_slice::FileSlice;
use common::{BinarySerializable, OwnedBytes};
@@ -94,6 +95,7 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
Ok(TSSTable::delta_reader(data))
}
#[instrument(skip_all)]
pub(crate) async fn sstable_delta_reader_block_async(
&self,
block_addr: BlockAddr,
@@ -232,6 +234,7 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
/// If the key was not found, returns Ok(None).
/// After calling this function, it is possible to call `DeltaReader::value` to get the
/// associated value.
#[instrument(skip_all)]
fn decode_up_to_key<K: AsRef<[u8]>>(
&self,
key: K,
@@ -344,6 +347,7 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
}
/// Lookups the value corresponding to the key.
#[instrument(skip_all)]
pub async fn get_async<K: AsRef<[u8]>>(&self, key: K) -> io::Result<Option<TSSTable::Value>> {
if let Some(block_addr) = self.sstable_index.get_block_with_key(key.as_ref()) {
let sstable_reader = self.sstable_delta_reader_block_async(block_addr).await?;

View File

@@ -1,6 +1,7 @@
use std::io::{self, Write};
use std::ops::Range;
use tracing::instrument;
use common::OwnedBytes;
use crate::{common_prefix_len, SSTable, SSTableDataCorruption, TermOrdinal};
@@ -27,6 +28,7 @@ impl SSTableIndex {
}
/// Get the [`BlockAddr`] of the requested block.
#[instrument]
pub(crate) fn get_block(&self, block_id: usize) -> Option<BlockAddr> {
self.blocks
.get(block_id)
@@ -56,6 +58,7 @@ impl SSTableIndex {
/// Get the [`BlockAddr`] of the block that would contain `key`.
///
/// Returns None if `key` is lexicographically after the last key recorded.
#[instrument]
pub fn get_block_with_key(&self, key: &[u8]) -> Option<BlockAddr> {
self.locate_with_key(key).and_then(|id| self.get_block(id))
}