当前位置:网站首页>Segment read
Segment read
2022-07-03 07:29:00 【chuanyangwang】
route :
org.apache.lucene.search.IndexSearcher IndexSearcher
org.apache.lucene.index.CompositeReader getContext
org.apache.lucene.index.CompositeReaderContext create
org.apache.lucene.index.CompositeReaderContext build
private IndexReaderContext build(CompositeReaderContext parent, IndexReader reader, int ord, int docBase) {
if (reader instanceof LeafReader) {
final LeafReader ar = (LeafReader) reader;
final LeafReaderContext atomic = new LeafReaderContext(parent, ar, ord, docBase, leaves.size(), leafDocBase);
leaves.add(atomic);
leafDocBase += reader.maxDoc();
return atomic;
} else {
final CompositeReader cr = (CompositeReader) reader;
final List<? extends IndexReader> sequentialSubReaders = cr.getSequentialSubReaders();
final List<IndexReaderContext> children = Arrays.asList(new IndexReaderContext[sequentialSubReaders.size()]);
final CompositeReaderContext newParent;
if (parent == null) {
newParent = new CompositeReaderContext(cr, children, leaves);
} else {
newParent = new CompositeReaderContext(parent, cr, ord, docBase, children);
}
// docBase It's cumulative
int newDocBase = 0;
for (int i = 0, c = sequentialSubReaders.size(); i < c; i++) {
final IndexReader r = sequentialSubReaders.get(i);
// Here is a recursion
children.set(i, build(newParent, r, i, newDocBase));
newDocBase += r.maxDoc();
}
assert newDocBase == cr.maxDoc();
return newParent;
}
}org.apache.lucene.index.OrdinalMap map
// weights: The same field In different segment Different from term The number of
private static int[] map(final long[] weights) {
final int[] newToOld = new int[weights.length];
for (int i = 0; i < weights.length; ++i) {
newToOld[i] = i;
}
new InPlaceMergeSorter() {
@Override
protected void swap(int i, int j) {
final int tmp = newToOld[i];
newToOld[i] = newToOld[j];
newToOld[j] = tmp;
}
@Override
protected int compare(int i, int j) {
// j first since we actually want higher weights first
return Long.compare(weights[newToOld[j]], weights[newToOld[i]]);
}
}.sort(0, weights.length);
return newToOld;
}边栏推荐
- "Moss ma not found" solution
- Recursion, Fibonacci sequence
- Vertx restful style web router
- How long is the fastest time you can develop data API? One minute is enough for me
- An overview of IfM Engage
- IO stream system and FileReader, filewriter
- Qtip2 solves the problem of too many texts
- Unified handling and interception of exception exceptions of vertx
- Vertx multi vertical shared data
- LeetCode
猜你喜欢
随机推荐
OSI knowledge sorting
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
Custom generic structure
Unified handling and interception of exception exceptions of vertx
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
Advanced APL (realize group chat room)
《指环王:力量之戒》新剧照 力量之戒铸造者亮相
Reconnaissance et détection d'images - Notes
Lombok -- simplify code
Topic | synchronous asynchronous
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
VMWare网络模式-桥接,Host-Only,NAT网络
Various postures of CS without online line
Rabbit MQ message sending of vertx
TypeScript let與var的區別
圖像識別與檢測--筆記
[solved] win10 cannot find a solution to the local group policy editor
【最详细】最新最全Redis面试大全(50道)
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Lombok cooperates with @slf4j and logback to realize logging



![[solved] unknown error 1146](/img/f1/b8dd3ca8359ac9eb19e1911bd3790a.png)





