public override List <FacetResult> GetAllDims(int topN) { int ord = children[TaxonomyReader.ROOT_ORDINAL]; IList <FacetResult> results = new List <FacetResult>(); while (ord != TaxonomyReader.INVALID_ORDINAL) { string dim = taxoReader.GetPath(ord).Components[0]; DimConfig dimConfig = config.GetDimConfig(dim); if (dimConfig.IndexFieldName.Equals(indexFieldName)) { FacetResult result = GetTopChildren(topN, dim); if (result != null) { results.Add(result); } } ord = siblings[ord]; } // Sort by highest value, tie break by dim: var resultArray = results.ToList(); resultArray.Sort(BY_VALUE_THEN_DIM); return(resultArray); }
private static void PrintAllChildren(TextWriter @out, TaxonomyReader r, int ord, string indent, int depth) { ChildrenIterator it = r.GetChildren(ord); int child; while ((child = it.Next()) != TaxonomyReader.INVALID_ORDINAL) { @out.WriteLine(indent + "/" + r.GetPath(child).Components[depth]); PrintAllChildren(@out, r, child, indent + " ", depth + 1); } }
private static void PrintAllChildren(TextWriter @out, TaxonomyReader r, int ord, string indent, int depth) { ChildrenEnumerator it = r.GetChildren(ord); int child; while (it.MoveNext()) { child = it.Current; @out.WriteLine(indent + "/" + r.GetPath(child).Components[depth]); PrintAllChildren(@out, r, child, indent + " ", depth + 1); } }
/// <summary> /// Recursively prints stats for all ordinals. </summary> public static void PrintStats(TaxonomyReader r, TextWriter @out, bool printTree) { @out.WriteLine(r.Size + " total categories."); ChildrenIterator it = r.GetChildren(TaxonomyReader.ROOT_ORDINAL); int child; while ((child = it.Next()) != TaxonomyReader.INVALID_ORDINAL) { ChildrenIterator chilrenIt = r.GetChildren(child); int numImmediateChildren = 0; while (chilrenIt.Next() != TaxonomyReader.INVALID_ORDINAL) { numImmediateChildren++; } FacetLabel cp = r.GetPath(child); @out.WriteLine("/" + cp.Components[0] + ": " + numImmediateChildren + " immediate children; " + (1 + CountAllChildren(r, child)) + " total categories"); if (printTree) { PrintAllChildren(@out, r, child, " ", 1); } } }
public override IList <FacetResult> GetAllDims(int topN) { int ord = m_children[TaxonomyReader.ROOT_ORDINAL]; List <FacetResult> results = new List <FacetResult>(); while (ord != TaxonomyReader.INVALID_ORDINAL) { string dim = m_taxoReader.GetPath(ord).Components[0]; DimConfig dimConfig = m_config.GetDimConfig(dim); if (dimConfig.IndexFieldName.Equals(m_indexFieldName, StringComparison.Ordinal)) { FacetResult result = GetTopChildren(topN, dim); if (result != null) { results.Add(result); } } ord = m_siblings[ord]; } // Sort by highest value, tie break by dim: results.Sort(BY_VALUE_THEN_DIM); return(results); }