当前位置:网站首页>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;
}
边栏推荐
- Dora (discover offer request recognition) process of obtaining IP address
- Common methods of file class
- 最全SQL与NoSQL优缺点对比
- 2021-07-18
- [solved] win10 cannot find a solution to the local group policy editor
- Rabbit MQ message sending of vertx
- FileInputStream and fileoutputstream
- Vertx's responsive redis client
- La différence entre le let Typescript et le Var
- [plus de détails] dernière entrevue complète redis (50)
猜你喜欢
随机推荐
Download address collection of various versions of devaexpress
Qtip2 solves the problem of too many texts
Vertx's responsive redis client
IPv4 address
Advanced APL (realize group chat room)
Lombok -- simplify code
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
SecureCRT取消Session记录的密码
Lombok cooperates with @slf4j and logback to realize logging
Why is data service the direction of the next generation data center?
PAT甲级真题1166
The babbage industrial policy forum
VMWare网络模式-桥接,Host-Only,NAT网络
Map interface and method
《指环王:力量之戒》新剧照 力量之戒铸造者亮相
SharePoint modification usage analysis report is more than 30 days
Common APIs
TypeScript let与var的区别
Responsive MySQL of vertx