apache / apache/lucene

Add reusability to FacetFields [LUCENE-4680]

Open
#5,745 0 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major module:facet type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

In #5712 I added a TODO to handle resubility to this class. Currently it allocates two new TokenStreams for every document, as well as some BytesRefs and an IntsRef. I think it should be possible to reuses those across documents (and also the Field instances, while we're at it).

It will make the class not thread-safe, but I don't think that's an important feature. `CategoryDocumentBuilder` (its predecessor) wasn't thread-safe either, and `Field` isn't thread safe, so it's fine by me if `FacetFields` isn't thread safe too.

---
Migrated from [LUCENE-4680](https://issues.apache.org/jira/browse/LUCENE-4680) by Shai Erera (@shaie)

Contributor guide

Open the contributing guide

Research direction

Start by locating FacetFields and compare it with its predecessor, CategoryDocumentBuilder. Inspect the per-document allocation of TokenStreams, BytesRefs, IntsRef, and Field instances, then verify that reuse works across documents without introducing thread-safety assumptions; completion should be validated with the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, search
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.