本文整理汇总了Java中org.apache.lucene.facet.taxonomy.TaxonomyReader.ROOT_ORDINAL属性的典型用法代码示例。如果您正苦于以下问题:Java TaxonomyReader.ROOT_ORDINAL属性的具体用法?Java TaxonomyReader.ROOT_ORDINAL怎么用?Java TaxonomyReader.ROOT_ORDINAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.lucene.facet.taxonomy.TaxonomyReader
的用法示例。
在下文中一共展示了TaxonomyReader.ROOT_ORDINAL属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalAddCategory
/**
* Add a new category into the index (and the cache), and return its new
* ordinal.
* <p>
* Actually, we might also need to add some of the category's ancestors
* before we can add the category itself (while keeping the invariant that a
* parent is always added to the taxonomy before its child). We do this by
* recursion.
*/
private int internalAddCategory(FacetLabel cp) throws IOException {
// Find our parent's ordinal (recursively adding the parent category
// to the taxonomy if it's not already there). Then add the parent
// ordinal as payloads (rather than a stored field; payloads can be
// more efficiently read into memory in bulk by LuceneTaxonomyReader)
int parent;
if (cp.length > 1) {
FacetLabel parentPath = cp.subpath(cp.length - 1);
parent = findCategory(parentPath);
if (parent < 0) {
parent = internalAddCategory(parentPath);
}
} else if (cp.length == 1) {
parent = TaxonomyReader.ROOT_ORDINAL;
} else {
parent = TaxonomyReader.INVALID_ORDINAL;
}
int id = addCategoryDocument(cp, parent);
return id;
}
示例2: printStats
public static void printStats(TaxonomyReader r, PrintStream out, boolean printTree) throws IOException {
ParallelTaxonomyArrays arrays = r.getParallelTaxonomyArrays();
//int[] parents = arrays.parents();
int[] children = arrays.children();
int[] siblings = arrays.siblings();
out.println(r.getSize() + " total categories.");
int childOrd = children[TaxonomyReader.ROOT_ORDINAL];
while(childOrd != -1) {
CategoryPath cp = r.getPath(childOrd);
int childOrd2 = children[childOrd];
int numImmediateChildren = 0;
while(childOrd2 != -1) {
numImmediateChildren++;
childOrd2 = siblings[childOrd2];
}
out.println("/" + cp + ": " + numImmediateChildren + " immediate children; " + (1+countAllChildren(r, childOrd, children, siblings)) + " total categories");
if (printTree) {
printAllChildren(out, r, childOrd, children, siblings, " ", 1);
}
childOrd = siblings[childOrd];
}
}
示例3: internalAddCategory
/**
* Add a new category into the index (and the cache), and return its new
* ordinal.
* <p>
* Actually, we might also need to add some of the category's ancestors
* before we can add the category itself (while keeping the invariant that a
* parent is always added to the taxonomy before its child). We do this by
* recursion.
*/
private int internalAddCategory(CategoryPath cp) throws IOException {
// Find our parent's ordinal (recursively adding the parent category
// to the taxonomy if it's not already there). Then add the parent
// ordinal as payloads (rather than a stored field; payloads can be
// more efficiently read into memory in bulk by LuceneTaxonomyReader)
int parent;
if (cp.length > 1) {
CategoryPath parentPath = cp.subpath(cp.length - 1);
parent = findCategory(parentPath);
if (parent < 0) {
parent = internalAddCategory(parentPath);
}
} else if (cp.length == 1) {
parent = TaxonomyReader.ROOT_ORDINAL;
} else {
parent = TaxonomyReader.INVALID_ORDINAL;
}
int id = addCategoryDocument(cp, parent);
return id;
}