mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2025-12-23 02:29:57 +00:00
first commit to show how to impl u128
This commit is contained in:
@@ -11,6 +11,7 @@ pub enum ColumnType {
|
||||
Bytes,
|
||||
Numerical(NumericalType),
|
||||
Bool,
|
||||
IpAddr,
|
||||
}
|
||||
|
||||
impl ColumnType {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::net::Ipv6Addr;
|
||||
|
||||
use crate::dictionary::UnorderedId;
|
||||
use crate::utils::{place_bits, pop_first_byte, select_bits};
|
||||
use crate::value::NumericalValue;
|
||||
@@ -142,6 +144,18 @@ impl SymbolValue for bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl SymbolValue for Ipv6Addr {
|
||||
fn serialize(self, buffer: &mut [u8]) -> u8 {
|
||||
// maybe not ueseful to use VIntEncoding for the mooment since we only use it for IP addr.
|
||||
// We could roll our own RLE compression but it is overkill. let's stick to 8 bytes.
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn deserialize(bytes: &[u8]) -> Self {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MiniBuffer {
|
||||
pub bytes: [u8; 10],
|
||||
|
||||
@@ -4,6 +4,7 @@ mod serializer;
|
||||
mod value_index;
|
||||
|
||||
use std::io;
|
||||
use std::net::Ipv6Addr;
|
||||
|
||||
use column_operation::ColumnOperation;
|
||||
use common::CountingWriter;
|
||||
@@ -48,6 +49,7 @@ struct SpareBuffers {
|
||||
pub struct ColumnarWriter {
|
||||
numerical_field_hash_map: ArenaHashMap,
|
||||
bool_field_hash_map: ArenaHashMap,
|
||||
ip_addr_field_hash_map: ArenaHashMap,
|
||||
bytes_field_hash_map: ArenaHashMap,
|
||||
arena: MemoryArena,
|
||||
// Dictionaries used to store dictionary-encoded values.
|
||||
@@ -90,6 +92,22 @@ impl ColumnarWriter {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn record_ip_addr(&mut self, doc: RowId, column_name: &str, ip_addr: Ipv6Addr) {
|
||||
assert!(
|
||||
!column_name.as_bytes().contains(&0u8),
|
||||
"key may not contain the 0 byte"
|
||||
);
|
||||
let (hash_map, arena) = (&mut self.ip_addr_field_hash_map, &mut self.arena);
|
||||
hash_map.mutate_or_create(
|
||||
column_name.as_bytes(),
|
||||
|column_opt: Option<ColumnWriter>| {
|
||||
let mut column: ColumnWriter = column_opt.unwrap_or_default();
|
||||
column.record(doc, ip_addr, arena);
|
||||
column
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn record_bool(&mut self, doc: RowId, column_name: &str, val: bool) {
|
||||
assert!(
|
||||
!column_name.as_bytes().contains(&0u8),
|
||||
|
||||
Reference in New Issue
Block a user