You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2025/03/17 03:33:29 UTC

[PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

dsmiley opened a new pull request, #3271:
URL: https://github.com/apache/solr/pull/3271

   https://issues.apache.org/jira/browse/SOLR-17706
   
   Remove from SolrClient, and thus update QueryResponse to not get it from there.
   Use Java SPI/ServiceLoader to allow someone to customize.
   Use ConcurrentHashMap.computeIfAbsent internally.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3271:
URL: https://github.com/apache/solr/pull/3271#issuecomment-2741495709

   I think the plug-ability need is advanced/expert and thus I think the testing level can be commensurate with that (nothing automated).  There is no test for its current level of plug-ability!
   
   The implementation I added will initialize to a static final, which makes it hard to test.  But it excels in brevity/simplicity :-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3271:
URL: https://github.com/apache/solr/pull/3271#discussion_r1999323063


##########
solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java:
##########
@@ -147,7 +147,7 @@ private void testJoins(String toColl, String fromColl, String toDocId, boolean i
               + fromQ;
       QueryRequest qr =
           new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
-      QueryResponse rsp = new QueryResponse(client.request(qr), client);
+      QueryResponse rsp = qr.process(client);

Review Comment:
   cool; in this and similar cases, I was just using SolrJ idiomatically irrespective of this PR's objective.  Given a request, if you want it's typed response, you use the `process` method.  That's the *right* way to do it.



##########
solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java:
##########
@@ -102,21 +101,10 @@ public class QueryResponse extends SolrResponseBase {
   private Map<String, Object> _debugMap = null;
   private Map<String, Object> _explainMap = null;
 
-  // utility variable used for automatic binding -- it should not be serialized
-  private final transient SolrClient solrClient;
+  public QueryResponse() {}
 
-  public QueryResponse() {
-    solrClient = null;
-  }
-
-  /** Utility constructor to set the solrServer and namedList */
-  public QueryResponse(NamedList<Object> res, SolrClient solrClient) {
+  public QueryResponse(NamedList<Object> res) {

Review Comment:
   Users shouldn't be using this constructor; it's for SolrJ internals.



##########
solr/CHANGES.txt:
##########
@@ -160,6 +160,9 @@ Other Changes
   thus BinaryQueryResponseWriter is gone.  Added TextQueryResponseWriter for the text ones.
   Stopped using RawResponseWriter when not needed.  (David Smiley)
 
+* SOLR-17706: SolrJ DocumentObjectBinder is now a global singleton via an INSTANCE field and that

Review Comment:
   I will test it manually before merging



##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java:
##########
@@ -62,7 +62,7 @@ public String getPath() {
 
   @Override
   protected QueryResponse createResponse(SolrClient client) {
-    return new QueryResponse(client);
+    return new QueryResponse();

Review Comment:
   No.  Only one place in Solr does it use it, aside from this spot.  So *not* using it is in fact the norm.  IMO it shouldn't even be on the `createResponse` API contract in the first place.  My other PR created yesterday makes that change.



##########
solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java:
##########
@@ -126,18 +136,12 @@ private void addChild(Object obj, DocField field, SolrInputDocument doc) {
   }
 
   private List<DocField> getDocFields(Class<?> clazz) {

Review Comment:
   Yeah I "had" to make this change; was begging for it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #3271:
URL: https://github.com/apache/solr/pull/3271#issuecomment-2741313792

   Is there any way to have an automated test for the SPI/client-customization scenario?  Relying on manual testing there feels a little brittle, since it could break two commits down the road and we'd never notice.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3271:
URL: https://github.com/apache/solr/pull/3271#issuecomment-2741212642

   I plan to merge this weekend, notwithstanding the possibility of more feedback.  And I'll do the plug ability test manually.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3271:
URL: https://github.com/apache/solr/pull/3271#issuecomment-2728002420

   Admittedly I didn't actually try the SPI to see if it works, or to try to see if DOM is sufficiently subclass-able.  My motivation today is to detatch it from a SolrClient instance (no longer be a field).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3271:
URL: https://github.com/apache/solr/pull/3271#discussion_r1998680285


##########
solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java:
##########
@@ -147,7 +147,7 @@ private void testJoins(String toColl, String fromColl, String toDocId, boolean i
               + fromQ;
       QueryRequest qr =
           new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
-      QueryResponse rsp = new QueryResponse(client.request(qr), client);
+      QueryResponse rsp = qr.process(client);

Review Comment:
   I love all these changes, much clearer....



##########
solr/CHANGES.txt:
##########
@@ -160,6 +160,9 @@ Other Changes
   thus BinaryQueryResponseWriter is gone.  Added TextQueryResponseWriter for the text ones.
   Stopped using RawResponseWriter when not needed.  (David Smiley)
 
+* SOLR-17706: SolrJ DocumentObjectBinder is now a global singleton via an INSTANCE field and that

Review Comment:
   "and is pluggable".   Out of curisotiy, do you want to say it is pluggable if it hasn't been tested?



##########
solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java:
##########
@@ -41,13 +42,22 @@
 import org.apache.solr.common.util.SuppressForbidden;
 
 /**
- * A class to map objects to and from solr documents.
+ * Maps objects to and from Solr documents.

Review Comment:
   nice!



##########
solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java:
##########
@@ -643,9 +631,7 @@ public List<FacetField> getLimitingFacets() {
   }
 
   public <T> List<T> getBeans(Class<T> type) {
-    return solrClient == null
-        ? new DocumentObjectBinder().getBeans(type, _results)
-        : solrClient.getBinder().getBeans(type, _results);
+    return DocumentObjectBinder.INSTANCE.getBeans(type, _results);

Review Comment:
   much nicer!  Love there isn't two ways to get it...



##########
solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java:
##########
@@ -102,21 +101,10 @@ public class QueryResponse extends SolrResponseBase {
   private Map<String, Object> _debugMap = null;
   private Map<String, Object> _explainMap = null;
 
-  // utility variable used for automatic binding -- it should not be serialized
-  private final transient SolrClient solrClient;
+  public QueryResponse() {}
 
-  public QueryResponse() {
-    solrClient = null;
-  }
-
-  /** Utility constructor to set the solrServer and namedList */
-  public QueryResponse(NamedList<Object> res, SolrClient solrClient) {
+  public QueryResponse(NamedList<Object> res) {

Review Comment:
   I love this, but also, does this need to be deprecated and or flagged?  Seems like a big method chagne?



##########
solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java:
##########
@@ -126,18 +136,12 @@ private void addChild(Object obj, DocField field, SolrInputDocument doc) {
   }
 
   private List<DocField> getDocFields(Class<?> clazz) {

Review Comment:
   much shorter, and actually is easier to read...



##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java:
##########
@@ -62,7 +62,7 @@ public String getPath() {
 
   @Override
   protected QueryResponse createResponse(SolrClient client) {
-    return new QueryResponse(client);
+    return new QueryResponse();

Review Comment:
   does the fact that this takes in a `client` but does not use it need to be documented?  Just reading it, I would think "thats weried"..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley merged PR #3271:
URL: https://github.com/apache/solr/pull/3271


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17706 SolrJ DocumentObjectBinder, make a singleton [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3271:
URL: https://github.com/apache/solr/pull/3271#discussion_r2008675158


##########
solr/CHANGES.txt:
##########
@@ -160,6 +160,9 @@ Other Changes
   thus BinaryQueryResponseWriter is gone.  Added TextQueryResponseWriter for the text ones.
   Stopped using RawResponseWriter when not needed.  (David Smiley)
 
+* SOLR-17706: SolrJ DocumentObjectBinder is now a global singleton via an INSTANCE field and that

Review Comment:
   I tested it; works fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org