Skip to content

Commit

Permalink
Removing serde-derive dependency (quickwit-oss#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton authored Mar 6, 2020
1 parent b2baed9 commit 486b8fa
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ atomicwrites = {version="0.2.2", optional=true}
tempfile = "3.0"
log = "0.4"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
num_cpus = "1.2"
fs2={version="0.4", optional=true}
Expand Down
3 changes: 1 addition & 2 deletions examples/pre_tokenized_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
// - import tokenized text straight from json,
// - perform a search on documents with pre-tokenized text

use tantivy::tokenizer::{PreTokenizedString, SimpleTokenizer, Token, Tokenizer};

use tantivy::collector::{Count, TopDocs};
use tantivy::query::TermQuery;
use tantivy::schema::*;
use tantivy::tokenizer::{PreTokenizedString, SimpleTokenizer, Token, Tokenizer};
use tantivy::{doc, Index, ReloadPolicy};
use tempfile::TempDir;

Expand Down
1 change: 1 addition & 0 deletions src/core/index_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::schema::Schema;
use crate::Opstamp;
use census::{Inventory, TrackedObject};
use serde;
use serde::{Deserialize, Serialize};
use serde_json;
use std::collections::HashSet;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/core/segment_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use uuid::Uuid;

#[cfg(test)]
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::str::FromStr;
#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions src/directory/mmap_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::directory::WatchHandle;
use crate::directory::{TerminatingWrite, WritePtr};
use atomicwrites;
use memmap::Mmap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::convert::From;
use std::fmt;
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@
//! [literate programming](https://tantivy-search.github.io/examples/basic_search.html) /
//! [source code](https://github.com/tantivy-search/tantivy/blob/master/examples/basic_search.rs))
#[macro_use]
extern crate serde_derive;

#[cfg_attr(test, macro_use)]
extern crate serde_json;

Expand Down Expand Up @@ -173,6 +170,7 @@ pub use crate::schema::{Document, Term};
use std::fmt;

use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

/// Index format version.
const INDEX_FORMAT_VERSION: u32 = 1;
Expand Down
1 change: 1 addition & 0 deletions src/query/explanation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{DocId, TantivyError};
use serde::Serialize;

pub(crate) fn does_not_match(doc: DocId) -> TantivyError {
TantivyError::InvalidArgument(format!("Document #({}) does not match", doc))
Expand Down
3 changes: 2 additions & 1 deletion src/schema/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::common::VInt;
use crate::tokenizer::PreTokenizedString;
use crate::DateTime;
use itertools::Itertools;
use serde;
use std::io::{self, Read, Write};

/// Tantivy's Document is the object that can
Expand All @@ -16,7 +17,7 @@ use std::io::{self, Read, Write};
/// Documents are really just a list of couple `(field, value)`.
/// In this list, one field may appear more than once.
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Default)]
pub struct Document {
field_values: Vec<FieldValue>,
}
Expand Down
5 changes: 4 additions & 1 deletion src/schema/field.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use crate::common::BinarySerializable;
use serde;
use std::io;
use std::io::Read;
use std::io::Write;

/// `Field` is represented by an unsigned 32-bit integer type
/// The schema holds the mapping between field names and `Field` objects.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
#[derive(
Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, serde::Serialize, serde::Deserialize,
)]
pub struct Field(u32);

impl Field {
Expand Down
3 changes: 2 additions & 1 deletion src/schema/field_value.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::common::BinarySerializable;
use crate::schema::Field;
use crate::schema::Value;
use serde;
use std::io;
use std::io::Read;
use std::io::Write;

/// `FieldValue` holds together a `Field` and its `Value`.
#[derive(Debug, Clone, Ord, PartialEq, Eq, PartialOrd, Serialize, Deserialize)]
#[derive(Debug, Clone, Ord, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)]
pub struct FieldValue {
field: Field,
value: Value,
Expand Down
2 changes: 2 additions & 0 deletions src/schema/index_record_option.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use serde::{Deserialize, Serialize};

/// `IndexRecordOption` describes an amount information associated
/// to a given indexed field.
///
Expand Down
1 change: 1 addition & 0 deletions src/schema/int_options.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::schema::flags::{FastFlag, IndexedFlag, SchemaFlagList, StoredFlag};
use serde::{Deserialize, Serialize};
use std::ops::BitOr;

/// Express whether a field is single-value or multi-valued.
Expand Down
1 change: 1 addition & 0 deletions src/schema/named_field_document.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::schema::Value;
use serde::Serialize;
use std::collections::BTreeMap;

/// Internal representation of a document used for JSON
Expand Down
1 change: 1 addition & 0 deletions src/schema/text_options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::schema::flags::SchemaFlagList;
use crate::schema::flags::StoredFlag;
use crate::schema::IndexRecordOption;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::ops::BitOr;

Expand Down
1 change: 1 addition & 0 deletions src/space_usage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ under-count actual resultant space usage by up to 4095 bytes per file.

use crate::schema::Field;
use crate::SegmentComponent;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Indicates space usage in bytes
Expand Down
1 change: 1 addition & 0 deletions src/tokenizer/stemmer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::{Token, TokenFilter, TokenStream};
use crate::tokenizer::BoxTokenStream;
use rust_stemmers::{self, Algorithm};
use serde::{Deserialize, Serialize};

/// Available stemmer languages.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
Expand Down
1 change: 1 addition & 0 deletions src/tokenizer/tokenized_string.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::tokenizer::{BoxTokenStream, Token, TokenStream, TokenStreamChain};
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;

/// Struct representing pre-tokenized text
Expand Down
1 change: 1 addition & 0 deletions src/tokenizer/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::tokenizer::TokenStreamChain;
use serde::{Deserialize, Serialize};
/// The tokenizer module contains all of the tools used to process
/// text in `tantivy`.
use std::borrow::{Borrow, BorrowMut};
Expand Down

0 comments on commit 486b8fa

Please sign in to comment.