Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide StoreReader::enumerate to simplify creation of secondary indexes #2361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 23, 2024

  1. Provide StoreReader::enumerate to simplify creation of secondary indexes

    For secondary indexes, it is often necessary to read all documents, compute
    some function on them and associated the result with a document ID.
    
    Currently, this requires something like
    
    ```rust
    let reader = segment.get_store_reader(1)?;
    
    for doc_id in segment.doc_ids_alive() {
        let doc = reader.get(doc_id)?;
    
        // Use doc and doc_id here ...
    }
    ```
    
    which can be simplified to
    
    ```rust
    let reader = segment.get_store_reader(1)?;
    
    for res in reader.enumerate() {
        let (doc_id, doc) = res?;
    
        // Use doc and doc_id here ...
    }
    ```
    
    using the method proposed here.
    
    (I added a new method instead of modifying `StoreReader::iter` to make the
    change backwards compatible, i.e. possible to include in a point release.)
    adamreichold committed May 23, 2024
    Configuration menu
    Copy the full SHA
    083aec5 View commit details
    Browse the repository at this point in the history