diff --git a/src/fastfield/writer.rs b/src/fastfield/writer.rs index cc66ae544..f6a3162c4 100644 --- a/src/fastfield/writer.rs +++ b/src/fastfield/writer.rs @@ -283,7 +283,7 @@ impl FastFieldsWriter { /// The fast field writer just keeps the values in memory. /// /// Only when the segment writer can be closed and -/// persisted on disc, the fast field writer is +/// persisted on disk, the fast field writer is /// sent to a `FastFieldSerializer` via the `.serialize(...)` /// method. /// @@ -371,7 +371,7 @@ impl U128FastFieldWriter { /// The fast field writer just keeps the values in memory. /// /// Only when the segment writer can be closed and -/// persisted on disc, the fast field writer is +/// persisted on disk, the fast field writer is /// sent to a `FastFieldSerializer` via the `.serialize(...)` /// method. /// diff --git a/src/indexer/index_writer.rs b/src/indexer/index_writer.rs index 9b3b6bfc9..619fa4a7b 100644 --- a/src/indexer/index_writer.rs +++ b/src/indexer/index_writer.rs @@ -817,7 +817,7 @@ mod tests { use crate::indexer::NoMergePolicy; use crate::query::{BooleanQuery, Occur, Query, QueryParser, TermQuery}; use crate::schema::{ - self, Cardinality, Facet, FacetOptions, IndexRecordOption, IpOptions, NumericOptions, + self, Cardinality, Facet, FacetOptions, IndexRecordOption, IpAddrOptions, NumericOptions, TextFieldIndexing, TextOptions, FAST, INDEXED, STORED, STRING, TEXT, }; use crate::store::DOCSTORE_CACHE_CAPACITY; @@ -1595,10 +1595,10 @@ mod tests { force_end_merge: bool, ) -> crate::Result<()> { let mut schema_builder = schema::Schema::builder(); - let ip_field = schema_builder.add_ip_field("ip", FAST | INDEXED | STORED); - let ips_field = schema_builder.add_ip_field( + let ip_field = schema_builder.add_ip_addr_field("ip", FAST | INDEXED | STORED); + let ips_field = schema_builder.add_ip_addr_field( "ips", - IpOptions::default().set_fast(Cardinality::MultiValues), + IpAddrOptions::default().set_fast(Cardinality::MultiValues), ); let id_field = schema_builder.add_u64_field("id", FAST | INDEXED | STORED); let bytes_field = schema_builder.add_bytes_field("bytes", FAST | INDEXED | STORED); diff --git a/src/schema/field_entry.rs b/src/schema/field_entry.rs index 80a8d5c1e..db2530040 100644 --- a/src/schema/field_entry.rs +++ b/src/schema/field_entry.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use super::ip_options::IpOptions; +use super::ip_options::IpAddrOptions; use crate::schema::bytes_options::BytesOptions; use crate::schema::{ is_valid_field_name, DateOptions, FacetOptions, FieldType, JsonObjectOptions, NumericOptions, @@ -62,7 +62,7 @@ impl FieldEntry { } /// Creates a new ip field entry. - pub fn new_ip(field_name: String, ip_options: IpOptions) -> FieldEntry { + pub fn new_ip_addr(field_name: String, ip_options: IpAddrOptions) -> FieldEntry { Self::new(field_name, FieldType::IpAddr(ip_options)) } diff --git a/src/schema/field_type.rs b/src/schema/field_type.rs index 19bc09f29..4ae6071e9 100644 --- a/src/schema/field_type.rs +++ b/src/schema/field_type.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; use thiserror::Error; -use super::ip_options::IpOptions; +use super::ip_options::IpAddrOptions; use super::Cardinality; use crate::schema::bytes_options::BytesOptions; use crate::schema::facet_options::FacetOptions; @@ -67,7 +67,7 @@ pub enum Type { /// Leaf in a Json object. Json = b'j', /// IpAddr - Ip = b'p', + IpAddr = b'p', /// IpAddr U128 = b'1', } @@ -82,7 +82,7 @@ const ALL_TYPES: [Type; 11] = [ Type::Facet, Type::Bytes, Type::Json, - Type::Ip, + Type::IpAddr, Type::U128, ]; @@ -110,7 +110,7 @@ impl Type { Type::Facet => "Facet", Type::Bytes => "Bytes", Type::Json => "Json", - Type::Ip => "Ip", + Type::IpAddr => "IpAddr", Type::U128 => "U128", } } @@ -128,7 +128,7 @@ impl Type { b'h' => Some(Type::Facet), b'b' => Some(Type::Bytes), b'j' => Some(Type::Json), - b'p' => Some(Type::Ip), + b'p' => Some(Type::IpAddr), b'1' => Some(Type::U128), _ => None, } @@ -161,7 +161,7 @@ pub enum FieldType { /// Json object JsonObject(JsonObjectOptions), /// IpAddr field - IpAddr(IpOptions), + IpAddr(IpAddrOptions), } impl FieldType { @@ -177,7 +177,7 @@ impl FieldType { FieldType::Facet(_) => Type::Facet, FieldType::Bytes(_) => Type::Bytes, FieldType::JsonObject(_) => Type::Json, - FieldType::IpAddr(_) => Type::Ip, + FieldType::IpAddr(_) => Type::IpAddr, } } diff --git a/src/schema/ip_options.rs b/src/schema/ip_options.rs index 195d46916..ce998f43f 100644 --- a/src/schema/ip_options.rs +++ b/src/schema/ip_options.rs @@ -7,13 +7,13 @@ use super::Cardinality; /// Define how an ip field should be handled by tantivy. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] -pub struct IpOptions { +pub struct IpAddrOptions { #[serde(skip_serializing_if = "Option::is_none")] fast: Option, stored: bool, } -impl IpOptions { +impl IpAddrOptions { /// Returns true iff the value is a fast field. pub fn is_fast(&self) -> bool { self.fast.is_some() @@ -52,52 +52,52 @@ impl IpOptions { } } -impl From<()> for IpOptions { - fn from(_: ()) -> IpOptions { - IpOptions::default() +impl From<()> for IpAddrOptions { + fn from(_: ()) -> IpAddrOptions { + IpAddrOptions::default() } } -impl From for IpOptions { +impl From for IpAddrOptions { fn from(_: FastFlag) -> Self { - IpOptions { + IpAddrOptions { stored: false, fast: Some(Cardinality::SingleValue), } } } -impl From for IpOptions { +impl From for IpAddrOptions { fn from(_: StoredFlag) -> Self { - IpOptions { + IpAddrOptions { stored: true, fast: None, } } } -impl From for IpOptions { +impl From for IpAddrOptions { fn from(_: IndexedFlag) -> Self { - IpOptions { + IpAddrOptions { stored: false, fast: None, } } } -impl> BitOr for IpOptions { - type Output = IpOptions; +impl> BitOr for IpAddrOptions { + type Output = IpAddrOptions; - fn bitor(self, other: T) -> IpOptions { + fn bitor(self, other: T) -> IpAddrOptions { let other = other.into(); - IpOptions { + IpAddrOptions { stored: self.stored | other.stored, fast: self.fast.or(other.fast), } } } -impl From> for IpOptions +impl From> for IpAddrOptions where Head: Clone, Tail: Clone, diff --git a/src/schema/mod.rs b/src/schema/mod.rs index 4d966a8b9..c64eef788 100644 --- a/src/schema/mod.rs +++ b/src/schema/mod.rs @@ -138,7 +138,7 @@ pub use self::field_type::{FieldType, Type}; pub use self::field_value::FieldValue; pub use self::flags::{FAST, INDEXED, STORED}; pub use self::index_record_option::IndexRecordOption; -pub use self::ip_options::IpOptions; +pub use self::ip_options::IpAddrOptions; pub use self::json_object_options::JsonObjectOptions; pub use self::named_field_document::NamedFieldDocument; pub use self::numeric_options::NumericOptions; diff --git a/src/schema/schema.rs b/src/schema/schema.rs index e85c9d5ae..a8e2be29f 100644 --- a/src/schema/schema.rs +++ b/src/schema/schema.rs @@ -7,7 +7,7 @@ use serde::ser::SerializeSeq; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{self, Value as JsonValue}; -use super::ip_options::IpOptions; +use super::ip_options::IpAddrOptions; use super::*; use crate::schema::bytes_options::BytesOptions; use crate::schema::field_type::ValueParsingError; @@ -157,13 +157,13 @@ impl SchemaBuilder { /// by the second one. /// The first field will get a field id /// but only the second one will be indexed - pub fn add_ip_field>( + pub fn add_ip_addr_field>( &mut self, field_name_str: &str, field_options: T, ) -> Field { let field_name = String::from(field_name_str); - let field_entry = FieldEntry::new_ip(field_name, field_options.into()); + let field_entry = FieldEntry::new_ip_addr(field_name, field_options.into()); self.add_field(field_entry) } diff --git a/src/schema/term.rs b/src/schema/term.rs index 79546d1dd..d0c37b767 100644 --- a/src/schema/term.rs +++ b/src/schema/term.rs @@ -415,7 +415,7 @@ fn debug_value_bytes(typ: Type, bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Re debug_value_bytes(typ, bytes, f)?; } } - Type::Ip => { + Type::IpAddr => { let s = as_str(bytes); // TODO: change when serialization changes write_opt(f, s)?; }