Permalink
Browse files

merged from branch cleanup

  • Loading branch information...
2 parents 2abfef8 + 7955e26 commit f3c4b4bcd8a811f339bc5b7258b24e0953777a3c @javasoze javasoze committed May 8, 2010
Showing with 2,344 additions and 106 deletions.
  1. +71 −0 bobo-browse/src/com/browseengine/bobo/analysis/section/IntMetaDataTokenStream.java
  2. +70 −0 bobo-browse/src/com/browseengine/bobo/analysis/section/SectionTokenStream.java
  3. +20 −2 bobo-browse/src/com/browseengine/bobo/api/BrowseFacet.java
  4. +49 −1 bobo-browse/src/com/browseengine/bobo/api/BrowseHit.java
  5. +0 −88 bobo-browse/src/com/browseengine/bobo/fields/FieldRegistry.java
  6. +52 −0 bobo-browse/src/com/browseengine/bobo/search/section/AbstractTerminalNode.java
  7. +94 −0 bobo-browse/src/com/browseengine/bobo/search/section/AndNode.java
  8. +57 −0 bobo-browse/src/com/browseengine/bobo/search/section/AndNotNode.java
  9. +215 −0 bobo-browse/src/com/browseengine/bobo/search/section/IntMetaDataCache.java
  10. +238 −0 bobo-browse/src/com/browseengine/bobo/search/section/IntMetaDataQuery.java
  11. +12 −0 bobo-browse/src/com/browseengine/bobo/search/section/MetaDataCache.java
  12. +14 −0 bobo-browse/src/com/browseengine/bobo/search/section/MetaDataCacheProvider.java
  13. +30 −0 bobo-browse/src/com/browseengine/bobo/search/section/MetaDataQuery.java
  14. +103 −0 bobo-browse/src/com/browseengine/bobo/search/section/OrNode.java
  15. +91 −0 bobo-browse/src/com/browseengine/bobo/search/section/PhraseNode.java
  16. +177 −0 bobo-browse/src/com/browseengine/bobo/search/section/SectionSearchQuery.java
  17. +78 −0 bobo-browse/src/com/browseengine/bobo/search/section/SectionSearchQueryPlan.java
  18. +220 −0 bobo-browse/src/com/browseengine/bobo/search/section/SectionSearchQueryPlanBuilder.java
  19. +104 −0 bobo-browse/src/com/browseengine/bobo/search/section/TermNode.java
  20. +38 −0 bobo-browse/src/com/browseengine/bobo/search/section/UnaryNotNode.java
  21. +2 −2 bobo-browse/src/com/browseengine/bobo/sort/SortCollector.java
  22. +4 −1 bobo-browse/src/com/browseengine/bobo/sort/SortCollectorImpl.java
  23. +1 −1 bobo-gwt/src/com/browseengine/bobo/svc/impl/BoboSearchServiceImpl.java
  24. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/serialize/JSONExternalizable.java
  25. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/serialize/JSONSerializable.java
  26. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/serialize/JSONSerializer.java
  27. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BoboHttpRequestParam.java
  28. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BoboParams.java
  29. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BoboQueryBuilder.java
  30. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BoboRequestBuilder.java
  31. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BrowseJSONHandler.java
  32. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/BrowseJSONSerializer.java
  33. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/JOSSHandler.java
  34. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/JSONHandler.java
  35. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/server/protocol/ProtocolHandler.java
  36. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/service/BrowseHitConverter.java
  37. 0 {bobo-browse → bobo-service}/src/com/browseengine/bobo/service/BrowseResultConverter.java
  38. +1 −1 ...rowseengine/bobo → bobo-service/src/com/browseengine/bobo/service}/util/BoboJSONStreamDriver.java
  39. +1 −1 ...rowseengine/bobo → bobo-service/src/com/browseengine/bobo/service}/util/BoboJSONStreamWriter.java
  40. +1 −1 ...om/browseengine/bobo → bobo-service/src/com/browseengine/bobo/service}/util/XStreamDispenser.java
  41. +1 −1 {bobo-browse → bobo-service}/src/com/browseengine/bobo/servlet/BoboAppController.java
  42. +1 −1 {bobo-browse → bobo-service}/src/com/browseengine/bobo/servlet/BrowseServlet.java
  43. +274 −0 bobo-service/src/com/browseengine/bobo/zoie/UIDFacetHandler.java
  44. +1 −1 bobo-solr/src/com/browseengine/solr/BoboXMLResponseWriter.java
  45. +1 −1 bobo-solr/src/com/browseengine/solr/DispatchUtil.java
  46. +2 −2 ivy.xml
  47. +47 −2 test/src/com/browseengine/bobo/test/BoboTestCase.java
  48. +3 −0 test/src/com/browseengine/bobo/test/UnitTestSuite.java
  49. +271 −0 test/src/com/browseengine/bobo/test/section/TestSectionSearch.java
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package com.browseengine.bobo.analysis.section;
+
+import java.io.IOException;
+
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.index.Payload;
+
+/**
+ * TokenStream for the section meta data. This returns a single token with a payload.
+ */
+public class IntMetaDataTokenStream extends TokenStream
+{
+ private final String _tokenText;
+ private final TermAttribute _termAttribute;
+ private final OffsetAttribute _offsetAttribute;
+ private final PayloadAttribute _payloadAtt;
+ private Payload _payload;
+ private boolean _returnToken = false;
+
+ public IntMetaDataTokenStream(String tokenText)
+ {
+ _tokenText = tokenText;
+ _termAttribute = (TermAttribute)addAttribute(TermAttribute.class);
+ _offsetAttribute = (OffsetAttribute)addAttribute(OffsetAttribute.class);
+ _payloadAtt = (PayloadAttribute)addAttribute(PayloadAttribute.class);
+ }
+
+ /**
+ * sets meta data
+ * @param data array of integer metadata indexed by section id
+ */
+ public void setMetaData(int[] data)
+ {
+ byte[] buf = new byte[data.length * 4];
+ int i = 0;
+
+ for(int j = 0; j < data.length; j++)
+ {
+ int datum = data[j];
+ buf[i++] = (byte)(datum);
+ buf[i++] = (byte)(datum >>> 8);
+ buf[i++] = (byte)(datum >>> 16);
+ buf[i++] = (byte)(datum >>> 24);
+ }
+
+ _payload = new Payload(buf);
+ _returnToken = true;
+ }
+
+ /**
+ * Return the single token created.
+ */
+ public boolean incrementToken() throws IOException
+ {
+ if(_returnToken)
+ {
+ _termAttribute.setTermBuffer(_tokenText);
+ _offsetAttribute.setOffset(0, 0);
+ _payloadAtt.setPayload(_payload);
+ _returnToken = false;
+ return true;
+ }
+ return false;
+ }
+}
@@ -0,0 +1,70 @@
+/**
+ *
+ */
+package com.browseengine.bobo.analysis.section;
+
+import java.io.IOException;
+
+import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.index.Payload;
+
+/**
+ * This class augments a token stream by attaching a section id as payloads.
+ *
+ */
+public class SectionTokenStream extends TokenFilter
+{
+ private Payload _payload;
+ private PayloadAttribute _payloadAtt;
+
+ public SectionTokenStream(TokenStream tokenStream, int sectionId)
+ {
+ super(tokenStream);
+ _payloadAtt = (PayloadAttribute)addAttribute(PayloadAttribute.class);
+ _payload = encodeIntPayload(sectionId);
+ }
+
+ public boolean incrementToken() throws IOException
+ {
+ if(input.incrementToken())
+ {
+ _payloadAtt.setPayload(_payload);
+ return true;
+ }
+ return false;
+ }
+
+ static public Payload encodeIntPayload(int id)
+ {
+ byte[] data = new byte[4];
+ int off = data.length;
+
+ do
+ {
+ data[--off] = (byte)(id);
+ id >>>= 8;
+ }
+ while(id > 0);
+
+ return new Payload(data, off, data.length - off);
+ }
+
+ static public int decodeIntPayload(Payload payload)
+ {
+ return decodeIntPayload(payload.getData(), payload.getOffset(), payload.length());
+ }
+
+ static public int decodeIntPayload(byte[] data, int off, int len)
+ {
+ int endOff = off + len;
+ int val = 0;
+ while(off < endOff)
+ {
+ val <<= 8;
+ val += (data[off++] & 0xFF);
+ }
+ return val;
+ }
+}
@@ -44,7 +44,7 @@ public void setValue(String value){
/**
* Gets the hit count
* @return hit count
- * @see #setHitCount(int)
+ * @deprecated use {@link #getFacetValueHitCount()}
*/
public int getHitCount(){
return _hitcount;
@@ -53,12 +53,30 @@ public int getHitCount(){
/**
* Sets the hit count
* @param hitcount Hit count
- * @see #getHitCount()
+ * @deprecated use {@link #setFacetValueHitCount(int)}
*/
public void setHitCount(int hitcount){
_hitcount=hitcount;
}
+ /**
+ * Gets the hit count
+ * @return hit count
+ * @see #setHitCount(int)
+ */
+ public int getFacetValueHitCount(){
+ return _hitcount;
+ }
+
+ /**
+ * Sets the hit count
+ * @param hitcount Hit count
+ * @see #getHitCount()
+ */
+ public void setFacetValueHitCount(int hitcount){
+ _hitcount=hitcount;
+ }
+
@Override
public String toString(){
StringBuilder buf=new StringBuilder();
@@ -2,7 +2,6 @@
import java.io.Serializable;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -39,6 +38,17 @@ public float getScore()
}
/**
+ * Get the raw field values
+ * @param field field name
+ * @return field value array
+ * @see #getRawField(String)
+ */
+ public Object[] getRawFields(String field)
+ {
+ return _rawFieldValues != null ? _rawFieldValues.get(field) : null;
+ }
+
+ /**
* Get the field value
* @param field field name
* @return field value
@@ -56,12 +66,32 @@ public String getField(String field)
return null;
}
}
+
+ /**
+ * Get the raw field value
+ * @param field field name
+ * @return raw field value
+ * @see #getRawFields(String)
+ */
+ public Object getRawField(String field)
+ {
+ Object[] fields=getRawFields(field);
+ if (fields!=null && fields.length > 0)
+ {
+ return fields[0];
+ }
+ else
+ {
+ return null;
+ }
+ }
private float score;
private int docid;
private Map<String,String[]> _fieldValues;
+ private Map<String,Object[]> _rawFieldValues;
private Comparable<?> _comparable;
private Document _storedFields;
@@ -103,6 +133,24 @@ public void setDocid(int docid) {
}
/**
+ * Sets the raw field value map
+ * @param rawFieldValues raw field value map
+ * @see #getRawFieldValues()
+ */
+ public void setRawFieldValues(Map<String,Object[]> rawFieldValues) {
+ _rawFieldValues = rawFieldValues;
+ }
+
+ /**
+ * Gets the raw field values
+ * @return raw field value map
+ * @see #setRawFieldValues(Map)
+ */
+ public Map<String,Object[]> getRawFieldValues() {
+ return _rawFieldValues;
+ }
+
+ /**
* Sets the field value map
* @param fieldValues field value map
* @see #getFieldValues()
@@ -1,88 +0,0 @@
-/**
- * Bobo Browse Engine - High performance faceted/parametric search implementation
- * that handles various types of semi-structured data. Written in Java.
- *
- * Copyright (C) 2005-2006 John Wang
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * To contact the project administrators for the bobo-browse project,
- * please go to https://sourceforge.net/projects/bobo-browse/, or
- * send mail to owner@browseengine.com.
- */
-
-package com.browseengine.bobo.fields;
-
-import java.util.HashMap;
-
-import com.browseengine.bobo.facets.FacetHandler;
-import com.browseengine.bobo.facets.impl.CompactMultiValueFacetHandler;
-import com.browseengine.bobo.facets.impl.MultiValueFacetHandler;
-import com.browseengine.bobo.facets.impl.PathFacetHandler;
-import com.browseengine.bobo.facets.impl.RangeFacetHandler;
-import com.browseengine.bobo.facets.impl.SimpleFacetHandler;
-
-public class FieldRegistry {
- private HashMap<String, Class<? extends FacetHandler>> _pluginMap;
-
- private FieldRegistry() {
- _pluginMap = new HashMap<String, Class<? extends FacetHandler>>();
- }
-
- private static final FieldRegistry instance = new FieldRegistry();
-
- static{
- instance.registerFieldPlugin("path", PathFacetHandler.class);
- instance.registerFieldPlugin("simple", SimpleFacetHandler.class);
- instance.registerFieldPlugin("range", RangeFacetHandler.class);
- instance.registerFieldPlugin("tags", MultiValueFacetHandler.class);
- instance.registerFieldPlugin("multi", MultiValueFacetHandler.class);
- instance.registerFieldPlugin("compact", CompactMultiValueFacetHandler.class);
- }
-
- public static FieldRegistry getInstance() {
- return instance;
- }
-
- public Class<? extends FacetHandler> getFieldPlugin(String typename){
- synchronized(_pluginMap){
- return _pluginMap.get(typename);
- }
- }
-
- public void registerFieldPlugin(String typename, Class<? extends FacetHandler> cls) {
- if (typename != null) {
- if (FacetHandler.class.isAssignableFrom(cls)) {
- synchronized (_pluginMap) {
- String name = typename.trim().toLowerCase();
- if (_pluginMap.get(name) == null) {
- try {
- //plugin = (FieldPlugin) cls.newInstance();
- _pluginMap.put(name, cls);
- } catch (Exception e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- } else {
- throw new RuntimeException("plugin: " + name
- + " already exists.");
- }
- }
- }
- else{
- throw new RuntimeException(cls+" is not a valid subclass of "+FacetHandler.class);
- }
- }
- }
-}
Oops, something went wrong.

0 comments on commit f3c4b4b

Please sign in to comment.