mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-11-04 09:56:28 +00:00 
			
		
		
		
	get rid of chrono in favor of time
This commit is contained in:
		@@ -9,7 +9,6 @@ bimap = { version = "0.6.1", features = ["serde"] }
 | 
				
			|||||||
bincode = "1.3.3"
 | 
					bincode = "1.3.3"
 | 
				
			||||||
bstr = "0.2.15"
 | 
					bstr = "0.2.15"
 | 
				
			||||||
byteorder = "1.4.2"
 | 
					byteorder = "1.4.2"
 | 
				
			||||||
chrono = { version = "0.4.19", features = ["serde"] }
 | 
					 | 
				
			||||||
concat-arrays = "0.1.2"
 | 
					concat-arrays = "0.1.2"
 | 
				
			||||||
crossbeam-channel = "0.5.1"
 | 
					crossbeam-channel = "0.5.1"
 | 
				
			||||||
either = "1.6.1"
 | 
					either = "1.6.1"
 | 
				
			||||||
@@ -36,6 +35,7 @@ slice-group-by = "0.2.6"
 | 
				
			|||||||
smallstr =  { version = "0.2.0", features = ["serde"] }
 | 
					smallstr =  { version = "0.2.0", features = ["serde"] }
 | 
				
			||||||
smallvec = "1.6.1"
 | 
					smallvec = "1.6.1"
 | 
				
			||||||
tempfile = "3.2.0"
 | 
					tempfile = "3.2.0"
 | 
				
			||||||
 | 
					time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsing", "macros"] }
 | 
				
			||||||
uuid = { version = "0.8.2", features = ["v4"] }
 | 
					uuid = { version = "0.8.2", features = ["v4"] }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
filter-parser = { path = "../filter-parser" }
 | 
					filter-parser = { path = "../filter-parser" }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,12 +3,12 @@ use std::collections::{HashMap, HashSet};
 | 
				
			|||||||
use std::mem::size_of;
 | 
					use std::mem::size_of;
 | 
				
			||||||
use std::path::Path;
 | 
					use std::path::Path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use chrono::{DateTime, Utc};
 | 
					 | 
				
			||||||
use heed::flags::Flags;
 | 
					use heed::flags::Flags;
 | 
				
			||||||
use heed::types::*;
 | 
					use heed::types::*;
 | 
				
			||||||
use heed::{Database, PolyDatabase, RoTxn, RwTxn};
 | 
					use heed::{Database, PolyDatabase, RoTxn, RwTxn};
 | 
				
			||||||
use roaring::RoaringBitmap;
 | 
					use roaring::RoaringBitmap;
 | 
				
			||||||
use rstar::RTree;
 | 
					use rstar::RTree;
 | 
				
			||||||
 | 
					use time::OffsetDateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::error::{InternalError, UserError};
 | 
					use crate::error::{InternalError, UserError};
 | 
				
			||||||
use crate::fields_ids_map::FieldsIdsMap;
 | 
					use crate::fields_ids_map::FieldsIdsMap;
 | 
				
			||||||
