当前位置:网站首页>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;
}边栏推荐
猜你喜欢

为什么说数据服务化是下一代数据中台的方向?

HCIA notes

How long is the fastest time you can develop data API? One minute is enough for me

Margin left: -100% understanding in the Grail layout

URL programming

Map interface and method

Summary of Arduino serial functions related to print read

图像识别与检测--笔记

Docker builds MySQL: the specified path of version 5.7 cannot be mounted.

Take you through the whole process and comprehensively understand the software accidents that belong to testing
随机推荐
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
Introduction of transformation flow
Read config configuration file of vertx
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
Jeecg menu path display problem
Various postures of CS without online line
《指环王:力量之戒》新剧照 力量之戒铸造者亮相
【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
Talk about floating
Lombok cooperates with @slf4j and logback to realize logging
7.2 brush two questions
最全SQL与NoSQL优缺点对比
Vertx's responsive redis client
SharePoint modification usage analysis report is more than 30 days
Lombok -- simplify code
FileInputStream and fileoutputstream
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
Image recognition and detection -- Notes
Use of other streams
TypeScript let與var的區別