apache / apache/lucene

Immutable Suggester impls. should be immutable [LUCENE-4492]

Open
#5,558 2 comments 0 reactions 0 assignees View on GitHub
affects-version:3.6.1 affects-version:4.0 affects-version:4.1 legacy-jira-fix-version:4.9 legacy-jira-fix-version:6.0 legacy-jira-priority:Major type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Currently we have a very clumsy interface to build and load the Suggesters that are immutable. All our FST impls must be somewhat pre-build and then loaded. But currently the code doesn't declare the fst member as final and lets you change it at any time. ie you can always call load / build. This makes safe publication tricky and required custom code to make this reasonable. Ie. you have as suggester that can reload it's dict every 20 min. Now if you want to swap this in once loaded you can create a new Lookup instance and assign it to a member in your app. Yet this member needs to be volatile otherwise threads won't fetch all the memory and you can run into NPE exceptions since the fst member is not final. I'd not want to pay the price for this volatile read in a suggest env since its really read-only.

---
Migrated from [LUCENE-4492](https://issues.apache.org/jira/browse/LUCENE-4492) by Simon Willnauer (@s1monw), updated May 09 2016

Contributor guide

Open the contributing guide

Research direction

Start by locating the FST-based Suggester implementations and their load/build entry points. Review how the FST member is initialized and reassigned across those implementations, then verify that the implementations are immutable after construction and that existing suggestion-loading behavior remains covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.