本文整理汇总了Java中org.apache.solr.common.util.SimpleOrderedMap类的典型用法代码示例。如果您正苦于以下问题:Java SimpleOrderedMap类的具体用法?Java SimpleOrderedMap怎么用?Java SimpleOrderedMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleOrderedMap类属于org.apache.solr.common.util包,在下文中一共展示了SimpleOrderedMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toNamedList
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
/** Convert this to a NamedList */
public NamedList<Object> toNamedList() {
final SimpleOrderedMap<Object> result = new SimpleOrderedMap<>();
for(Iterator<String> it=getParameterNamesIterator(); it.hasNext(); ) {
final String name = it.next();
final String [] values = getParams(name);
if(values.length==1) {
result.add(name,values[0]);
} else {
// currently no reason not to use the same array
result.add(name,values);
}
}
return result;
}
示例2: getChildCounts
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public static Map<String,Integer> getChildCounts(SolrResponse response) {
//check if there are subdocs
if (Objects.nonNull(response.getResponse())) {
final Object subDocumentFacetResult = response.getResponse().get("facets");
if (Objects.nonNull(subDocumentFacetResult)) {
Map<String,Integer> childCounts = new HashMap<>();
log.debug("Parsing subdocument facet result from JSON ");
final int facetCount = (int) ((SimpleOrderedMap) subDocumentFacetResult).get("count");
if (facetCount > 0) {
final List<SimpleOrderedMap> parentDocs = (ArrayList) ((SimpleOrderedMap) ((SimpleOrderedMap) subDocumentFacetResult).get("parent_facet")).get("buckets");
childCounts = parentDocs.stream().collect(Collectors.toMap(p -> (String) p.get("val"), p -> ((Integer) ((SimpleOrderedMap) p.get("children_facet")).get("count"))));
}
return childCounts;
}
}
return null;
}
示例3: setUp
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
@Before
public void setUp() {
rh1 = mock(SearchHandler.class);
rh2 = mock(SearchHandler.class);
rh3 = mock(SearchHandler.class);
cut = new InvisibleQueriesRequestHandler();
qrequest = mock(SolrQueryRequest.class);
qresponse = mock(SolrQueryResponse.class);
args = new SimpleOrderedMap<>();
args.add(
InvisibleQueriesRequestHandler.CHAIN_KEY,
SAMPLE_VALID_CHAIN.stream().collect(joining(",")));
params = new ModifiableSolrParams().add(SAMPLE_KEY, SAMPLE_VALUE);
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:19,代码来源:FacadeRequestHandlerTestCase.java
示例4: getResult
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public SimpleOrderedMap<Object> getResult(){
if(future.isDone()){
SimpleOrderedMap<Object> result = new SimpleOrderedMap<Object>();
//Config json = ConfigFactory.parseFile(featuresFile); // I don't know why, but this throws parse error
// Let's use parseReader to avoid parse error
Reader r = null;
try{
r = new FileReader(featuresFile);
Config json = ConfigFactory.parseReader(new FileReader(featuresFile));
result.add("data", parseData(json));
return result;
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally{
IOUtils.closeWhileHandlingException(r);
}
}
else return null;
}
示例5: handleExtract
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public void handleExtract(SolrQueryRequest req, Iterable<ContentStream> ite, SimpleOrderedMap<Object> results)
throws Exception {
FeaturesConfigReader fcReader = new FeaturesConfigReader(req.getCore().getResourceLoader(),
req.getParams().required().get("conf"));
FeaturesConfigReader.FeatureDesc[] featureDescs = fcReader.getFeatureDescs();
List<FieldFeatureExtractorFactory> featuresSpec = new ArrayList<FieldFeatureExtractorFactory>();
for(FeaturesConfigReader.FeatureDesc featureDesc: featureDescs){
FieldFeatureExtractorFactory dfeFactory = FeaturesConfigReader.loadFactory(featureDesc);
featuresSpec.add(dfeFactory);
}
StringBuilder queries = new StringBuilder();
for(ContentStream cs: ite){
Reader reader = cs.getReader();
try{
queries.append(IOUtils.toString(reader));
}
finally{
IOUtils.closeQuietly(reader);
}
}
long procId = startExtractor(req, featuresSpec, queries.toString());
FeaturesExtractorManager manager = getManager(procId);
results.add("procId", procId);
results.add("progress", manager.getProgress());
}
示例6: download
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public SimpleOrderedMap<Object> download(long procId, boolean delete){
SimpleOrderedMap<Object> data = null;
synchronized (managers){
FeaturesExtractorManager manager = managers.get(procId);
if(manager == null){
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, String.format("no such process (procId=%d)", procId));
}
else{
data = manager.getResult();
if(delete){
manager.delete();
managers.remove(procId);
}
}
}
return data;
}
示例7: iterateOverSpellcheckerSuggestionsForAllIncorrectWords
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
/**
* Contains logic for iterating over spellchecker's suggestions. If any of input parameters is null, just exits. This method
* iterates over suggestions for ALL incorrectly spelled words. It will not sub-iterate over suggestions of each incorrect
* word, that is the logic which SpellcheckerSuggestionProcessor should take care off.
*
* @param suggestions list of all suggestions, can be extracted with method .extractSpellcheckerSuggestions().
* @param processor instance of processor which will handle all suggestions for word
*/
@SuppressWarnings("unchecked")
public static void iterateOverSpellcheckerSuggestionsForAllIncorrectWords(NamedList suggestions, SpellcheckerSuggestionProcessor processor) {
if (suggestions == null || processor == null) {
return;
}
for (int i = 0; i < suggestions.size(); i++) {
// find first acceptable suggestion
if (suggestions.getVal(i) instanceof SimpleOrderedMap) {
processor.process((SimpleOrderedMap) suggestions.getVal(i), suggestions.getName(i));
}
}
processor.afterProcessingFinished();
}
示例8: getFacetQueryCounts
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
/**
* Returns a list of facet counts for each of the facet queries
* specified in the params
*
* @see FacetParams#FACET_QUERY
*/
public NamedList<Integer> getFacetQueryCounts() throws IOException,SyntaxError {
NamedList<Integer> res = new SimpleOrderedMap<>();
/* Ignore CommonParams.DF - could have init param facet.query assuming
* the schema default with query param DF intented to only affect Q.
* If user doesn't want schema default for facet.query, they should be
* explicit.
*/
// SolrQueryParser qp = searcher.getSchema().getSolrQueryParser(null);
String[] facetQs = global.getParams(FacetParams.FACET_QUERY);
if (null != facetQs && 0 != facetQs.length) {
for (String q : facetQs) {
final ParsedParams parsed = parseParams(FacetParams.FACET_QUERY, q);
getFacetQueryCount(parsed, res);
}
}
return res;
}
示例9: getHeatmapCounts
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
final NamedList<Object> resOuter = new SimpleOrderedMap<>();
String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
if (unparsedFields == null || unparsedFields.length == 0) {
return resOuter;
}
if (global.getBool(GroupParams.GROUP_FACET, false)) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Heatmaps can't be used with " + GroupParams.GROUP_FACET);
}
for (String unparsedField : unparsedFields) {
final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs
resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
}
return resOuter;
}
示例10: populateNorms
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
private void populateNorms(AggregationWaitable runner,
String requestValue,
LinkedList<String> normalizedStrings,
LinkedList<SimpleOrderedMap<String>> normalizedMaps) {
for(SimpleOrderedMap<Object> bucket : runner.buckets)
{
SimpleOrderedMap<String> facetResult = runner.adapter.getMapValue(bucket);
if(MapUtility.mapContainsValue(requestValue.toLowerCase(), facetResult))
{
normalizedStrings.add(runner.adapter.getStringValue(bucket));
normalizedMaps.add(runner.adapter.getMapValue(bucket));
return;
}
}
normalizedStrings.add(requestValue);
normalizedMaps.add(null);
}
示例11: addPassedInValues_normalized
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
@Test
public void addPassedInValues_normalized() throws IOException
{
ResponseNode response = new ResponseNode("testField");
response.values = new ResponseValue[2];
ResponseValue [] expecteds = new ResponseValue[2];
expecteds[0] = new ResponseValue("passedInValue1");
expecteds[0].normalizedValue = new SimpleOrderedMap<>();
expecteds[0].normalizedValue.add("name", "passedInValue1");
expecteds[1] = new ResponseValue("passedInValue2");
expecteds[1].normalizedValue = new SimpleOrderedMap<>();
expecteds[1].normalizedValue.add("name", "passedInValue2");
request.normalizedValues = new LinkedList<>();
request.normalizedValues.add(expecteds[0].normalizedValue);
request.normalizedValues.add(expecteds[1].normalizedValue);
NodeGenerator target = new NodeGenerator();
Deencapsulation.invoke(target, "addPassedInValues", request, response);
Assert.assertEquals(2, response.values.length);
for(int i = 0; i < expecteds.length; ++i) {
Assert.assertTrue(response.values[i].equals(expecteds[i]));
Assert.assertTrue(MapUtility.mapsEqual(response.values[i].normalizedValue, expecteds[i].normalizedValue));
}
}
示例12: toNamedList
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
/** Convert this to a NamedList */
public NamedList<Object> toNamedList() {
final SimpleOrderedMap<Object> result = new SimpleOrderedMap<>();
for(Iterator<String> it=getParameterNamesIterator(); it.hasNext(); ) {
final String name = it.next();
final String [] values = getParams(name);
if(values.length==1) {
result.add(name,values[0]);
} else {
// currently no reason not to use the same array
result.add(name,values);
}
}
return result;
}
示例13: getStatistics
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
@Override
public NamedList<Object> getStatistics() {
NamedList<Object> lst = new SimpleOrderedMap<>();
lst.add("searcherName", name);
lst.add("caching", cachingEnabled);
lst.add("numDocs", reader.numDocs());
lst.add("maxDoc", reader.maxDoc());
lst.add("deletedDocs", reader.maxDoc() - reader.numDocs());
lst.add("reader", reader.toString());
lst.add("readerDir", reader.directory());
lst.add("indexVersion", reader.getVersion());
lst.add("openedAt", new Date(openTime));
if (registerTime!=0) lst.add("registeredAt", new Date(registerTime));
lst.add("warmupTime", warmupTime);
return lst;
}
示例14: preDecorateResponse
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
public static void preDecorateResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
// setup response header
final NamedList<Object> responseHeader = new SimpleOrderedMap<>();
rsp.add("responseHeader", responseHeader);
// toLog is a local ref to the same NamedList used by the response
NamedList<Object> toLog = rsp.getToLog();
// for back compat, we set these now just in case other code
// are expecting them during handleRequest
toLog.add("webapp", req.getContext().get("webapp"));
toLog.add("path", req.getContext().get("path"));
final SolrParams params = req.getParams();
final String lpList = params.get(CommonParams.LOG_PARAMS_LIST);
if (lpList == null) {
toLog.add("params", "{" + req.getParamString() + "}");
} else if (lpList.length() > 0) {
toLog.add("params", "{" + params.toFilteredSolrParams(Arrays.asList(lpList.split(","))).toString() + "}");
}
}
示例15: getStatistics
import org.apache.solr.common.util.SimpleOrderedMap; //导入依赖的package包/类
@Override
public NamedList getStatistics() {
NamedList lst = new SimpleOrderedMap();
synchronized (map) {
lst.add("lookups", lookups);
lst.add("hits", hits);
lst.add("hitratio", calcHitRatio(lookups,hits));
lst.add("inserts", inserts);
lst.add("evictions", evictions);
lst.add("size", map.size());
}
lst.add("warmupTime", warmupTime);
long clookups = stats.lookups.get();
long chits = stats.hits.get();
lst.add("cumulative_lookups", clookups);
lst.add("cumulative_hits", chits);
lst.add("cumulative_hitratio", calcHitRatio(clookups,chits));
lst.add("cumulative_inserts", stats.inserts.get());
lst.add("cumulative_evictions", stats.evictions.get());
return lst;
}