Returns 3 arrays for traversing the taxonomy:
  • {@code parents}: {@code parents[i]} denotes the parent of category ordinal {@code i}.
  • {@code children}: {@code children[i]} denotes a child of category ordinal {@code i}.
  • {@code siblings}: {@code siblings[i]} denotes the sibling of category ordinal {@code i}.
To traverse the taxonomy tree, you typically start with {@code children[0]} (ordinal 0 is reserved for ROOT), and then depends if you want to do DFS or BFS, you call {@code children[children[0]]} or {@code siblings[children[0]]} and so forth, respectively.

NOTE: you are not expected to modify the values of the arrays, since the arrays are shared with other threads. @lucene.experimental

Ejemplo n.º 1
0
        /// <summary>
        /// Returns an iterator over the children of the given ordinal.
        /// </summary>
        public virtual ChildrenIterator GetChildren(int ordinal)
        {
            ParallelTaxonomyArrays arrays = ParallelTaxonomyArrays;
            int child = ordinal >= 0 ? arrays.Children[ordinal] : INVALID_ORDINAL;

            return(new ChildrenIterator(child, arrays.Siblings));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sole constructor.
        /// </summary>
        protected internal TaxonomyFacets(string indexFieldName, TaxonomyReader taxoReader, FacetsConfig config)
        {
            this.m_indexFieldName = indexFieldName;
            this.m_taxoReader     = taxoReader;
            this.m_config         = config;
            ParallelTaxonomyArrays pta = taxoReader.ParallelTaxonomyArrays;

            m_children = pta.Children;
            m_siblings = pta.Siblings;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sole constructor.
        /// </summary>
        protected internal TaxonomyFacets(string indexFieldName, TaxonomyReader taxoReader, FacetsConfig config)
        {
            this.IndexFieldName = indexFieldName;
            this.TaxoReader     = taxoReader;
            this.Config         = config;
            ParallelTaxonomyArrays pta = taxoReader.ParallelTaxonomyArrays;

            Children = pta.Children();
            Siblings = pta.Siblings();
        }
Ejemplo n.º 4
0
 private void AssertChildrenArrays(ParallelTaxonomyArrays ca, int retry, int retrieval)
 {
     int abYoungChild = ca.Children()[abOrd];
     Assert.True(abYoungChildBase1 == abYoungChild || abYoungChildBase2 == ca.Children()[abOrd], "Retry " + retry + ": retrieval: " + retrieval + ": wrong youngest child for category " + abPath + " (ord=" + abOrd + ") - must be either " + abYoungChildBase1 + " or " + abYoungChildBase2 + " but was: " + abYoungChild);
 }