Permalink
Browse files

Added javadocs

  • Loading branch information...
1 parent a6d468d commit 634fe2a768d97da827ee6e9228494a43eadf4303 vzhabiuk committed May 5, 2012
@@ -3,6 +3,10 @@
import java.util.Arrays;
import java.util.List;
+/**
+ * Holds params needed to initialize the facet filter
+ *
+ */
public class FacetInit {
String type; List<Object> values;
@@ -1,5 +1,11 @@
package com.senseidb.search.client.req;
+/**
+ * Specifies different facet types
+ * Supported facet types:
+
+ *
+ */
public enum FacetType {
type_int, type_long, type_double, type_float, type_short, type_string;
@@ -3,6 +3,10 @@
import java.util.Map;
+/**
+ * Allows to create Sensei map reduce job
+ *
+ */
public class MapReduce {
private String function;
private Map<String, Object> parameters;
@@ -9,6 +9,32 @@
import com.senseidb.search.client.json.JsonField;
import com.senseidb.search.client.req.FacetType;
+/**
+ * The relevance json has two parts, one is the model part, another is the
+ * values part. Model part should be relatively static. The values part provides
+ * the input required by the static model. Each request may have different
+ * values part, but may probably use the same model.
+ *
+ * Inside the model part, we define 4 items:
+ *
+ * <ol>
+ * <li>variables — User provided variable, the variable name and type are defined
+ * here, but the actual values has to be filled outside the model part, but in
+ * the values part.
+ *
+ * <li>facets — Define what facet/column will be used in the relevance model. It
+ * automatically defined the variable name the same as the facet name.
+ *
+ * <li>function_params — Define which parameters will be used in the function. All
+ * the parameters listed here have to be defined either in the variables part,
+ * or the facets part.
+ *
+ * <li>function — The real function body. Java code here. It must have a return
+ * type, and return a float value. No malicious class can be used, a custom
+ * class loader will prevent it from being loaded if it is not in the white
+ * class list.
+ * <ol>
+ */
public class Model {
private Map<String, List<String>> variables = new HashMap<String, List<String>>();;
private Map<String, List<String>> facets = new HashMap<String, List<String>>();
@@ -17,54 +43,62 @@
private String function;
@JsonField("save_as")
private SaveAs saveAs;
+
public static ModelBuilder builder() {
return new ModelBuilder();
}
-
+
public static class ModelBuilder {
private final Model model;
+
public ModelBuilder() {
this.model = new Model();
}
+
public ModelBuilder function(String function) {
this.model.function = function;
return this;
}
+
public ModelBuilder addFunctionParams(String... params) {
if (params != null) {
this.model.functionParams.addAll(Arrays.asList(params));
}
return this;
}
+
public ModelBuilder addFacets(RelevanceFacetType type, String... names) {
if (names != null) {
- List<String> facets = this.model.facets.get(type.getValue());
- if (facets == null) {
- facets = new ArrayList<String>();
- this.model.facets.put(type.getValue(), facets);
- }
- facets.addAll(Arrays.asList(names));
+ List<String> facets = this.model.facets.get(type.getValue());
+ if (facets == null) {
+ facets = new ArrayList<String>();
+ this.model.facets.put(type.getValue(), facets);
+ }
+ facets.addAll(Arrays.asList(names));
}
return this;
}
+
public ModelBuilder addVariables(VariableType type, String... variables) {
if (variables != null) {
- List<String> variablesList = this.model.variables.get(type.getValue());
- if (variablesList == null) {
- variablesList = new ArrayList<String>();
- this.model.variables.put(type.getValue(), variablesList);
- }
- variablesList.addAll(Arrays.asList(variables));
+ List<String> variablesList = this.model.variables.get(type.getValue());
+ if (variablesList == null) {
+ variablesList = new ArrayList<String>();
+ this.model.variables.put(type.getValue(), variablesList);
+ }
+ variablesList.addAll(Arrays.asList(variables));
}
return this;
}
+
public ModelBuilder saveAs(String name, boolean overwrite) {
this.model.saveAs = new SaveAs(name, overwrite);
return this;
}
+
public Model build() {
return model;
}
}
-
+
}
@@ -6,6 +6,17 @@
import java.util.List;
import java.util.Map;
+/**
+ * The "values" part provides the input values for either the runtime model or the predefined one
+ * values part is used for either predefined model or a runtime model above, if these models require input values;
+ * <pre> "values":{
+ * "thisYear":2001,
+ * "goodYear":[
+ * 1996,
+ * 1997
+ * ]
+ * }</pre>
+ */
public class RelevanceValues {
protected Map<String, Object> values = new HashMap<String, Object>();
@@ -1,18 +1,30 @@
package com.senseidb.search.client.req.relevance;
+/**
+ * "save as" part below is optional, if specified, this runtime generated model
+ * will be saved with a name. After a runtime model is named, it will be
+ * convenient to use next time, we can just specify the model name. Attn: Even
+ * if we do not name a runtime model, the system will also automatically cache a
+ * certain amount of anonymous runtime models, so there is no extra compilation
+ * cost for second request with the same model function body and signature.
+ *
+ */
public class SaveAs {
private String name;
private boolean overwrite;
+
public SaveAs(String name, boolean overwrite) {
super();
this.name = name;
this.overwrite = overwrite;
}
+
public String getName() {
return name;
}
+
public boolean isOverwrite() {
return overwrite;
}
-
+
}
@@ -1,10 +1,21 @@
package com.senseidb.search.client.req.relevance;
+/**
+ * Supported variable types:
+ * <ul>
+ * <li>Variable type:
+ * <li>HashSet: in detail, set_int, set_float, set_string, set_double,
+ * set_long|set_int, set_float, set_string, set_double, set_long.
+ * <li>HashMap: e.g., map_int_int, map_int_double, map_int_float,
+ * map_string_int, map_string_double, etc. (Currently support two types hashmap:
+ * map_int_* and map_string_*)
+ * <li>other normal type: int, double, float, long, bool, string.
+ * </ul>
+ *
+ *
+ */
public enum VariableType {
- set_int, set_float, set_string, set_double, set_long,
- map_int_int,map_int_double,map_int_float,map_int_long,map_int_bool,map_int_string,
- map_string_int,map_string_double,map_string_float,map_string_long,map_string_bool,map_string_string,
- type_int, type_double, type_float, type_long, type_bool, type_string;
+ set_int, set_float, set_string, set_double, set_long, map_int_int, map_int_double, map_int_float, map_int_long, map_int_bool, map_int_string, map_string_int, map_string_double, map_string_float, map_string_long, map_string_bool, map_string_string, type_int, type_double, type_float, type_long, type_bool, type_string;
public String getValue() {
if (this.name().startsWith("type_")) {
return this.name().substring("type_".length());
@@ -21,10 +21,14 @@ sensei.cluster.url=localhost:2181
# sensei indexing parameters
sensei.index.directory = /tmp/sensei-example-cars-perf
-
-sensei.index.batchSize = 2000000
+sensei.indexer.type=hourglass
+sensei.indexer.hourglass.frequency=minute
+sensei.indexer.hourglass.schedule=00 00 00
+sensei.indexer.hourglass.trimthreshold=3
+sensei.index.hourglass.DelayedGCPerIndexReaderInSeconds=4
+sensei.index.batchSize = 40000
sensei.index.batchDelay = 5
-sensei.index.maxBatchSize = 2000000
+sensei.index.maxBatchSize = 40000
sensei.index.realtime = true
# indicator of freshness of data, in seconds, a number <=0 implies as fast as possible
@@ -41,7 +41,7 @@ public void run() {
}
};
};
- //thread.start();
+ thread.start();
Thread[] queryThreads = new Thread[1];
final SenseiServiceProxy proxy = new SenseiServiceProxy("localhost", 8080);
Runnable query = new Runnable() {
@@ -52,8 +52,8 @@ public void run() {
String sendPostRaw = proxy.sendPostRaw(proxy.getSearchUrl(), ((JSONObject)JsonSerializer.serialize(SenseiClientRequest.builder().addSort(com.senseidb.search.client.req.Sort.desc("mileage")).build())).toString());
try {
int numihits = new JSONObject(sendPostRaw).getInt("totaldocs");
- System.out.println(numihits);
- Thread.sleep(200);
+ //System.out.println(numihits);
+ Thread.sleep(500);
if (numihits == 0) {
System.out.println("!!!!numihits is 0");
@@ -1,5 +1,17 @@
package com.senseidb.search.req.mapred;
+/**
+ * Tells on which level the combine callback method is called.
+ * @author vzhabiuk
+ *
+ */
public enum CombinerStage {
- partitionLevel, nodeLevel
+ /**
+ * After partition was processed
+ */
+ partitionLevel,
+ /**
+ * On the node level
+ */
+ nodeLevel
}
@@ -65,6 +65,12 @@ public final FacetDataCache getValueCache(String name) {
+ /**
+ * Get facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final Object get(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache instanceof MultiValueFacetDataCache) {
@@ -76,12 +82,22 @@ public final Object get(String fieldName, int docId) {
return getFacetHandler(fieldName).getRawFieldValues(boboIndexReader, docId);
}
-
+ /**
+ * Get string facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final String getString(String fieldName, int docId) {
return getFacetHandler(fieldName).getFieldValue(boboIndexReader, docId);
}
-
+ /**
+ * Get long facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final long getLong(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache != null) {
@@ -105,7 +121,12 @@ public final long getLong(String fieldName, int docId) {
}
}
-
+ /**
+ * Get double facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final double getDouble(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache != null) {
@@ -125,7 +146,12 @@ public final double getDouble(String fieldName, int docId) {
}
}
-
+ /**
+ * Get short facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final short getShort(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache != null) {
@@ -149,7 +175,12 @@ public final short getShort(String fieldName, int docId) {
}
}
-
+ /**
+ * Get integer facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final int getInteger(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache != null) {
@@ -173,7 +204,12 @@ public final int getInteger(String fieldName, int docId) {
}
}
-
+ /**
+ * Get float facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final float getFloat(String fieldName, int docId) {
FacetDataCache valueCache = getValueCache(fieldName);
if (valueCache != null) {
@@ -197,7 +233,12 @@ public final float getFloat(String fieldName, int docId) {
}
}
-
+ /**
+ * Get array facet value for the document
+ * @param fieldName
+ * @param docId
+ * @return
+ */
public final Object[] getArray(String fieldName, int docId) {
return getFacetHandler(fieldName).getRawFieldValues(boboIndexReader, docId);
@@ -256,6 +297,10 @@ public final FacetHandler getFacetHandler(String fieldName) {
public BoboIndexReader getBoboIndexReader() {
return boboIndexReader;
}
+ /**
+ * Returns the docIdtoUID mapper
+ * @return
+ */
public DocIDMapper getMapper() {
return mapper;
}
Oops, something went wrong.

0 comments on commit 634fe2a

Please sign in to comment.