You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2026/08/18 21:08:21 UTC
(couchdb) 05/05: cache PointsConfig
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-fixes
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit addb17482ba7ea67575357f37a84f984ed4c4f13
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Aug 18 20:30:11 2026 +0100
cache PointsConfig
---
.../org/apache/couchdb/nouveau/lucene/LuceneIndexSchema.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene/LuceneIndexSchema.java b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene/LuceneIndexSchema.java
index bf4351292..b453591ed 100644
--- a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene/LuceneIndexSchema.java
+++ b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene/LuceneIndexSchema.java
@@ -56,6 +56,8 @@ final class LuceneIndexSchema {
private final ConcurrentMap<String, Type> map;
+ private final ConcurrentMap<Locale, Map<String, PointsConfig>> pointsConfigCache = new ConcurrentHashMap<>();
+
private LuceneIndexSchema(Map<String, Type> map) {
this.map = new ConcurrentHashMap<>(map);
this.map.put("_id", Type.STRING);
@@ -78,7 +80,11 @@ final class LuceneIndexSchema {
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 @@ final class LuceneIndexSchema {
}
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);