Re: svn commit: r1056612 - in /lucene/dev/trunk/solr/src/java/org/apache/solr: handler/ handler/component/ request/ search/

2011-01-08 Thread Robert Muir
On Fri, Jan 7, 2011 at 10:47 PM,  hoss...@apache.org wrote:

 +  public static final SetString EMPTY_STRING_SET = Collections.emptySet();
 +

I don't know about this commit... i see a lot of EMPTY set's and maps
defined statically here.
There is no advantage to doing this, even the javadocs explain:
Implementation note: Implementations of this method need not create a
separate (Set|Map|List) object for each call. Using this method is
likely to have comparable cost to using the like-named field. (Unlike
this method, the field does not provide type safety.)

I think we should be using the Collection methods, for example on your
first file:

Index: solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
===
--- solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java   
(revision
1056691)
+++ solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java   
(working
copy)
@@ -47,8 +47,6 @@
  */
 public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {

-  public static final SetString EMPTY_STRING_SET = Collections.emptySet();
-
   public void handleRequestBody(SolrQueryRequest req,
SolrQueryResponse rsp) throws Exception {
 rsp.add(analysis, doAnalysis(req));
   }
@@ -343,7 +341,7 @@
  *
  */
 public AnalysisContext(String fieldName, FieldType fieldType,
Analyzer analyzer) {
-  this(fieldName, fieldType, analyzer, EMPTY_STRING_SET);
+  this(fieldName, fieldType, analyzer, Collections.StringemptySet());
 }

 /**
I

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



Re: svn commit: r1056612 - in /lucene/dev/trunk/solr/src/java/org/apache/solr: handler/ handler/component/ request/ search/

2011-01-08 Thread Chris Hostetter

:  +  public static final SetString EMPTY_STRING_SET = 
Collections.emptySet();
:  +
: 
: I don't know about this commit... i see a lot of EMPTY set's and maps
: defined statically here.
...
: I think we should be using the Collection methods, for example on your
: first file:

Hmmm... i am using the Collections method, it's the same set/map in each 
case, i'm just creating static ref's to them with the type information.  

My reading of the javadocs was that the implementation of emptySet() was 
going to just return the same immutable instance every time anyway, so 
there didn't seem to be any functional diff in reusing it like this -- it 
seemed like the natureal way to migrate from using Collections.EMPTY_SET,  
use our own local ref of the same object w/type info.

: -  this(fieldName, fieldType, analyzer, EMPTY_STRING_SET);
: +  this(fieldName, fieldType, analyzer, Collections.StringemptySet());

Ah... see, i didn't even know that syntax was valid to bind the generic on 
a static method.  I'd only ever done the binding in the assignmet.  

yeah, sure -- i'll make a note to myself to go back and clean those up.

-Hoss

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org