mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 13:40:31 +01:00
Merge pull request #159 from meilisearch/create-specific-schema-crate
Move the Schema to its own workspace crate
This commit is contained in:
commit
c39254bf98
@ -3,6 +3,7 @@ members = [
|
|||||||
"meilidb",
|
"meilidb",
|
||||||
"meilidb-core",
|
"meilidb-core",
|
||||||
"meilidb-data",
|
"meilidb-data",
|
||||||
|
"meilidb-schema",
|
||||||
"meilidb-tokenizer",
|
"meilidb-tokenizer",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -9,15 +9,13 @@ arc-swap = "0.3.11"
|
|||||||
bincode = "1.1.2"
|
bincode = "1.1.2"
|
||||||
deunicode = "1.0.0"
|
deunicode = "1.0.0"
|
||||||
hashbrown = { version = "0.2.2", features = ["serde"] }
|
hashbrown = { version = "0.2.2", features = ["serde"] }
|
||||||
linked-hash-map = { version = "0.5.2", features = ["serde_impl"] }
|
|
||||||
meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
|
meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
|
||||||
meilidb-tokenizer = { path = "../meilidb-tokenizer", version = "0.1.0" }
|
meilidb-tokenizer = { path = "../meilidb-tokenizer", version = "0.1.0" }
|
||||||
|
meilidb-schema = { path = "../meilidb-schema", version = "0.1.0" }
|
||||||
ordered-float = { version = "1.0.2", features = ["serde"] }
|
ordered-float = { version = "1.0.2", features = ["serde"] }
|
||||||
sdset = "0.3.2"
|
sdset = "0.3.2"
|
||||||
serde = { version = "1.0.91", features = ["derive"] }
|
serde = { version = "1.0.91", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.39", features = ["preserve_order"] }
|
|
||||||
rocksdb = { version = "0.12.2", default-features = false }
|
rocksdb = { version = "0.12.2", default-features = false }
|
||||||
toml = { version = "0.5.0", features = ["preserve_order"] }
|
|
||||||
zerocopy = "0.2.2"
|
zerocopy = "0.2.2"
|
||||||
|
|
||||||
[dependencies.rmp-serde]
|
[dependencies.rmp-serde]
|
||||||
@ -30,3 +28,4 @@ branch = "arc-byte-slice"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.0.7"
|
tempfile = "3.0.7"
|
||||||
|
serde_json = "1.0.39"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
use rocksdb::DBVector;
|
use rocksdb::DBVector;
|
||||||
|
|
||||||
use crate::database::raw_index::InnerRawIndex;
|
use crate::database::raw_index::InnerRawIndex;
|
||||||
use crate::document_attr_key::DocumentAttrKey;
|
use crate::document_attr_key::DocumentAttrKey;
|
||||||
use crate::schema::SchemaAttr;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DocumentsIndex(pub(crate) InnerRawIndex);
|
pub struct DocumentsIndex(pub(crate) InnerRawIndex);
|
||||||
@ -52,7 +52,7 @@ impl DocumentsIndex {
|
|||||||
let from = rocksdb::IteratorMode::Start;
|
let from = rocksdb::IteratorMode::Start;
|
||||||
let iterator = self.0.iterator(from)?;
|
let iterator = self.0.iterator(from)?;
|
||||||
|
|
||||||
for (key, value) in iterator {
|
for (key, _) in iterator {
|
||||||
let slice = key.as_ref().try_into().unwrap();
|
let slice = key.as_ref().try_into().unwrap();
|
||||||
let document_id = DocumentAttrKey::from_be_bytes(slice).document_id;
|
let document_id = DocumentAttrKey::from_be_bytes(slice).document_id;
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ use std::sync::Arc;
|
|||||||
use arc_swap::{ArcSwap, Lease};
|
use arc_swap::{ArcSwap, Lease};
|
||||||
use meilidb_core::criterion::Criteria;
|
use meilidb_core::criterion::Criteria;
|
||||||
use meilidb_core::{DocIndex, Store, DocumentId, QueryBuilder};
|
use meilidb_core::{DocIndex, Store, DocumentId, QueryBuilder};
|
||||||
|
use meilidb_schema::Schema;
|
||||||
use rmp_serde::decode::Error as RmpError;
|
use rmp_serde::decode::Error as RmpError;
|
||||||
use serde::de;
|
use serde::de;
|
||||||
|
|
||||||
use crate::ranked_map::RankedMap;
|
use crate::ranked_map::RankedMap;
|
||||||
use crate::schema::Schema;
|
|
||||||
use crate::serde::Deserializer;
|
use crate::serde::Deserializer;
|
||||||
|
|
||||||
use super::{Error, CustomSettings};
|
use super::{Error, CustomSettings};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use meilidb_schema::Schema;
|
||||||
|
|
||||||
use crate::database::raw_index::InnerRawIndex;
|
use crate::database::raw_index::InnerRawIndex;
|
||||||
use crate::ranked_map::RankedMap;
|
use crate::ranked_map::RankedMap;
|
||||||
use crate::schema::Schema;
|
|
||||||
|
|
||||||
use super::Error;
|
use super::Error;
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ use std::collections::hash_map::Entry;
|
|||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::{HashSet, HashMap};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
use meilidb_schema::Schema;
|
||||||
use crate::Schema;
|
|
||||||
|
|
||||||
mod custom_settings;
|
mod custom_settings;
|
||||||
mod docs_words_index;
|
mod docs_words_index;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
use crate::schema::SchemaAttr;
|
use meilidb_schema::SchemaAttr;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DocumentAttrKey {
|
pub struct DocumentAttrKey {
|
||||||
|
@ -3,11 +3,10 @@ use std::convert::TryFrom;
|
|||||||
|
|
||||||
use deunicode::deunicode_with_tofu;
|
use deunicode::deunicode_with_tofu;
|
||||||
use meilidb_core::{DocumentId, DocIndex};
|
use meilidb_core::{DocumentId, DocIndex};
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
use meilidb_tokenizer::{is_cjk, Tokenizer, SeqTokenizer, Token};
|
use meilidb_tokenizer::{is_cjk, Tokenizer, SeqTokenizer, Token};
|
||||||
use sdset::SetBuf;
|
use sdset::SetBuf;
|
||||||
|
|
||||||
use crate::SchemaAttr;
|
|
||||||
|
|
||||||
type Word = Vec<u8>; // TODO make it be a SmallVec
|
type Word = Vec<u8>; // TODO make it be a SmallVec
|
||||||
|
|
||||||
pub struct Indexer {
|
pub struct Indexer {
|
||||||
|
@ -4,10 +4,8 @@ mod indexer;
|
|||||||
mod number;
|
mod number;
|
||||||
mod ranked_map;
|
mod ranked_map;
|
||||||
mod serde;
|
mod serde;
|
||||||
pub mod schema;
|
|
||||||
|
|
||||||
pub use rocksdb;
|
pub use rocksdb;
|
||||||
pub use self::database::{Database, Index, CustomSettings};
|
pub use self::database::{Database, Index, CustomSettings};
|
||||||
pub use self::number::Number;
|
pub use self::number::Number;
|
||||||
pub use self::ranked_map::RankedMap;
|
pub use self::ranked_map::RankedMap;
|
||||||
pub use self::schema::{Schema, SchemaAttr};
|
|
||||||
|
@ -2,8 +2,9 @@ use std::io::{Read, Write};
|
|||||||
|
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
|
|
||||||
use crate::{SchemaAttr, Number};
|
use crate::Number;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct RankedMap(HashMap<(DocumentId, SchemaAttr), Number>);
|
pub struct RankedMap(HashMap<(DocumentId, SchemaAttr), Number>);
|
||||||
|
@ -2,12 +2,12 @@ use std::collections::HashSet;
|
|||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
use rmp_serde::decode::{Deserializer as RmpDeserializer, ReadReader};
|
use rmp_serde::decode::{Deserializer as RmpDeserializer, ReadReader};
|
||||||
use rmp_serde::decode::{Error as RmpError};
|
use rmp_serde::decode::{Error as RmpError};
|
||||||
use serde::{de, forward_to_deserialize_any};
|
use serde::{de, forward_to_deserialize_any};
|
||||||
|
|
||||||
use crate::database::Index;
|
use crate::database::Index;
|
||||||
use crate::SchemaAttr;
|
|
||||||
|
|
||||||
pub struct Deserializer<'a> {
|
pub struct Deserializer<'a> {
|
||||||
pub document_id: DocumentId,
|
pub document_id: DocumentId,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
use serde::ser;
|
use serde::ser;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::indexer::Indexer as RawIndexer;
|
use crate::indexer::Indexer as RawIndexer;
|
||||||
use crate::schema::SchemaAttr;
|
|
||||||
use super::{SerializerError, ConvertToString};
|
use super::{SerializerError, ConvertToString};
|
||||||
|
|
||||||
pub struct Indexer<'a> {
|
pub struct Indexer<'a> {
|
||||||
|
@ -26,11 +26,11 @@ use std::collections::BTreeMap;
|
|||||||
use std::{fmt, error::Error};
|
use std::{fmt, error::Error};
|
||||||
|
|
||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
use rmp_serde::encode::Error as RmpError;
|
use rmp_serde::encode::Error as RmpError;
|
||||||
use serde::ser;
|
use serde::ser;
|
||||||
|
|
||||||
use crate::number::ParseNumberError;
|
use crate::number::ParseNumberError;
|
||||||
use crate::schema::SchemaAttr;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SerializerError {
|
pub enum SerializerError {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use meilidb_core::DocumentId;
|
use meilidb_core::DocumentId;
|
||||||
|
use meilidb_schema::Schema;
|
||||||
use serde::ser;
|
use serde::ser;
|
||||||
|
|
||||||
use crate::indexer::Indexer as RawIndexer;
|
use crate::indexer::Indexer as RawIndexer;
|
||||||
use crate::ranked_map::RankedMap;
|
use crate::ranked_map::RankedMap;
|
||||||
use crate::schema::Schema;
|
|
||||||
use super::{RamDocumentStore, SerializerError, ConvertToString, ConvertToNumber, Indexer};
|
use super::{RamDocumentStore, SerializerError, ConvertToString, ConvertToNumber, Indexer};
|
||||||
|
|
||||||
pub struct Serializer<'a> {
|
pub struct Serializer<'a> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use meilidb_data::{Database, Schema};
|
use meilidb_data::Database;
|
||||||
use meilidb_data::schema::{SchemaBuilder, STORED, INDEXED};
|
use meilidb_schema::{Schema, SchemaBuilder, STORED, INDEXED};
|
||||||
|
|
||||||
fn simple_schema() -> Schema {
|
fn simple_schema() -> Schema {
|
||||||
let mut builder = SchemaBuilder::with_identifier("objectId");
|
let mut builder = SchemaBuilder::with_identifier("objectId");
|
||||||
|
12
meilidb-schema/Cargo.toml
Normal file
12
meilidb-schema/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "meilidb-schema"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Kerollmops <renault.cle@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bincode = "1.1.2"
|
||||||
|
linked-hash-map = { version = "0.5.2", features = ["serde_impl"] }
|
||||||
|
serde = { version = "1.0.91", features = ["derive"] }
|
||||||
|
serde_json = { version = "1.0.39", features = ["preserve_order"] }
|
||||||
|
toml = { version = "0.5.0", features = ["preserve_order"] }
|
@ -7,6 +7,7 @@ authors = ["Kerollmops <renault.cle@gmail.com>"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
|
meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
|
||||||
meilidb-data = { path = "../meilidb-data", version = "0.1.0" }
|
meilidb-data = { path = "../meilidb-data", version = "0.1.0" }
|
||||||
|
meilidb-schema = { path = "../meilidb-schema", version = "0.1.0" }
|
||||||
serde = { version = "1.0.91" , features = ["derive"] }
|
serde = { version = "1.0.91" , features = ["derive"] }
|
||||||
serde_json = "1.0.39"
|
serde_json = "1.0.39"
|
||||||
tempfile = "3.0.7"
|
tempfile = "3.0.7"
|
||||||
|
@ -14,7 +14,8 @@ use sysinfo::{SystemExt, ProcessExt};
|
|||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use meilidb_data::{Database, Schema};
|
use meilidb_data::Database;
|
||||||
|
use meilidb_schema::Schema;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
|
@ -13,8 +13,8 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
|||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use meilidb_core::Match;
|
use meilidb_core::Match;
|
||||||
|
|
||||||
use meilidb_data::schema::SchemaAttr;
|
|
||||||
use meilidb_data::Database;
|
use meilidb_data::Database;
|
||||||
|
use meilidb_schema::SchemaAttr;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use meilidb_data::Database;
|
||||||
|
use meilidb_schema::Schema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tide::querystring::ExtractQuery;
|
|
||||||
use tide::http::status::StatusCode;
|
|
||||||
use tide::{error::ResultExt, response, App, Context, EndpointResult};
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use meilidb_data::{Database, Schema};
|
use tide::http::status::StatusCode;
|
||||||
|
use tide::querystring::ExtractQuery;
|
||||||
|
use tide::{error::ResultExt, response, App, Context, EndpointResult};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
struct SearchQuery {
|
struct SearchQuery {
|
||||||
|
@ -2,9 +2,9 @@ use std::cmp::Ordering;
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use meilidb_core::criterion::Criterion;
|
use meilidb_core::{criterion::Criterion, RawDocument};
|
||||||
use meilidb_core::RawDocument;
|
use meilidb_data::RankedMap;
|
||||||
use meilidb_data::{Schema, SchemaAttr, RankedMap};
|
use meilidb_schema::{Schema, SchemaAttr};
|
||||||
|
|
||||||
/// An helper struct that permit to sort documents by
|
/// An helper struct that permit to sort documents by
|
||||||
/// some of their stored attributes.
|
/// some of their stored attributes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user