Skip to content

Commit

Permalink
using single instance of empty SingleOrderedMap
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoh committed Jan 4, 2025
1 parent d4fc020 commit ff25f8b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions solr/core/src/java/org/apache/solr/request/SimpleFacets.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,12 @@ public void execute(Runnable r) {
* @see #getFieldMissingCount
* @see #getFacetTermEnumCounts
*/
public NamedList<Object> getFacetFieldCounts() throws IOException, SyntaxError {
public SimpleOrderedMap<Object> getFacetFieldCounts() throws IOException, SyntaxError {

String[] facetFs = global.getParams(FacetParams.FACET_FIELD);

if (null == facetFs) {
return NamedList.emptyNamedList();
return SimpleOrderedMap.emptySimpleOrderedMap();
}

// Passing a negative number for FACET_THREADS implies an unlimited number of threads is
Expand All @@ -891,7 +891,7 @@ public NamedList<Object> getFacetFieldCounts() throws IOException, SyntaxError {
fdebugParent.putInfoItem("maxThreads", maxThreads);
}

NamedList<Object> res;
SimpleOrderedMap<Object> res;
try {
// Loop over fields; submit to executor, keeping the future
for (String f : facetFs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
public class NamedList<T>
implements Cloneable, Serializable, Iterable<Map.Entry<String, T>>, MapWriter, SimpleMap<T> {

private static final NamedList<Object> emptyNamedList = new NamedList(0);
private static final long serialVersionUID = 1957981902839867821L;
protected final List<Object> nvPairs;

Expand Down Expand Up @@ -862,8 +861,4 @@ public int _size() {
public void forEachEntry(BiConsumer<String, ? super T> fun) {
forEach(fun);
}

public static NamedList<Object> emptyNamedList() {
return emptyNamedList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* serialized. It aims to minimize overhead and to be efficient at adding new elements.
*/
public class SimpleOrderedMap<T> extends NamedList<T> {

private static final SimpleOrderedMap<Object> emptySimpleOrderedMap = new SimpleOrderedMap<>(0);
/** Creates an empty instance */
public SimpleOrderedMap() {
super();
Expand Down Expand Up @@ -67,4 +69,8 @@ public SimpleOrderedMap<T> clone() {
newList.addAll(nvPairs);
return new SimpleOrderedMap<>(newList);
}

public static SimpleOrderedMap<Object> emptySimpleOrderedMap() {
return emptySimpleOrderedMap;
}
}

0 comments on commit ff25f8b

Please sign in to comment.