feat(whoosh): implement skip list for document lookup#129
Open
Predd0o wants to merge 4 commits intoSygil-Dev:mainfrom
Open
feat(whoosh): implement skip list for document lookup#129Predd0o wants to merge 4 commits intoSygil-Dev:mainfrom
Predd0o wants to merge 4 commits intoSygil-Dev:mainfrom
Conversation
Co-authored-by: Matheus Virgolino <matheus.virgolino.abilio.da.silva@ccc.ufcg.edu.br> Co-authored-by: Manoel Netto <manoel.da.nobrega.eustaqueo.netto@ccc.ufcg.edu.br> Co-authored-by: Pedro <pedroalmeida1896@gmail.com> Co-authored-by: Lucaslg7 <lucasmoizinholg7@gmail.com> Co-authored-by: RailtonDantas <railtondantas.code@gmail.com> Co-authored-by: João Pereira <joao.pereira.de.oliveira@ccc.ufcg.edu.br>
Co-authored-by: Matheus Virgolino <matheus.virgolino.abilio.da.silva@ccc.ufcg.edu.br> Co-authored-by: Manoel Netto <manoel.da.nobrega.eustaqueo.netto@ccc.ufcg.edu.br> Co-authored-by: Pedro <pedroalmeida1896@gmail.com> Co-authored-by: Lucaslg7 <lucasmoizinholg7@gmail.com> Co-authored-by: RailtonDantas <railtondantas.code@gmail.com> Co-authored-by: João Pereira <joao.pereira.de.oliveira@ccc.ufcg.edu.br>
f3c6934 to
b34f6ad
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




O que foi feito
O método
skip_to()atual doListMatcherusa uma varredura linearpara avançar nas posting lists (O(n)), o que se torna custoso em
consultas AND onde o
skip_to()é chamado repetidamente.Esta mudança introduz uma Skip List em um novo arquivo
skiplist.pycom duas classes:
SkipNode: representa um nó armazenando o ID do documento e ponteirosforward para cada nível. Usa
__slots__para minimizar uso de memória.SkipList: constrói todos os níveis em uma única passagem O(n) eimplementa o
skip_to()em O(log n) descendo dos níveis mais altos.Uma nova classe
SkipListMatcherherda doListMatchere sobrescreveapenas o
skip_to(), usando aSkipListpara localizar o doc_id alvoem O(log n) e
bisect_leftpara encontrar o índice correspondente.Todos os outros métodos (next, id, weight, score, all_ids, etc.)
permanecem inalterados.
IntersectionMatcher._find_next()não precisou de alterações — aosubstituir
SkipListMatcherno lugar deListMatcher, a otimizaçãoé propagada automaticamente. Consultas AND sobre duas listas de N
documentos passam de O(n) para O(k log n), onde k é o número de
resultados.
Como testar
Rodar a suite de testes existente para verificar que nada foi quebrado:
pip install -e . pytestIssue relacionada
Closes matheusvir/eda-oss-performance#19