1#[cfg(feature = "native")]
11use crate::dsl::Schema;
12#[cfg(feature = "native")]
13use crate::error::Result;
14#[cfg(feature = "sync")]
15use std::collections::HashMap;
16#[cfg(feature = "native")]
17use std::sync::Arc;
18#[cfg(feature = "native")]
19use std::sync::{OnceLock, Weak};
20
21mod searcher;
22pub use searcher::Searcher;
23
24#[cfg(feature = "native")]
25mod primary_key;
26#[cfg(feature = "native")]
27mod reader;
28#[cfg(feature = "native")]
29mod vector_builder;
30#[cfg(all(feature = "wasm", not(feature = "native")))]
31mod wasm_writer;
32#[cfg(feature = "native")]
33mod writer;
34#[cfg(feature = "native")]
35pub use primary_key::PrimaryKeyIndex;
36#[cfg(feature = "native")]
37pub use reader::IndexReader;
38#[cfg(feature = "native")]
39pub use vector_builder::{AlterVectorIndexOutcome, AlterVectorIndexState};
40#[cfg(all(feature = "wasm", not(feature = "native")))]
41pub use wasm_writer::IndexWriter as WasmIndexWriter;
42#[cfg(feature = "native")]
43pub use writer::{IndexWriter, PreparedCommit, WRITER_LOCK_FILENAME};
44
45mod metadata;
46pub use metadata::{
47 FieldVectorMeta, INDEX_META_FILENAME, IndexMetadata, SegmentMetaInfo, VectorIndexState,
48};
49
50#[cfg(feature = "native")]
51mod helpers;
52#[cfg(feature = "native")]
53pub use helpers::{
54 IndexingStats, SchemaConfig, SchemaFieldConfig, create_index_at_path, create_index_from_sdl,
55 index_documents_from_reader, index_json_document, parse_schema,
56};
57
58pub const SLICE_CACHE_FILENAME: &str = "index.slicecache";
60
61#[cfg(feature = "native")]
65pub const MAX_CONCURRENT_REORDER_PASSES: usize = 2;
66
67#[cfg(feature = "native")]
68#[derive(Clone, Copy, Debug, Eq, PartialEq)]
69pub(crate) enum ReorderPriority {
70 Optimizer,
75 AutomaticMerge,
77 Foreground,
78}
79
80#[cfg(feature = "native")]
86#[derive(Debug)]
87pub struct ReorderConcurrencyGate {
88 permits: Arc<tokio::sync::Semaphore>,
89 optimizer_permits: Arc<tokio::sync::Semaphore>,
94 automatic_merge_permits: Arc<tokio::sync::Semaphore>,
98 limit: usize,
99 foreground_lock: Arc<tokio::sync::Mutex<()>>,
100 foreground_active: std::sync::atomic::AtomicBool,
101 foreground_finished: tokio::sync::Notify,
102}
103
104#[cfg(feature = "native")]
110#[derive(Debug)]
111pub(crate) struct BmpIoGate {
112 limit: usize,
113 active: parking_lot::Mutex<usize>,
114 available: parking_lot::Condvar,
115 async_available: tokio::sync::Notify,
116}
117
118#[cfg(feature = "native")]
119impl BmpIoGate {
120 fn new(limit: usize) -> Self {
121 Self {
122 limit,
123 active: parking_lot::Mutex::new(0),
124 available: parking_lot::Condvar::new(),
125 async_available: tokio::sync::Notify::new(),
126 }
127 }
128
129 #[cfg(feature = "sync")]
130 fn acquire(&self) -> BmpIoPermit<'_> {
131 let mut active = self.active.lock();
132 while *active >= self.limit {
133 self.available.wait(&mut active);
134 }
135 *active += 1;
136 BmpIoPermit { gate: self }
137 }
138
139 async fn acquire_async(&self) -> BmpIoPermit<'_> {
140 loop {
141 let notified = self.async_available.notified();
144 {
145 let mut active = self.active.lock();
146 if *active < self.limit {
147 *active += 1;
148 return BmpIoPermit { gate: self };
149 }
150 }
151 notified.await;
152 }
153 }
154}
155
156#[cfg(feature = "native")]
157struct BmpIoPermit<'a> {
158 gate: &'a BmpIoGate,
159}
160
161#[cfg(feature = "native")]
162impl Drop for BmpIoPermit<'_> {
163 fn drop(&mut self) {
164 let mut active = self.gate.active.lock();
165 *active -= 1;
166 self.gate.available.notify_one();
167 self.gate.async_available.notify_one();
168 }
169}
170
171#[cfg(feature = "native")]
172impl ReorderConcurrencyGate {
173 pub fn new(requested_limit: usize) -> Self {
174 let limit = requested_limit.clamp(1, MAX_CONCURRENT_REORDER_PASSES);
175 let automatic_merge_limit = limit.saturating_sub(1).max(1);
176 Self {
177 permits: Arc::new(tokio::sync::Semaphore::new(limit)),
178 optimizer_permits: Arc::new(tokio::sync::Semaphore::new(1)),
179 automatic_merge_permits: Arc::new(tokio::sync::Semaphore::new(automatic_merge_limit)),
180 limit,
181 foreground_lock: Arc::new(tokio::sync::Mutex::new(())),
182 foreground_active: std::sync::atomic::AtomicBool::new(false),
183 foreground_finished: tokio::sync::Notify::new(),
184 }
185 }
186
187 pub fn limit(&self) -> usize {
188 self.limit
189 }
190
191 pub(crate) async fn acquire(
192 self: &Arc<Self>,
193 priority: ReorderPriority,
194 ) -> std::result::Result<ReorderPermit, tokio::sync::AcquireError> {
195 match priority {
196 ReorderPriority::Optimizer => {
197 let optimizer_permit = Arc::clone(&self.optimizer_permits).acquire_owned().await?;
198 self.acquire_background(Some(optimizer_permit), None).await
199 }
200 ReorderPriority::AutomaticMerge => {
201 let merge_permit = Arc::clone(&self.automatic_merge_permits)
202 .acquire_owned()
203 .await?;
204 self.acquire_background(None, Some(merge_permit)).await
205 }
206 ReorderPriority::Foreground => self.acquire_foreground().await,
207 }
208 }
209
210 async fn acquire_background(
212 self: &Arc<Self>,
213 optimizer: Option<tokio::sync::OwnedSemaphorePermit>,
214 automatic_merge: Option<tokio::sync::OwnedSemaphorePermit>,
215 ) -> std::result::Result<ReorderPermit, tokio::sync::AcquireError> {
216 loop {
217 if self
218 .foreground_active
219 .load(std::sync::atomic::Ordering::Acquire)
220 {
221 let notified = self.foreground_finished.notified();
222 if self
223 .foreground_active
224 .load(std::sync::atomic::Ordering::Acquire)
225 {
226 notified.await;
227 continue;
228 }
229 }
230
231 let permit = Arc::clone(&self.permits).acquire_owned().await?;
232 if !self
233 .foreground_active
234 .load(std::sync::atomic::Ordering::Acquire)
235 {
236 return Ok(ReorderPermit {
237 _permit: permit,
238 _optimizer: optimizer,
239 _automatic_merge: automatic_merge,
240 });
241 }
242 drop(permit);
245 }
246 }
247
248 async fn acquire_foreground(
250 self: &Arc<Self>,
251 ) -> std::result::Result<ReorderPermit, tokio::sync::AcquireError> {
252 let permit = Arc::clone(&self.permits).acquire_owned().await?;
253 Ok(ReorderPermit {
254 _permit: permit,
255 _optimizer: None,
256 _automatic_merge: None,
257 })
258 }
259
260 pub(crate) async fn begin_foreground(
266 self: &Arc<Self>,
267 ) -> std::result::Result<ForegroundReorderGuard, tokio::sync::AcquireError> {
268 let exclusive = Arc::clone(&self.foreground_lock).lock_owned().await;
269 self.foreground_active
270 .store(true, std::sync::atomic::Ordering::Release);
271
272 let mut guard = ForegroundReorderGuard {
276 gate: Arc::clone(self),
277 reserved: None,
278 _exclusive: exclusive,
279 };
280 if self.limit > 1 {
281 guard.reserved = Some(
282 Arc::clone(&self.permits)
283 .acquire_many_owned((self.limit - 1) as u32)
284 .await?,
285 );
286 }
287 Ok(guard)
288 }
289}
290
291#[cfg(feature = "native")]
292pub(crate) struct ReorderPermit {
293 _permit: tokio::sync::OwnedSemaphorePermit,
294 _optimizer: Option<tokio::sync::OwnedSemaphorePermit>,
295 _automatic_merge: Option<tokio::sync::OwnedSemaphorePermit>,
296}
297
298#[cfg(feature = "native")]
299pub(crate) struct ForegroundReorderGuard {
300 gate: Arc<ReorderConcurrencyGate>,
301 reserved: Option<tokio::sync::OwnedSemaphorePermit>,
302 _exclusive: tokio::sync::OwnedMutexGuard<()>,
303}
304
305#[cfg(feature = "native")]
306impl Drop for ForegroundReorderGuard {
307 fn drop(&mut self) {
308 drop(self.reserved.take());
310 self.gate
311 .foreground_active
312 .store(false, std::sync::atomic::Ordering::Release);
313 self.gate.foreground_finished.notify_waiters();
314 }
315}
316
317#[derive(Debug, Clone)]
319pub struct IndexConfig {
320 pub num_threads: usize,
326 pub bmp_io_concurrency: usize,
331 pub num_indexing_threads: usize,
333 pub num_compression_threads: usize,
337 pub term_cache_blocks: usize,
339 pub store_cache_budget_bytes: usize,
346 pub max_indexing_memory_bytes: usize,
348 pub vector_training_max_samples: usize,
352 pub vector_training_memory_bytes: usize,
354 pub merge_policy: Box<dyn crate::merge::MergePolicy>,
356 pub optimization: crate::structures::IndexOptimization,
358 pub reload_interval_ms: u64,
360 pub max_concurrent_merges: usize,
362 #[cfg(feature = "native")]
366 pub background_merge_permits: Arc<tokio::sync::Semaphore>,
367 pub merge_bp_time_budget: Option<std::time::Duration>,
374 pub bp_memory_budget_bytes: usize,
381 #[cfg(feature = "native")]
387 pub background_reorder_permits: Arc<ReorderConcurrencyGate>,
388 #[cfg(feature = "native")]
392 pub background_reorder_pool: Option<Arc<rayon::ThreadPool>>,
393}
394
395#[cfg(feature = "sync")]
399static SEARCH_CPU_POOLS: OnceLock<parking_lot::Mutex<HashMap<usize, Weak<rayon::ThreadPool>>>> =
400 OnceLock::new();
401
402#[cfg(feature = "native")]
407static STORE_CACHE_POOLS: OnceLock<
408 parking_lot::Mutex<std::collections::HashMap<usize, Weak<crate::segment::SharedStoreCache>>>,
409> = OnceLock::new();
410
411#[cfg(feature = "native")]
412static BMP_IO_GATES: OnceLock<
413 parking_lot::Mutex<std::collections::HashMap<usize, Weak<BmpIoGate>>>,
414> = OnceLock::new();
415
416#[cfg(feature = "native")]
417pub(crate) fn shared_bmp_io_gate(limit: usize) -> Arc<BmpIoGate> {
418 let mut gates = BMP_IO_GATES
419 .get_or_init(|| parking_lot::Mutex::new(std::collections::HashMap::new()))
420 .lock();
421 if let Some(gate) = gates.get(&limit).and_then(Weak::upgrade) {
422 return gate;
423 }
424 let gate = Arc::new(BmpIoGate::new(limit));
425 gates.retain(|_, gate| gate.strong_count() > 0);
426 gates.insert(limit, Arc::downgrade(&gate));
427 log::info!("[bmp] process-wide random-I/O concurrency={limit}");
428 gate
429}
430
431#[cfg(feature = "native")]
432pub(crate) fn shared_store_cache(budget_bytes: usize) -> Arc<crate::segment::SharedStoreCache> {
433 let mut caches = STORE_CACHE_POOLS
434 .get_or_init(|| parking_lot::Mutex::new(std::collections::HashMap::new()))
435 .lock();
436 if let Some(cache) = caches.get(&budget_bytes).and_then(Weak::upgrade) {
437 return cache;
438 }
439 let cache = Arc::new(crate::segment::SharedStoreCache::new(budget_bytes));
440 caches.retain(|_, cache| cache.strong_count() > 0);
441 caches.insert(budget_bytes, Arc::downgrade(&cache));
442 log::info!(
443 "[store_cache] process-wide budget={}",
444 crate::format_bytes(budget_bytes as u64)
445 );
446 cache
447}
448
449#[cfg(feature = "sync")]
450fn shared_search_pool(num_threads: usize) -> Result<Arc<rayon::ThreadPool>> {
451 if num_threads == 0 {
452 return Err(crate::Error::Internal(
453 "IndexConfig.num_threads must be greater than zero".into(),
454 ));
455 }
456
457 let mut pools = SEARCH_CPU_POOLS
458 .get_or_init(|| parking_lot::Mutex::new(HashMap::new()))
459 .lock();
460 if let Some(pool) = pools.get(&num_threads).and_then(Weak::upgrade) {
461 return Ok(pool);
462 }
463
464 let pool = Arc::new(
468 rayon::ThreadPoolBuilder::new()
469 .num_threads(num_threads)
470 .thread_name(move |idx| format!("hermes-search-{}-{}", num_threads, idx))
471 .build()
472 .map_err(|error| {
473 crate::Error::Internal(format!(
474 "failed to create {num_threads}-thread search pool: {error}"
475 ))
476 })?,
477 );
478 pools.retain(|_, pool| pool.strong_count() > 0);
479 pools.insert(num_threads, Arc::downgrade(&pool));
480 log::info!("[search] process-wide CPU pool: {} thread(s)", num_threads);
481 Ok(pool)
482}
483
484impl Default for IndexConfig {
485 fn default() -> Self {
486 #[cfg(feature = "native")]
487 let compression_threads = crate::default_compression_threads();
488 #[cfg(not(feature = "native"))]
489 let compression_threads = 1;
490
491 #[cfg(feature = "native")]
492 let search_threads = crate::default_search_threads();
493 #[cfg(not(feature = "native"))]
494 let search_threads = 1;
495
496 Self {
497 num_threads: search_threads,
498 bmp_io_concurrency: 4,
499 num_indexing_threads: 1, num_compression_threads: compression_threads,
501 term_cache_blocks: 256,
502 #[cfg(target_pointer_width = "64")]
506 store_cache_budget_bytes: 2 * 1024 * 1024 * 1024,
507 #[cfg(not(target_pointer_width = "64"))]
508 store_cache_budget_bytes: 32 * 1024 * 1024,
509 max_indexing_memory_bytes: 256 * 1024 * 1024, vector_training_max_samples: 10_000_000,
511 #[cfg(target_pointer_width = "64")]
512 vector_training_memory_bytes: 4 * 1024 * 1024 * 1024,
513 #[cfg(not(target_pointer_width = "64"))]
514 vector_training_memory_bytes: usize::MAX,
515 merge_policy: Box::new(crate::merge::TieredMergePolicy::large_scale()),
520 optimization: crate::structures::IndexOptimization::default(),
521 reload_interval_ms: 1000, max_concurrent_merges: 4,
523 #[cfg(feature = "native")]
524 background_merge_permits: Arc::new(tokio::sync::Semaphore::new(4)),
525 merge_bp_time_budget: Some(std::time::Duration::from_secs(600)),
526 #[cfg(target_pointer_width = "64")]
535 bp_memory_budget_bytes: 24 * 1024 * 1024 * 1024,
536 #[cfg(not(target_pointer_width = "64"))]
537 bp_memory_budget_bytes: usize::MAX,
538 #[cfg(feature = "native")]
539 background_reorder_permits: Arc::new(ReorderConcurrencyGate::new(2)),
540 #[cfg(feature = "native")]
541 background_reorder_pool: None,
542 }
543 }
544}
545
546#[cfg(feature = "native")]
552fn segment_manager_from_config<D: crate::directories::DirectoryWriter + 'static>(
553 directory: &Arc<D>,
554 schema: &Arc<Schema>,
555 metadata: IndexMetadata,
556 config: &IndexConfig,
557) -> Arc<crate::merge::SegmentManager<D>> {
558 Arc::new(crate::merge::SegmentManager::new(
559 Arc::clone(directory),
560 Arc::clone(schema),
561 metadata,
562 config.merge_policy.clone_box(),
563 config.term_cache_blocks,
564 config.max_concurrent_merges,
565 Arc::clone(&config.background_merge_permits),
566 config.merge_bp_time_budget,
567 config.bp_memory_budget_bytes,
568 Arc::clone(&config.background_reorder_permits),
569 config.background_reorder_pool.clone(),
570 ))
571}
572
573#[cfg(feature = "native")]
582pub struct Index<D: crate::directories::DirectoryWriter + 'static> {
583 directory: Arc<D>,
584 config: IndexConfig,
585 search_resources: searcher::SearcherResources,
587 segment_manager: Arc<crate::merge::SegmentManager<D>>,
589 cached_reader: tokio::sync::OnceCell<IndexReader<D>>,
591}
592
593#[cfg(feature = "native")]
594impl<D: crate::directories::DirectoryWriter + 'static> Index<D> {
595 pub async fn create(directory: D, schema: Schema, config: IndexConfig) -> Result<Self> {
597 let search_resources = searcher::SearcherResources::new(
598 config.term_cache_blocks,
599 config.store_cache_budget_bytes,
600 config.num_threads,
601 config.bmp_io_concurrency,
602 )?;
603 let directory = Arc::new(directory);
604 let schema = Arc::new(schema);
605 directory.set_index_label(schema.index_label());
607
608 if directory
612 .exists(std::path::Path::new(INDEX_META_FILENAME))
613 .await?
614 {
615 return Err(crate::Error::Internal(format!(
616 "refusing to create index: {} already exists in this directory; \
617 use Index::open to open the existing index, or delete the \
618 directory first if you really want to start over",
619 INDEX_META_FILENAME
620 )));
621 }
622
623 let metadata = IndexMetadata::new((*schema).clone());
624
625 let segment_manager = segment_manager_from_config(&directory, &schema, metadata, &config);
626
627 segment_manager.update_metadata(|_| {}).await?;
629
630 Ok(Self {
631 directory,
632 config,
633 search_resources,
634 segment_manager,
635 cached_reader: tokio::sync::OnceCell::new(),
636 })
637 }
638
639 pub async fn open(directory: D, config: IndexConfig) -> Result<Self> {
641 let search_resources = searcher::SearcherResources::new(
642 config.term_cache_blocks,
643 config.store_cache_budget_bytes,
644 config.num_threads,
645 config.bmp_io_concurrency,
646 )?;
647 let directory = Arc::new(directory);
648
649 let metadata = IndexMetadata::load(directory.as_ref()).await?;
651 let schema = Arc::new(metadata.schema.clone());
652 directory.set_index_label(schema.index_label());
654
655 let segment_manager = segment_manager_from_config(&directory, &schema, metadata, &config);
656
657 segment_manager.try_load_and_publish_trained().await?;
659
660 Ok(Self {
661 directory,
662 config,
663 search_resources,
664 segment_manager,
665 cached_reader: tokio::sync::OnceCell::new(),
666 })
667 }
668
669 pub fn schema(&self) -> Arc<Schema> {
671 self.schema_arc()
672 }
673
674 pub fn schema_arc(&self) -> Arc<Schema> {
676 self.segment_manager.published_generation().schema.clone()
677 }
678
679 pub fn directory(&self) -> &D {
681 &self.directory
682 }
683
684 pub fn segment_manager(&self) -> &Arc<crate::merge::SegmentManager<D>> {
686 &self.segment_manager
687 }
688
689 pub async fn reader(&self) -> Result<&IndexReader<D>> {
694 self.cached_reader
695 .get_or_try_init(|| async {
696 IndexReader::from_segment_manager_with_resources(
697 self.schema_arc(),
698 Arc::clone(&self.segment_manager),
699 self.config.reload_interval_ms,
700 self.search_resources.clone(),
701 )
702 .await
703 })
704 .await
705 }
706
707 pub fn config(&self) -> &IndexConfig {
709 &self.config
710 }
711
712 pub async fn segment_readers(&self) -> Result<Vec<Arc<crate::segment::SegmentReader>>> {
714 let reader = self.reader().await?;
715 let searcher = reader.searcher().await?;
716 Ok(searcher.segment_readers().to_vec())
717 }
718
719 pub async fn num_docs(&self) -> Result<u32> {
721 let reader = self.reader().await?;
722 let searcher = reader.searcher().await?;
723 Ok(searcher.num_docs())
724 }
725
726 pub fn default_fields(&self) -> Vec<crate::Field> {
728 let schema = self.schema_arc();
729 if !schema.default_fields().is_empty() {
730 schema.default_fields().to_vec()
731 } else {
732 schema
733 .fields()
734 .filter(|(_, entry)| {
735 entry.indexed && entry.field_type == crate::dsl::FieldType::Text
736 })
737 .map(|(field, _)| field)
738 .collect()
739 }
740 }
741
742 pub fn tokenizers(&self) -> Arc<crate::tokenizer::TokenizerRegistry> {
744 Arc::new(crate::tokenizer::TokenizerRegistry::default())
745 }
746
747 pub fn query_parser(&self) -> crate::dsl::QueryLanguageParser {
749 let default_fields = self.default_fields();
750 let tokenizers = self.tokenizers();
751 let schema = self.schema_arc();
752
753 let query_routers = schema.query_routers();
754 if !query_routers.is_empty()
755 && let Ok(router) = crate::dsl::QueryFieldRouter::from_rules(query_routers)
756 {
757 return crate::dsl::QueryLanguageParser::with_router(
758 Arc::clone(&schema),
759 default_fields,
760 tokenizers,
761 router,
762 );
763 }
764
765 crate::dsl::QueryLanguageParser::new(schema, default_fields, tokenizers)
766 }
767
768 pub async fn query(
770 &self,
771 query_str: &str,
772 limit: usize,
773 ) -> Result<crate::query::SearchResponse> {
774 self.query_offset(query_str, limit, 0).await
775 }
776
777 pub async fn query_offset(
779 &self,
780 query_str: &str,
781 limit: usize,
782 offset: usize,
783 ) -> Result<crate::query::SearchResponse> {
784 let parser = self.query_parser();
785 let query = parser
786 .parse(query_str)
787 .map_err(crate::error::Error::Query)?;
788 self.search_offset(query.as_ref(), limit, offset).await
789 }
790
791 pub async fn search(
793 &self,
794 query: &dyn crate::query::Query,
795 limit: usize,
796 ) -> Result<crate::query::SearchResponse> {
797 self.search_offset(query, limit, 0).await
798 }
799
800 pub async fn search_offset(
802 &self,
803 query: &dyn crate::query::Query,
804 limit: usize,
805 offset: usize,
806 ) -> Result<crate::query::SearchResponse> {
807 let reader = self.reader().await?;
808 let searcher = reader.searcher().await?;
809
810 #[cfg(feature = "sync")]
811 let (results, total_seen) = {
812 let runtime_flavor = tokio::runtime::Handle::current().runtime_flavor();
816 if runtime_flavor == tokio::runtime::RuntimeFlavor::MultiThread {
817 tokio::task::block_in_place(|| {
818 searcher.search_with_offset_and_count_sync(query, limit, offset)
819 })?
820 } else {
821 searcher.search_with_offset_and_count_sync(query, limit, offset)?
822 }
823 };
824
825 #[cfg(not(feature = "sync"))]
826 let (results, total_seen) = {
827 searcher
828 .search_with_offset_and_count(query, limit, offset)
829 .await?
830 };
831
832 let total_hits = total_seen;
833 let hits: Vec<crate::query::SearchHit> = results
834 .into_iter()
835 .map(|result| crate::query::SearchHit {
836 address: crate::query::DocAddress::new(result.segment_id, result.doc_id),
837 score: result.score,
838 matched_fields: result.extract_ordinals(),
839 })
840 .collect();
841
842 Ok(crate::query::SearchResponse { hits, total_hits })
843 }
844
845 pub async fn get_document(
847 &self,
848 address: &crate::query::DocAddress,
849 ) -> Result<Option<crate::dsl::Document>> {
850 let reader = self.reader().await?;
851 let searcher = reader.searcher().await?;
852 searcher.get_document(address).await
853 }
854
855 pub async fn get_postings(
857 &self,
858 field: crate::Field,
859 term: &[u8],
860 ) -> Result<
861 Vec<(
862 Arc<crate::segment::SegmentReader>,
863 crate::structures::BlockPostingList,
864 )>,
865 > {
866 let segments = self.segment_readers().await?;
867 let mut results = Vec::new();
868
869 for segment in segments {
870 if let Some(postings) = segment.get_postings(field, term).await? {
871 results.push((segment, postings));
872 }
873 }
874
875 Ok(results)
876 }
877}
878
879#[cfg(feature = "native")]
881impl<D: crate::directories::DirectoryWriter + 'static> Index<D> {
882 pub fn writer(&self) -> writer::IndexWriter<D> {
884 writer::IndexWriter::from_index(self)
885 }
886}
887
888#[cfg(test)]
889mod tests;
890
891