本文整理汇总了Java中org.apache.lucene.queries.function.ValueSource.newContext方法的典型用法代码示例。如果您正苦于以下问题:Java ValueSource.newContext方法的具体用法?Java ValueSource.newContext怎么用?Java ValueSource.newContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queries.function.ValueSource
的用法示例。
在下文中一共展示了ValueSource.newContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVersionFromIndex
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public Long getVersionFromIndex(BytesRef idBytes) {
// TODO: we could cache much of this and invalidate during a commit.
// TODO: most DocValues classes are threadsafe - expose which.
RefCounted<SolrIndexSearcher> newestSearcher = ulog.uhandler.core.getRealtimeSearcher();
try {
SolrIndexSearcher searcher = newestSearcher.get();
long lookup = searcher.lookupId(idBytes);
if (lookup < 0) return null;
ValueSource vs = versionField.getType().getValueSource(versionField, null);
Map context = ValueSource.newContext(searcher);
vs.createWeight(context, searcher);
FunctionValues fv = vs.getValues(context, searcher.getTopReaderContext().leaves().get((int)(lookup>>32)));
long ver = fv.longVal((int)lookup);
return ver;
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error reading version from index", e);
} finally {
if (newestSearcher != null) {
newestSearcher.decref();
}
}
}
示例2: setContext
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
@Override
public void setContext( TransformContext context ) {
try {
IndexReader reader = qparser.getReq().getSearcher().getIndexReader();
readerContexts = reader.leaves();
docValuesArr = new FunctionValues[readerContexts.size()];
searcher = qparser.getReq().getSearcher();
fcontext = ValueSource.newContext(searcher);
this.valueSource.createWeight(fcontext, searcher);
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
}
示例3: prepare
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void prepare() throws IOException {
Map context = ValueSource.newContext(searcher);
groupBy.createWeight(context, searcher);
actualGroupsToFind = getMax(offset, numGroups, maxDoc);
}
示例4: ValueSourceCollapse
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public ValueSourceCollapse(int maxDoc,
String funcStr,
int nullPolicy,
int[] ords,
boolean max,
boolean needsScores,
IntIntOpenHashMap boostDocs,
FunctionQuery funcQuery, IndexSearcher searcher, SortedDocValues values) throws IOException {
super(maxDoc, null, nullPolicy, max, needsScores, boostDocs, values);
this.valueSource = funcQuery.getValueSource();
this.rcontext = ValueSource.newContext(searcher);
this.ords = ords;
this.ordVals = new float[ords.length];
Arrays.fill(ords, -1);
if(max) {
comp = new MaxFloatComp();
Arrays.fill(ordVals, -Float.MAX_VALUE );
} else {
this.nullVal = Float.MAX_VALUE;
comp = new MinFloatComp();
Arrays.fill(ordVals, Float.MAX_VALUE);
}
if(funcStr.indexOf("cscore()") != -1) {
this.cscore = true;
this.rcontext.put("CSCORE",this.collapseScore);
}
if(this.needsScores) {
this.scores = new float[ords.length];
if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) {
nullScores = new FloatArrayList();
}
}
}
示例5: SpatialWeight
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public SpatialWeight(IndexSearcher searcher) throws IOException {
this.searcher = searcher;
this.latContext = ValueSource.newContext(searcher);
this.lonContext = ValueSource.newContext(searcher);
latSource.createWeight(latContext, searcher);
lonSource.createWeight(lonContext, searcher);
}
示例6: getStringVal
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
private String getStringVal(SolrQueryRequest sqr, String field, int doc) throws IOException {
SchemaField sf = sqr.getSchema().getField(field);
ValueSource vs = sf.getType().getValueSource(sf, null);
Map context = ValueSource.newContext(sqr.getSearcher());
vs.createWeight(context, sqr.getSearcher());
IndexReaderContext topReaderContext = sqr.getSearcher().getTopReaderContext();
List<AtomicReaderContext> leaves = topReaderContext.leaves();
int idx = ReaderUtil.subIndex(doc, leaves);
AtomicReaderContext leaf = leaves.get(idx);
FunctionValues vals = vs.getValues(context, leaf);
return vals.strVal(doc-leaf.docBase);
}
示例7: getFilterCollector
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
@Override
public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
Map fcontext = ValueSource.newContext(searcher);
return new FunctionRangeCollector(fcontext);
}
示例8: ConstantWeight
import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public ConstantWeight(IndexSearcher searcher) throws IOException {
this.context = ValueSource.newContext(searcher);
if (filter instanceof SolrFilter)
((SolrFilter)filter).createWeight(context, searcher);
}