mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-10 15:08:56 +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-core",
|
||||
"meilidb-data",
|
||||
"meilidb-schema",
|
||||
"meilidb-tokenizer",
|
||||
]
|
||||
|
||||
|
@ -9,15 +9,13 @@ arc-swap = "0.3.11"
|
||||
bincode = "1.1.2"
|
||||
deunicode = "1.0.0"
|
||||
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-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"] }
|
||||
sdset = "0.3.2"
|
||||
serde = { version = "1.0.91", features = ["derive"] }
|
||||
serde_json = { version = "1.0.39", features = ["preserve_order"] }
|
||||
rocksdb = { version = "0.12.2", default-features = false }
|
||||
toml = { version = "0.5.0", features = ["preserve_order"] }
|
||||
zerocopy = "0.2.2"
|
||||
|
||||
[dependencies.rmp-serde]
|
||||
@ -30,3 +28,4 @@ branch = "arc-byte-slice"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.0.7"
|
||||
serde_json = "1.0.39"
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::convert::TryInto;
|
||||
|
||||
use meilidb_core::DocumentId;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
use rocksdb::DBVector;
|
||||
|
||||
use crate::database::raw_index::InnerRawIndex;
|
||||
use crate::document_attr_key::DocumentAttrKey;
|
||||
use crate::schema::SchemaAttr;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DocumentsIndex(pub(crate) InnerRawIndex);
|
||||
@ -52,7 +52,7 @@ impl DocumentsIndex {
|
||||
let from = rocksdb::IteratorMode::Start;
|
||||
let iterator = self.0.iterator(from)?;
|
||||
|
||||
for (key, value) in iterator {
|
||||
for (key, _) in iterator {
|
||||
let slice = key.as_ref().try_into().unwrap();
|
||||
let document_id = DocumentAttrKey::from_be_bytes(slice).document_id;
|
||||
|
||||
|
@ -5,11 +5,11 @@ use std::sync::Arc;
|
||||
use arc_swap::{ArcSwap, Lease};
|
||||
use meilidb_core::criterion::Criteria;
|
||||
use meilidb_core::{DocIndex, Store, DocumentId, QueryBuilder};
|
||||
use meilidb_schema::Schema;
|
||||
use rmp_serde::decode::Error as RmpError;
|
||||
use serde::de;
|
||||
|
||||
use crate::ranked_map::RankedMap;
|
||||
use crate::schema::Schema;
|
||||
use crate::serde::Deserializer;
|
||||
|
||||
use super::{Error, CustomSettings};
|
||||
|
@ -1,8 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use meilidb_schema::Schema;
|
||||
|
||||
use crate::database::raw_index::InnerRawIndex;
|
||||
use crate::ranked_map::RankedMap;
|
||||
use crate::schema::Schema;
|
||||
|
||||
use super::Error;
|
||||
|
||||
|
@ -2,8 +2,7 @@ use std::collections::hash_map::Entry;
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::Schema;
|
||||
use meilidb_schema::Schema;
|
||||
|
||||
mod custom_settings;
|
||||
mod docs_words_index;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use meilidb_core::DocumentId;
|
||||
use crate::schema::SchemaAttr;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DocumentAttrKey {
|
||||
|
@ -3,11 +3,10 @@ use std::convert::TryFrom;
|
||||
|
||||
use deunicode::deunicode_with_tofu;
|
||||
use meilidb_core::{DocumentId, DocIndex};
|
||||
use meilidb_schema::SchemaAttr;
|
||||
use meilidb_tokenizer::{is_cjk, Tokenizer, SeqTokenizer, Token};
|
||||
use sdset::SetBuf;
|
||||
|
||||
use crate::SchemaAttr;
|
||||
|
||||
type Word = Vec<u8>; // TODO make it be a SmallVec
|
||||
|
||||
pub struct Indexer {
|
||||
|
@ -4,10 +4,8 @@ mod indexer;
|
||||
mod number;
|
||||
mod ranked_map;
|
||||
mod serde;
|
||||
pub mod schema;
|
||||
|
||||
pub use rocksdb;
|
||||
pub use self::database::{Database, Index, CustomSettings};
|
||||
pub use self::number::Number;
|
||||
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 meilidb_core::DocumentId;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
|
||||
use crate::{SchemaAttr, Number};
|
||||
use crate::Number;
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct RankedMap(HashMap<(DocumentId, SchemaAttr), Number>);
|
||||
|
@ -2,12 +2,12 @@ use std::collections::HashSet;
|
||||
use std::io::Cursor;
|
||||
|
||||
use meilidb_core::DocumentId;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
use rmp_serde::decode::{Deserializer as RmpDeserializer, ReadReader};
|
||||
use rmp_serde::decode::{Error as RmpError};
|
||||
use serde::{de, forward_to_deserialize_any};
|
||||
|
||||
use crate::database::Index;
|
||||
use crate::SchemaAttr;
|
||||
|
||||
pub struct Deserializer<'a> {
|
||||
pub document_id: DocumentId,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use meilidb_core::DocumentId;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
use serde::ser;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::indexer::Indexer as RawIndexer;
|
||||
use crate::schema::SchemaAttr;
|
||||
use super::{SerializerError, ConvertToString};
|
||||
|
||||
pub struct Indexer<'a> {
|
||||
|
@ -26,11 +26,11 @@ use std::collections::BTreeMap;
|
||||
use std::{fmt, error::Error};
|
||||
|
||||
use meilidb_core::DocumentId;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
use rmp_serde::encode::Error as RmpError;
|
||||
use serde::ser;
|
||||
|
||||
use crate::number::ParseNumberError;
|
||||
use crate::schema::SchemaAttr;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SerializerError {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use meilidb_core::DocumentId;
|
||||
use meilidb_schema::Schema;
|
||||
use serde::ser;
|
||||
|
||||
use crate::indexer::Indexer as RawIndexer;
|
||||
use crate::ranked_map::RankedMap;
|
||||
use crate::schema::Schema;
|
||||
use super::{RamDocumentStore, SerializerError, ConvertToString, ConvertToNumber, Indexer};
|
||||
|
||||
pub struct Serializer<'a> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use serde_json::json;
|
||||
use meilidb_data::{Database, Schema};
|
||||
use meilidb_data::schema::{SchemaBuilder, STORED, INDEXED};
|
||||
use meilidb_data::Database;
|
||||
use meilidb_schema::{Schema, SchemaBuilder, STORED, INDEXED};
|
||||
|
||||
fn simple_schema() -> Schema {
|
||||
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]
|
||||
meilidb-core = { path = "../meilidb-core", 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_json = "1.0.39"
|
||||
tempfile = "3.0.7"
|
||||
|
@ -14,7 +14,8 @@ use sysinfo::{SystemExt, ProcessExt};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use structopt::StructOpt;
|
||||
|
||||
use meilidb_data::{Database, Schema};
|
||||
use meilidb_data::Database;
|
||||
use meilidb_schema::Schema;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Opt {
|
||||
|
@ -13,8 +13,8 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
use structopt::StructOpt;
|
||||
use meilidb_core::Match;
|
||||
|
||||
use meilidb_data::schema::SchemaAttr;
|
||||
use meilidb_data::Database;
|
||||
use meilidb_schema::SchemaAttr;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Opt {
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use meilidb_data::Database;
|
||||
use meilidb_schema::Schema;
|
||||
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 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)]
|
||||
struct SearchQuery {
|
||||
|
@ -2,9 +2,9 @@ use std::cmp::Ordering;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
use meilidb_core::criterion::Criterion;
|
||||
use meilidb_core::RawDocument;
|
||||
use meilidb_data::{Schema, SchemaAttr, RankedMap};
|
||||
use meilidb_core::{criterion::Criterion, RawDocument};
|
||||
use meilidb_data::RankedMap;
|
||||
use meilidb_schema::{Schema, SchemaAttr};
|
||||
|
||||
/// An helper struct that permit to sort documents by
|
||||
/// some of their stored attributes.
|
||||
|
Loading…
Reference in New Issue
Block a user