Permalink
Browse files

Merge pull request #2 from vzhabiuk/master

All the recent work done by the CNC search team
  • Loading branch information...
alejandroperez committed Aug 7, 2012
2 parents ab9c3f7 + a76679c commit 45207aadd0ffc2d3446f310d920f84c28e7260b3
Showing with 182 additions and 68 deletions.
  1. +1 −1 bobo-browse/pom.xml
  2. +1 −1 bobo-browse/src/main/java/com/browseengine/bobo/api/BoboSubBrowser.java
  3. +17 −0 bobo-browse/src/main/java/com/browseengine/bobo/api/BrowseResult.java
  4. +17 −3 bobo-browse/src/main/java/com/browseengine/bobo/api/FacetSpec.java
  5. +5 −4 bobo-browse/src/main/java/com/browseengine/bobo/api/MultiBoboBrowser.java
  6. +18 −3 bobo-browse/src/main/java/com/browseengine/bobo/facets/data/TermStringList.java
  7. +3 −2 bobo-browse/src/main/java/com/browseengine/bobo/facets/filter/AdaptiveFacetFilter.java
  8. +4 −4 bobo-browse/src/main/java/com/browseengine/bobo/facets/impl/MultiValueFacetHandler.java
  9. +1 −1 bobo-browse/src/main/java/com/browseengine/bobo/facets/impl/MultiValueWithWeightFacetHandler.java
  10. +1 −1 bobo-browse/src/main/java/com/browseengine/bobo/facets/impl/RangeFacetHandler.java
  11. +17 −7 bobo-browse/src/main/java/com/browseengine/bobo/facets/impl/SimpleFacetHandler.java
  12. +12 −4 bobo-browse/src/main/java/com/browseengine/bobo/facets/range/MultiDataCacheBuilder.java
  13. +1 −1 bobo-browse/src/main/java/com/browseengine/bobo/facets/range/MultiRangeFacetHandler.java
  14. +11 −3 bobo-browse/src/main/java/com/browseengine/bobo/facets/range/SimpleDataCacheBuilder.java
  15. +26 −2 bobo-browse/src/main/java/com/browseengine/bobo/mapred/BoboMapFunctionWrapper.java
  16. +4 −0 bobo-browse/src/main/java/com/browseengine/bobo/mapred/MapReduceResult.java
  17. +13 −5 bobo-browse/src/main/java/com/browseengine/bobo/search/BoboSearcher2.java
  18. +14 −0 bobo-browse/src/test/java/com/browseengine/bobo/test/BoboTestCase.java
  19. +2 −2 bobo-contrib/pom.xml
  20. +2 −3 bobo-contrib/src/main/java/com/browseengine/bobo/geosearch/query/GeoScorer.java
  21. +2 −6 bobo-contrib/src/main/java/com/browseengine/bobo/geosearch/score/IComputeDistance.java
  22. +4 −9 bobo-contrib/src/main/java/com/browseengine/bobo/geosearch/score/impl/HaversineComputeDistance.java
  23. +2 −2 bobo-contrib/src/main/java/com/browseengine/bobo/geosearch/score/impl/HaversineFormula.java
  24. +1 −1 bobo-parent/pom.xml
  25. +1 −1 bobo-solr/pom.xml
  26. +1 −1 cardemo/pom.xml
  27. +1 −1 pom.xml
