-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Nouveau fixes #6096
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
base: main
Are you sure you want to change the base?
Nouveau fixes #6096
Changes from all commits
ef66d3b
a6128de
a253aa0
272a447
addb174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,8 @@ private static Type fromField(final Field field) { | |
|
|
||
| private final ConcurrentMap<String, Type> map; | ||
|
|
||
| private final ConcurrentMap<Locale, Map<String, PointsConfig>> pointsConfigCache = new ConcurrentHashMap<>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is caching a locale => number format instances to share between client calls? Since it seem to be shared I checked https://lucene.apache.org/core/10_5_0/queryparser/org/apache/lucene/queryparser/flexible/standard/config/PointsConfig.html and it doesn't mention any synchronization safety but the number format warns about using them in different threads https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/NumberFormat.html#synchronization maybe it need a lock or if you looked and think it's fine it's ok. I am just going by superficial impressions and docs |
||
|
|
||
| private LuceneIndexSchema(Map<String, Type> map) { | ||
| this.map = new ConcurrentHashMap<>(map); | ||
| this.map.put("_id", Type.STRING); | ||
|
|
@@ -78,7 +80,11 @@ public static LuceneIndexSchema fromString(final String schemaStr) { | |
| public void update(final Collection<Field> fields) { | ||
| Objects.requireNonNull(fields); | ||
| for (var field : fields) { | ||
| map.putIfAbsent(field.name(), Type.fromField(field)); | ||
| var type = Type.fromField(field); | ||
| var result = map.putIfAbsent(field.name(), type); | ||
| if (result == null && type == Type.DOUBLE) { | ||
| pointsConfigCache.clear(); | ||
| } | ||
| assertType(field); | ||
| } | ||
| } | ||
|
|
@@ -102,6 +108,10 @@ public void assertType(final Field field) { | |
| } | ||
|
|
||
| public Map<String, PointsConfig> toPointsConfigMap(final Locale locale) { | ||
| return pointsConfigCache.computeIfAbsent(locale, l -> buildPointsConfigMap(l)); | ||
| } | ||
|
|
||
| private Map<String, PointsConfig> buildPointsConfigMap(final Locale locale) { | ||
| Objects.requireNonNull(locale); | ||
| var numberFormat = NumberFormat.getInstance(locale); | ||
| var doublePointsConfig = new PointsConfig(numberFormat, Double.class); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems racy if say after an update? A first search call triggers getAndSet(false) but then a concurrent, second search won't block anymore even if the first one hadn't finished updating?