/// <summary>Skip key-value pairs with keys less than or equal to the key provided.</summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual void Skip(K key)
 {
     if (HasNext())
     {
         while (cmp.Compare(khead, key) <= 0 && Next())
         {
         }
     }
 }
Example #2
0
 /// <summary>Skip key-value pairs with keys less than or equal to the key provided.</summary>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 internal override void Skip(K key)
 {
     if (HasNext())
     {
         while (cmp.Compare(Key(), key) <= 0 && Next())
         {
         }
     }
 }
Example #3
0
            public virtual int Compare(int i, int j)
            {
                int ii = indices[i];
                int ij = indices[j];

                return(comparator.Compare(bytes, offsets[ii], ((ii + 1 == indices.Length) ? eob :
                                                               offsets[ii + 1]) - offsets[ii], bytes, offsets[ij], ((ij + 1 == indices.Length) ?
                                                                                                                    eob : offsets[ij + 1]) - offsets[ij]));
            }
Example #4
0
        /// <summary>Pass skip key to child RRs.</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void Skip(K key)
        {
            AList <ComposableRecordReader <K, object> > tmp = new AList <ComposableRecordReader <K
                                                                                                 , object> >();

            while (!q.IsEmpty() && cmp.Compare(q.Peek().Key(), key) <= 0)
            {
                tmp.AddItem(q.Poll());
            }
            foreach (ComposableRecordReader <K, object> rr in tmp)
            {
                rr.Skip(key);
                if (rr.HasNext())
                {
                    q.AddItem(rr);
                }
            }
        }
        /// <summary>
        /// Instead of filling the JoinCollector with iterators from all
        /// data sources, fill only the rightmost for this key.
        /// </summary>
        /// <remarks>
        /// Instead of filling the JoinCollector with iterators from all
        /// data sources, fill only the rightmost for this key.
        /// This not only saves space by discarding the other sources, but
        /// it also emits the number of key-value pairs in the preferred
        /// RecordReader instead of repeating that stream n times, where
        /// n is the cardinality of the cross product of the discarded
        /// streams for the given key.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        protected internal override void FillJoinCollector(K iterkey)
        {
            PriorityQueue <ComposableRecordReader <K, object> > q = GetRecordReaderQueue();

            if (q != null && !q.IsEmpty())
            {
                int highpos = -1;
                AList <ComposableRecordReader <K, object> > list = new AList <ComposableRecordReader <
                                                                                  K, object> >(kids.Length);
                q.Peek().Key(iterkey);
                WritableComparator cmp = GetComparator();
                while (0 == cmp.Compare(q.Peek().Key(), iterkey))
                {
                    ComposableRecordReader <K, object> t = q.Poll();
                    if (-1 == highpos || list[highpos].Id() < t.Id())
                    {
                        highpos = list.Count;
                    }
                    list.AddItem(t);
                    if (q.IsEmpty())
                    {
                        break;
                    }
                }
                ComposableRecordReader <K, object> t_1 = list.Remove(highpos);
                t_1.Accept(jc, iterkey);
                foreach (ComposableRecordReader <K, object> rr in list)
                {
                    rr.Skip(iterkey);
                }
                list.AddItem(t_1);
                foreach (ComposableRecordReader <K, object> rr_1 in list)
                {
                    if (rr_1.HasNext())
                    {
                        q.AddItem(rr_1);
                    }
                }
            }
        }
 private int Compare(WritableComparator writableComparator, MemoryStream buf1, MemoryStream buf2)
 {
     return(writableComparator.Compare(buf1.GetBuffer(), 0, buf1.Capacity, buf2.GetBuffer(), 0, buf2.Capacity));
 }