View
@@ -17,7 +17,7 @@
<parent>
<groupId>com.browseengine.bobo</groupId>
<artifactId>bobo-parent</artifactId>
- <version>3.0.6-SNAPSHOT</version>
+ <version>3.0.8-SNAPSHOT</version>
<relativePath>../bobo-parent/pom.xml</relativePath>
</parent>
@@ -230,7 +230,7 @@ public void browse(BrowseRequest req,
}
catch (IOException e)
{
- logger.error("error trying to set FacetHandler : " + facetName+":"+e.getMessage(),e);
+ throw new BrowseException("error trying to set FacetHandler : " + facetName+":"+e.getMessage(),e);
}
}
// done initialize all RuntimeFacetHandlers with data supplied by user at run-time.
@@ -26,9 +26,11 @@
package com.browseengine.bobo.api;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -75,6 +77,7 @@ public final void setTid(long tid)
private BrowseHit[] hits;
private long time;
private MapReduceResult mapReduceResult;
+ private List<String> errors;
private static BrowseHit[] NO_HITS=new BrowseHit[0];
/**
@@ -332,4 +335,18 @@ public void close()
fa.close();
}
}
+
+ public void addError(String message) {
+ if (errors == null)
+ errors = new ArrayList<String>(1);
+
+ errors.add(message);
+ }
+
+ public List<String> getBoboErrors() {
+ if (errors == null)
+ errors = new ArrayList<String>(1);
+
+ return errors;
+ }
}
@@ -164,9 +164,23 @@ public FacetSpec setExpandSelection(boolean expandSelection) {
* Sets custom properties for the facet search. For example AttributeFacetHandler uses this to perform custom facet filtering
* @param properties
*/
- public void setProperties(Map<String, String> properties) {
+ public FacetSpec setProperties(Map<String, String> properties) {
this.properties = properties;
+ return this;
+ }
+
+ @Override
+ public FacetSpec clone() {
+ Map<String, String> properties = getProperties();
+ Map<String, String> clonedProperties = new HashMap<String, String>(properties.size());
+ clonedProperties.putAll(properties);
+
+ return new FacetSpec()
+ .setCustomComparatorFactory(getCustomComparatorFactory())
+ .setExpandSelection(isExpandSelection())
+ .setMaxCount(getMaxCount())
+ .setMinHitCount(getMinHitCount())
+ .setOrderBy(getOrderBy())
+ .setProperties(clonedProperties);
}
-
-
}
@@ -79,18 +79,17 @@ public void browse(BrowseRequest req,
}
w = createWeight(q);
}
- catch (IOException ioe)
+ catch (Exception ioe)
{
throw new BrowseException(ioe.getMessage(), ioe);
- } catch(RuntimeException e)
- {
- w = null;
}
+
browse(req, w, collector, facetMap, start);
}
public void browse(BrowseRequest req, Weight weight, final Collector hc, Map<String, FacetAccessible> facetMap, int start) throws BrowseException
{
+
Browsable[] browsers = getSubBrowsers();
// index empty
if (browsers==null || browsers.length ==0 ) return;
@@ -187,6 +186,7 @@ public BrowseResult browse(BrowseRequest req) throws BrowseException
}
catch (IOException e){
logger.error(e.getMessage(), e);
+ result.addError(e.getMessage());
hits = new BrowseHit[0];
}
@@ -201,6 +201,7 @@ public BrowseResult browse(BrowseRequest req) throws BrowseException
hit.setExplanation(expl);
} catch (IOException e) {
logger.error(e.getMessage(),e);
+ result.addError(e.getMessage());
}
}
}
@@ -61,7 +61,14 @@ public int indexOf(Object o)
if (withDummy)
{
if (o == null) return -1;
- if (o.equals("") && "".equals(_innerList.get(1))) return 1;
+
+ if (o.equals("")) {
+ if (_innerList.size() > 1 && "".equals(_innerList.get(1))) {
+ return 1;
+ } else if (_innerList.size() < 2) {
+ return -1;
+ }
+ }
return Collections.binarySearch(((ArrayList<String>)_innerList), (String)o);
} else
{
@@ -80,7 +87,9 @@ public boolean containsWithType(String val)
if (withDummy)
{
if (val == null) return false;
- if (val.equals("")) return "".equals(_innerList.get(1));
+ if (val.equals("")) {
+ return _innerList.size() > 1 && "".equals(_innerList.get(1));
+ }
return Collections.binarySearch(((ArrayList<String>)_innerList), val)>=0;
} else
{
@@ -94,7 +103,13 @@ public int indexOfWithType(String o)
if (withDummy)
{
if (o == null) return -1;
- if (o.equals("") && "".equals(_innerList.get(1))) return 1;
+ if (o.equals("")) {
+ if (_innerList.size() > 1 && "".equals(_innerList.get(1))) {
+ return 1;
+ } else if (_innerList.size() < 2) {
+ return -1;
+ }
+ }
return Collections.binarySearch(((ArrayList<String>)_innerList), (String)o);
} else
{
@@ -37,6 +37,7 @@
public interface FacetDataCacheBuilder{
FacetDataCache build(BoboIndexReader reader);
String getName();
+ String getIndexFieldName();
}
// If takeComplement is true, we still return the filter for NotValues . Therefore, the calling function of this class needs to apply NotFilter on top
@@ -87,8 +88,8 @@ public RandomAccessDocIdSet getRandomAccessDocIdSet(BoboIndexReader reader)
// takeComplement is only used to choose between TermListRandomAccessDocIdSet and innerDocSet
int validFreqCount = _takeComplement ? (totalCount - freqCount) : freqCount;
- if (_facetDataCacheBuilder.getName() != null && ((validFreqCount<<1) < totalCount)) {
- return new TermListRandomAccessDocIdSet(_facetDataCacheBuilder.getName(), innerDocSet, validVals, reader);
+ if (_facetDataCacheBuilder.getIndexFieldName() != null && ((validFreqCount<<1) < totalCount)) {
+ return new TermListRandomAccessDocIdSet(_facetDataCacheBuilder.getIndexFieldName(), innerDocSet, validVals, reader);
}
else{
return innerDocSet;
@@ -107,7 +107,7 @@ public MultiValueFacetHandler(String name, Set<String> depends)
@Override
public DocComparatorSource getDocComparatorSource()
{
- return new MultiValueFacetDataCache.MultiFacetDocComparatorSource(new MultiDataCacheBuilder(getName()));
+ return new MultiValueFacetDataCache.MultiFacetDocComparatorSource(new MultiDataCacheBuilder(getName(), _indexFieldName));
}
@@ -179,8 +179,8 @@ public MultiValueFacetDataCache load(BoboIndexReader reader, WorkArea workArea)
@Override
public RandomAccessFilter buildRandomAccessFilter(String value, Properties prop) throws IOException
{
- MultiValueFacetFilter f= new MultiValueFacetFilter(new MultiDataCacheBuilder(getName()), value);
- AdaptiveFacetFilter af = new AdaptiveFacetFilter(new SimpleDataCacheBuilder(getName()), f, new String[]{value}, false);
+ MultiValueFacetFilter f= new MultiValueFacetFilter(new MultiDataCacheBuilder(getName(), _indexFieldName), value);
+ AdaptiveFacetFilter af = new AdaptiveFacetFilter(new SimpleDataCacheBuilder(getName(), _indexFieldName), f, new String[]{value}, false);
return af;
}
@@ -214,7 +214,7 @@ public RandomAccessFilter buildRandomAccessOrFilter(String[] vals,Properties pro
{
MultiValueORFacetFilter f = new MultiValueORFacetFilter(this,vals,false); // catch the "not" case later
if (!isNot) {
- AdaptiveFacetFilter af = new AdaptiveFacetFilter(new SimpleDataCacheBuilder(getName()), f, vals, false);
+ AdaptiveFacetFilter af = new AdaptiveFacetFilter(new SimpleDataCacheBuilder(getName(), _indexFieldName), f, vals, false);
return af;
}
else{
@@ -57,7 +57,7 @@ public MultiValueWithWeightFacetHandler(String name)
@Override
public RandomAccessFilter buildRandomAccessFilter(String value, Properties prop) throws IOException
{
- MultiValueFacetFilter f= new MultiValueFacetFilter(new MultiDataCacheBuilder(getName()), value);
+ MultiValueFacetFilter f= new MultiValueFacetFilter(new MultiDataCacheBuilder(getName(), _indexFieldName), value);
return f;
}
@Override
@@ -109,7 +109,7 @@ public RandomAccessFilter buildRandomAccessOrFilter(String[] vals,Properties pro
{
if (vals.length > 1)
{
- return new BitSetFilter(new ValueConverterBitSetBuilder(FacetRangeValueConverter.instance, vals, isNot), new SimpleDataCacheBuilder(getName()));
+ return new BitSetFilter(new ValueConverterBitSetBuilder(FacetRangeValueConverter.instance, vals, isNot), new SimpleDataCacheBuilder(getName(), _indexFieldName));
}
else
{
@@ -113,9 +113,14 @@ public FacetDataCache build(BoboIndexReader reader) {
@Override
public String getName() {
- return _indexFieldName;
+ return SimpleFacetHandler.this.getName();
}
-
+
+ @Override
+ public String getIndexFieldName() {
+ return _indexFieldName;
+ }
+
}, f, new String[]{value}, false);
return af;
}
@@ -148,11 +153,16 @@ public FacetDataCache build(BoboIndexReader reader) {
return getFacetData(reader);
}
- @Override
- public String getName() {
- return _indexFieldName;
- }
-
+ @Override
+ public String getName() {
+ return SimpleFacetHandler.this.getName();
+ }
+
+ @Override
+ public String getIndexFieldName() {
+ return _indexFieldName;
+ }
+
}, f, vals, isNot);
}
else if(vals.length == 1)
@@ -6,14 +6,22 @@
public class MultiDataCacheBuilder implements FacetDataCacheBuilder{
private String name;
- public MultiDataCacheBuilder( String name) {
+ private String indexFieldName;
+
+ public MultiDataCacheBuilder(String name, String indexFieldName) {
this.name = name;
-
+ this.indexFieldName = indexFieldName;
}
+
public MultiValueFacetDataCache build(BoboIndexReader reader) {
return (MultiValueFacetDataCache) reader.getFacetData(name);
}
+
public String getName() {
return name;
- }
-}
+ }
+
+ public String getIndexFieldName() {
+ return indexFieldName;
+ }
+}
@@ -39,7 +39,7 @@ public MultiRangeFacetHandler(String name, String indexFieldName, Term sizePaylo
@Override
public DocComparatorSource getDocComparatorSource() {
- return new MultiValueFacetDataCache.MultiFacetDocComparatorSource(new MultiDataCacheBuilder(getName()));
+ return new MultiValueFacetDataCache.MultiFacetDocComparatorSource(new MultiDataCacheBuilder(getName(), _indexFieldName));
}
@Override
@@ -6,14 +6,22 @@
public class SimpleDataCacheBuilder implements FacetDataCacheBuilder{
private String name;
- public SimpleDataCacheBuilder( String name) {
+ private String indexFieldName;
+
+ public SimpleDataCacheBuilder(String name, String indexFieldName) {
this.name = name;
-
+ this.indexFieldName = indexFieldName;
}
+
public FacetDataCache build(BoboIndexReader reader) {
return (FacetDataCache) reader.getFacetData(name);
}
+
public String getName() {
return name;
- }
+ }
+
+ public String getIndexFieldName() {
+ return indexFieldName;
+ }
}
@@ -1,11 +1,35 @@
package com.browseengine.bobo.mapred;
+import java.util.List;
+
import com.browseengine.bobo.api.BoboIndexReader;
+import com.browseengine.bobo.facets.FacetCountCollector;
+/**
+ * Is the part of the bobo request, that maintains the map result intermediate state
+ *
+ */
public interface BoboMapFunctionWrapper {
- public void mapFullIndexReader(BoboIndexReader reader);
+ /**
+ * When there is no filter, map reduce will try to map the entire segment
+ * @param reader
+ */
+ public void mapFullIndexReader(BoboIndexReader reader, FacetCountCollector[] facetCountCollectors);
+ /**
+ * The basic callback method for a single doc
+ * @param docId
+ * @param reader
+ */
public void mapSingleDocument(int docId, BoboIndexReader reader);
- public void finalizeSegment(BoboIndexReader reader);
+ /**
+ * The callback method, after the segment was processed
+ * @param reader
+ */
+ public void finalizeSegment(BoboIndexReader reader, FacetCountCollector[] facetCountCollectors);
+ /**
+ * The callback method, after the partition was processed
+ *
+ */
public void finalizePartition();
public MapReduceResult getResult();
}
@@ -4,6 +4,10 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Keeps the map reduce results
+ *
+ */
public class MapReduceResult implements Serializable {
protected List mapResults = new ArrayList(200);
protected Serializable reduceResult;
Oops, something went wrong.

0 comments on commit 45207aa

Please sign in to comment.