/// <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);
                    }
                }
            }
        }
 /// <summary>
 /// For all child RRs offering the key provided, obtain an iterator
 /// at that position in the JoinCollector.
 /// </summary>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected internal virtual void FillJoinCollector(K iterkey)
 {
     if (!q.IsEmpty())
     {
         q.Peek().Key(iterkey);
         while (0 == cmp.Compare(q.Peek().Key(), iterkey))
         {
             ComposableRecordReader <K, object> t = q.Poll();
             t.Accept(jc, iterkey);
             if (t.HasNext())
             {
                 q.AddItem(t);
             }
             else
             {
                 if (q.IsEmpty())
                 {
                     return;
                 }
             }
         }
     }
 }
Example #3
0
 /// <summary>
 /// Implement Comparable contract (compare key at head of proxied RR
 /// with that of another).
 /// </summary>
 public override int CompareTo(ComposableRecordReader <K, object> other)
 {
     return(cmp.Compare(Key(), other.Key()));
 }
Example #4
0
 public abstract int CompareTo(ComposableRecordReader <K, object> arg1);
 public int Compare(ComposableRecordReader <K, object> o1, ComposableRecordReader <K
                                                                                   , object> o2)
 {
     return(this._enclosing.cmp.Compare(o1.Key(), o2.Key()));
 }
 /// <summary>Add a RecordReader to this collection.</summary>
 /// <remarks>
 /// Add a RecordReader to this collection.
 /// The id() of a RecordReader determines where in the Tuple its
 /// entry will appear. Adding RecordReaders with the same id has
 /// undefined behavior.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public virtual void Add(ComposableRecordReader <K, V> rr)
 {
     kids[rr.Id()] = rr;
 }