EqualsToSerialized() public static method

Check whether the FacetLabel is equal to the one serialized in CharBlockArray.
public static EqualsToSerialized ( FacetLabel cp, Lucene.Net.Facet.Taxonomy.WriterCache.CharBlockArray charBlockArray, int offset ) : bool
cp FacetLabel
charBlockArray Lucene.Net.Facet.Taxonomy.WriterCache.CharBlockArray
offset int
return bool
Example #1
0
        /// <summary>
        /// Return the mapping, or {@link
        ///  LabelToOrdinal#INVALID_ORDINAL} if the label isn't
        ///  recognized.
        /// </summary>
        public virtual int Get(FacetLabel label, int hash)
        {
            int   bucketIndex = IndexFor(hash, this.capacity_Renamed);
            Entry e           = this.entries[bucketIndex];

            while (e != null && !(hash == e.hash && CategoryPathUtils.EqualsToSerialized(label, labelRepository, e.offset)))
            {
                e = e.next;
            }
            if (e == null)
            {
                return(LabelToOrdinal.INVALID_ORDINAL);
            }

            return(e.cid);
        }
Example #2
0
        /// <summary>
        /// Add another mapping.
        /// </summary>
        public virtual int AddLabel(FacetLabel label, int hash, int cid)
        {
            int bucketIndex = IndexFor(hash, this.capacity_Renamed);

            for (Entry e = this.entries[bucketIndex]; e != null; e = e.next)
            {
                if (e.hash == hash && CategoryPathUtils.EqualsToSerialized(label, labelRepository, e.offset))
                {
                    return(e.cid);
                }
            }

            // new string; add to label repository
            int offset = labelRepository.Length;

            CategoryPathUtils.Serialize(label, labelRepository);
            AddEntry(offset, cid, hash, bucketIndex);
            return(cid);
        }
        private int GetOrdinal(HashArray a, FacetLabel label, int hash)
        {
            if (label == null)
            {
                return(LabelToOrdinal.INVALID_ORDINAL);
            }

            int index  = IndexFor(hash, a.offsets.Length);
            int offset = a.offsets[index];

            if (offset == 0)
            {
                return(LabelToOrdinal.INVALID_ORDINAL);
            }

            if (CategoryPathUtils.EqualsToSerialized(label, labelRepository, offset))
            {
                return(a.cids[index]);
            }

            return(COLLISION);
        }