feat: Save the schema in the key-value store

This commit is contained in:
Clément Renault
2018-11-21 15:19:29 +01:00
parent 8df068af3c
commit 86f23d2695
4 changed files with 63 additions and 34 deletions

View File

@ -5,10 +5,11 @@ use std::fmt::Write;
use ::rocksdb::rocksdb_options;
use crate::index::schema::{SchemaProps, Schema, SchemaAttr};
use crate::index::update::{FIELD_BLOBS_ORDER, Update};
use crate::tokenizer::TokenizerBuilder;
use crate::index::DATA_BLOBS_ORDER;
use crate::index::update::Update;
use crate::index::blob_name::BlobName;
use crate::index::schema::{SchemaProps, Schema, SchemaAttr};
use crate::tokenizer::TokenizerBuilder;
use crate::blob::PositiveBlobBuilder;
use crate::{DocIndex, DocumentId};
@ -66,7 +67,7 @@ where B: TokenizerBuilder
// write the blob name to be merged
let blob_name = blob_name.to_string();
file_writer.put(FIELD_BLOBS_ORDER.as_bytes(), blob_name.as_bytes())?;
file_writer.put(DATA_BLOBS_ORDER.as_bytes(), blob_name.as_bytes())?;
let mut builder = PositiveBlobBuilder::new(Vec::new(), Vec::new());
for ((document_id, field), state) in &self.new_states {
@ -96,15 +97,15 @@ where B: TokenizerBuilder
let (blob_fst_map, blob_doc_idx) = builder.into_inner()?;
// write the fst
let blob_key = format!("0b-{}-fst", blob_name);
let blob_key = format!("BLOB-{}-fst", blob_name);
file_writer.put(blob_key.as_bytes(), &blob_fst_map)?;
// write the doc-idx
let blob_key = format!("0b-{}-doc-idx", blob_name);
let blob_key = format!("BLOB-{}-doc-idx", blob_name);
file_writer.put(blob_key.as_bytes(), &blob_doc_idx)?;
// write all the documents fields updates
let mut key = String::from("5d-");
let mut key = String::from("DOCU-");
let prefix_len = key.len();
for ((id, field), state) in self.new_states {