예제 #1
0
 /// <summary>Return true iff the tuple is full (all data sources contain this key).</summary>
 protected internal override bool Combine(object[] srcs, TupleWritable dst)
 {
     System.Diagnostics.Debug.Assert(srcs.Length == dst.Size());
     for (int i = 0; i < srcs.Length; ++i)
     {
         if (!dst.Has(i))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
 public virtual bool IsCompatible(TupleWritable that)
 {
     if (this.Size() != that.Size())
     {
         return(false);
     }
     for (int i = 0; i < values.Length; ++i)
     {
         if (Has(i) != that.Has(i))
         {
             return(false);
         }
         if (Has(i) && !values[i].Equals(that.Get(i)))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #3
0
        /// <summary>Tests that we can write more than 64 values.</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestWideTupleBoundary()
        {
            Text emptyText = new Text("Should not be set written");

            Writable[] values = new Writable[65];
            Arrays.Fill(values, emptyText);
            values[64] = new Text("Should be the only value set written");
            TupleWritable tuple = new TupleWritable(values);

            tuple.SetWritten(64);
            for (int pos = 0; pos < tuple.Size(); pos++)
            {
                bool has = tuple.Has(pos);
                if (pos == 64)
                {
                    NUnit.Framework.Assert.IsTrue(has);
                }
                else
                {
                    NUnit.Framework.Assert.IsFalse("Tuple position is incorrectly labelled as set: "
                                                   + pos, has);
                }
            }
        }
예제 #4
0
        /// <exception cref="System.Exception"/>
        public virtual void TestWideTuple2()
        {
            Text emptyText = new Text("Should be empty");

            Writable[] values = new Writable[64];
            Arrays.Fill(values, emptyText);
            values[9] = new Text("Number 9");
            TupleWritable tuple = new TupleWritable(values);

            tuple.SetWritten(9);
            for (int pos = 0; pos < tuple.Size(); pos++)
            {
                bool has = tuple.Has(pos);
                if (pos == 9)
                {
                    NUnit.Framework.Assert.IsTrue(has);
                }
                else
                {
                    NUnit.Framework.Assert.IsFalse("Tuple position is incorrectly labelled as set: "
                                                   + pos, has);
                }
            }
        }
예제 #5
0
 /// <summary>Emit everything from the collector.</summary>
 protected internal override bool Combine(object[] srcs, TupleWritable dst)
 {
     System.Diagnostics.Debug.Assert(srcs.Length == dst.Size());
     return(true);
 }