@@ -156,10 +156,19 @@ impl Index {
 | 
				
			|||||||
    fn initialize_creation_dates(env: &heed::Env, main: PolyDatabase) -> heed::Result<()> {
 | 
					    fn initialize_creation_dates(env: &heed::Env, main: PolyDatabase) -> heed::Result<()> {
 | 
				
			||||||
        let mut txn = env.write_txn()?;
 | 
					        let mut txn = env.write_txn()?;
 | 
				
			||||||
        // The db was just created, we update its metadata with the relevant information.
 | 
					        // The db was just created, we update its metadata with the relevant information.
 | 
				
			||||||
        if main.get::<_, Str, SerdeJson<DateTime<Utc>>>(&txn, main_key::CREATED_AT_KEY)?.is_none() {
 | 
					        if main.get::<_, Str, SerdeJson<OffsetDateTime>>(&txn, main_key::CREATED_AT_KEY)?.is_none()
 | 
				
			||||||
            let now = Utc::now();
 | 
					        {
 | 
				
			||||||
            main.put::<_, Str, SerdeJson<DateTime<Utc>>>(&mut txn, main_key::UPDATED_AT_KEY, &now)?;
 | 
					            let now = OffsetDateTime::now_utc();
 | 
				
			||||||
            main.put::<_, Str, SerdeJson<DateTime<Utc>>>(&mut txn, main_key::CREATED_AT_KEY, &now)?;
 | 
					            main.put::<_, Str, SerdeJson<OffsetDateTime>>(
 | 
				
			||||||
 | 
					                &mut txn,
 | 
				
			||||||
 | 
					                main_key::UPDATED_AT_KEY,
 | 
				
			||||||
 | 
					                &now,
 | 
				
			||||||
 | 
					            )?;
 | 
				
			||||||
 | 
					            main.put::<_, Str, SerdeJson<OffsetDateTime>>(
 | 
				
			||||||
 | 
					                &mut txn,
 | 
				
			||||||
 | 
					                main_key::CREATED_AT_KEY,
 | 
				
			||||||
 | 
					                &now,
 | 
				
			||||||
 | 
					            )?;
 | 
				
			||||||
            txn.commit()?;
 | 
					            txn.commit()?;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Ok(())
 | 
					        Ok(())
 | 
				
			||||||
@@ -219,7 +228,7 @@ impl Index {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /// Writes the documents primary key, this is the field name that is used to store the id.
 | 
					    /// Writes the documents primary key, this is the field name that is used to store the id.
 | 
				
			||||||
    pub(crate) fn put_primary_key(&self, wtxn: &mut RwTxn, primary_key: &str) -> heed::Result<()> {
 | 
					    pub(crate) fn put_primary_key(&self, wtxn: &mut RwTxn, primary_key: &str) -> heed::Result<()> {
 | 
				
			||||||
        self.set_updated_at(wtxn, &Utc::now())?;
 | 
					        self.set_updated_at(wtxn, &OffsetDateTime::now_utc())?;
 | 
				
			||||||
        self.main.put::<_, Str, Str>(wtxn, main_key::PRIMARY_KEY_KEY, &primary_key)
 | 
					        self.main.put::<_, Str, Str>(wtxn, main_key::PRIMARY_KEY_KEY, &primary_key)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -829,10 +838,10 @@ impl Index {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns the index creation time.
 | 
					    /// Returns the index creation time.
 | 
				
			||||||
    pub fn created_at(&self, rtxn: &RoTxn) -> Result<DateTime<Utc>> {
 | 
					    pub fn created_at(&self, rtxn: &RoTxn) -> Result<OffsetDateTime> {
 | 
				
			||||||
        Ok(self
 | 
					        Ok(self
 | 
				
			||||||
            .main
 | 
					            .main
 | 
				
			||||||
            .get::<_, Str, SerdeJson<DateTime<Utc>>>(rtxn, main_key::CREATED_AT_KEY)?
 | 
					            .get::<_, Str, SerdeJson<OffsetDateTime>>(rtxn, main_key::CREATED_AT_KEY)?
 | 
				
			||||||
            .ok_or(InternalError::DatabaseMissingEntry {
 | 
					            .ok_or(InternalError::DatabaseMissingEntry {
 | 
				
			||||||
                db_name: db_name::MAIN,
 | 
					                db_name: db_name::MAIN,
 | 
				
			||||||
                key: Some(main_key::CREATED_AT_KEY),
 | 
					                key: Some(main_key::CREATED_AT_KEY),
 | 
				
			||||||
@@ -840,10 +849,10 @@ impl Index {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns the index last updated time.
 | 
					    /// Returns the index last updated time.
 | 
				
			||||||
    pub fn updated_at(&self, rtxn: &RoTxn) -> Result<DateTime<Utc>> {
 | 
					    pub fn updated_at(&self, rtxn: &RoTxn) -> Result<OffsetDateTime> {
 | 
				
			||||||
        Ok(self
 | 
					        Ok(self
 | 
				
			||||||
            .main
 | 
					            .main
 | 
				
			||||||
            .get::<_, Str, SerdeJson<DateTime<Utc>>>(rtxn, main_key::UPDATED_AT_KEY)?
 | 
					            .get::<_, Str, SerdeJson<OffsetDateTime>>(rtxn, main_key::UPDATED_AT_KEY)?
 | 
				
			||||||
            .ok_or(InternalError::DatabaseMissingEntry {
 | 
					            .ok_or(InternalError::DatabaseMissingEntry {
 | 
				
			||||||
                db_name: db_name::MAIN,
 | 
					                db_name: db_name::MAIN,
 | 
				
			||||||
                key: Some(main_key::UPDATED_AT_KEY),
 | 
					                key: Some(main_key::UPDATED_AT_KEY),
 | 
				
			||||||
@@ -853,9 +862,9 @@ impl Index {
 | 
				
			|||||||
    pub(crate) fn set_updated_at(
 | 
					    pub(crate) fn set_updated_at(
 | 
				
			||||||
        &self,
 | 
					        &self,
 | 
				
			||||||
        wtxn: &mut RwTxn,
 | 
					        wtxn: &mut RwTxn,
 | 
				
			||||||
        time: &DateTime<Utc>,
 | 
					        time: &OffsetDateTime,
 | 
				
			||||||
    ) -> heed::Result<()> {
 | 
					    ) -> heed::Result<()> {
 | 
				
			||||||
        self.main.put::<_, Str, SerdeJson<DateTime<Utc>>>(wtxn, main_key::UPDATED_AT_KEY, &time)
 | 
					        self.main.put::<_, Str, SerdeJson<OffsetDateTime>>(wtxn, main_key::UPDATED_AT_KEY, &time)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
use chrono::Utc;
 | 
					 | 
				
			||||||
use roaring::RoaringBitmap;
 | 
					use roaring::RoaringBitmap;
 | 
				
			||||||
 | 
					use time::OffsetDateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{ExternalDocumentsIds, FieldDistribution, Index, Result};
 | 
					use crate::{ExternalDocumentsIds, FieldDistribution, Index, Result};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -14,7 +14,7 @@ impl<'t, 'u, 'i> ClearDocuments<'t, 'u, 'i> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn execute(self) -> Result<u64> {
 | 
					    pub fn execute(self) -> Result<u64> {
 | 
				
			||||||
        self.index.set_updated_at(self.wtxn, &Utc::now())?;
 | 
					        self.index.set_updated_at(self.wtxn, &OffsetDateTime::now_utc())?;
 | 
				
			||||||
        let Index {
 | 
					        let Index {
 | 
				
			||||||
            env: _env,
 | 
					            env: _env,
 | 
				
			||||||
            main: _main,
 | 
					            main: _main,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,13 @@
 | 
				
			|||||||
use std::collections::btree_map::Entry;
 | 
					use std::collections::btree_map::Entry;
 | 
				
			||||||
use std::collections::HashMap;
 | 
					use std::collections::HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use chrono::Utc;
 | 
					 | 
				
			||||||
use fst::IntoStreamer;
 | 
					use fst::IntoStreamer;
 | 
				
			||||||
use heed::types::ByteSlice;
 | 
					use heed::types::ByteSlice;
 | 
				
			||||||
use heed::{BytesDecode, BytesEncode};
 | 
					use heed::{BytesDecode, BytesEncode};
 | 
				
			||||||
use roaring::RoaringBitmap;
 | 
					use roaring::RoaringBitmap;
 | 
				
			||||||
use serde::{Deserialize, Serialize};
 | 
					use serde::{Deserialize, Serialize};
 | 
				
			||||||
use serde_json::Value;
 | 
					use serde_json::Value;
 | 
				
			||||||
 | 
					use time::OffsetDateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use super::ClearDocuments;
 | 
					use super::ClearDocuments;
 | 
				
			||||||
use crate::error::{InternalError, SerializationError, UserError};
 | 
					use crate::error::{InternalError, SerializationError, UserError};
 | 
				
			||||||
@@ -61,7 +61,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn execute(self) -> Result<DocumentDeletionResult> {
 | 
					    pub fn execute(self) -> Result<DocumentDeletionResult> {
 | 
				
			||||||
        self.index.set_updated_at(self.wtxn, &Utc::now())?;
 | 
					        self.index.set_updated_at(self.wtxn, &OffsetDateTime::now_utc())?;
 | 
				
			||||||
        // We retrieve the current documents ids that are in the database.
 | 
					        // We retrieve the current documents ids that are in the database.
 | 
				
			||||||
        let mut documents_ids = self.index.documents_ids(self.wtxn)?;
 | 
					        let mut documents_ids = self.index.documents_ids(self.wtxn)?;
 | 
				
			||||||
        let current_documents_ids_len = documents_ids.len();
 | 
					        let current_documents_ids_len = documents_ids.len();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,12 +2,12 @@ use std::fs::File;
 | 
				
			|||||||
use std::num::{NonZeroU8, NonZeroUsize};
 | 
					use std::num::{NonZeroU8, NonZeroUsize};
 | 
				
			||||||
use std::{cmp, mem};
 | 
					use std::{cmp, mem};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use chrono::Utc;
 | 
					 | 
				
			||||||
use grenad::{CompressionType, Reader, Writer};
 | 
					use grenad::{CompressionType, Reader, Writer};
 | 
				
			||||||
use heed::types::{ByteSlice, DecodeIgnore};
 | 
					use heed::types::{ByteSlice, DecodeIgnore};
 | 
				
			||||||
use heed::{BytesEncode, Error};
 | 
					use heed::{BytesEncode, Error};
 | 
				
			||||||
use log::debug;
 | 
					use log::debug;
 | 
				
			||||||
use roaring::RoaringBitmap;
 | 
					use roaring::RoaringBitmap;
 | 
				
			||||||
 | 
					use time::OffsetDateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::error::InternalError;
 | 
					use crate::error::InternalError;
 | 
				
			||||||
use crate::heed_codec::facet::{
 | 
					use crate::heed_codec::facet::{
 | 
				
			||||||
@@ -53,7 +53,7 @@ impl<'t, 'u, 'i> Facets<'t, 'u, 'i> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    #[logging_timer::time("Facets::{}")]
 | 
					    #[logging_timer::time("Facets::{}")]
 | 
				
			||||||
    pub fn execute(self) -> Result<()> {
 | 
					    pub fn execute(self) -> Result<()> {
 | 
				
			||||||
        self.index.set_updated_at(self.wtxn, &Utc::now())?;
 | 
					        self.index.set_updated_at(self.wtxn, &OffsetDateTime::now_utc())?;
 | 
				
			||||||
        // We get the faceted fields to be able to create the facet levels.
 | 
					        // We get the faceted fields to be able to create the facet levels.
 | 
				
			||||||
        let faceted_fields = self.index.faceted_fields_ids(self.wtxn)?;
 | 
					        let faceted_fields = self.index.faceted_fields_ids(self.wtxn)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
use std::collections::{BTreeSet, HashMap, HashSet};
 | 
					use std::collections::{BTreeSet, HashMap, HashSet};
 | 
				
			||||||
use std::result::Result as StdResult;
 | 
					use std::result::Result as StdResult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use chrono::Utc;
 | 
					 | 
				
			||||||
use itertools::Itertools;
 | 
					use itertools::Itertools;
 | 
				
			||||||
use meilisearch_tokenizer::{Analyzer, AnalyzerConfig};
 | 
					use meilisearch_tokenizer::{Analyzer, AnalyzerConfig};
 | 
				
			||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
 | 
					use serde::{Deserialize, Deserializer, Serialize, Serializer};
 | 
				
			||||||
 | 
					use time::OffsetDateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use super::index_documents::{IndexDocumentsConfig, Transform};
 | 
					use super::index_documents::{IndexDocumentsConfig, Transform};
 | 
				
			||||||
use super::IndexerConfig;
 | 
					use super::IndexerConfig;
 | 
				
			||||||
@@ -454,7 +454,7 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
 | 
				
			|||||||
    where
 | 
					    where
 | 
				
			||||||
        F: Fn(UpdateIndexingStep) + Sync,
 | 
					        F: Fn(UpdateIndexingStep) + Sync,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        self.index.set_updated_at(self.wtxn, &Utc::now())?;
 | 
					        self.index.set_updated_at(self.wtxn, &OffsetDateTime::now_utc())?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let old_faceted_fields = self.index.faceted_fields(&self.wtxn)?;
 | 
					        let old_faceted_fields = self.index.faceted_fields(&self.wtxn)?;
 | 
				
			||||||
        let old_fields_ids_map = self.index.fields_ids_map(&self.wtxn)?;
 | 
					        let old_fields_ids_map = self.index.fields_ids_map(&self.wtxn)?;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user