Beispiel #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestCoding()
        {
            string before = "Bad \t encoding \t testcase";

            Org.Apache.Hadoop.IO.Text text = new Org.Apache.Hadoop.IO.Text(before);
            string after = text.ToString();

            Assert.True(before.Equals(after));
            for (int i = 0; i < NumIterations; i++)
            {
                // generate a random string
                if (i == 0)
                {
                    before = GetLongString();
                }
                else
                {
                    before = GetTestString();
                }
                // test string to utf8
                ByteBuffer bb       = Org.Apache.Hadoop.IO.Text.Encode(before);
                byte[]     utf8Text = ((byte[])bb.Array());
                byte[]     utf8Java = Runtime.GetBytesForString(before, "UTF-8");
                Assert.Equal(0, WritableComparator.CompareBytes(utf8Text, 0, bb
                                                                .Limit(), utf8Java, 0, utf8Java.Length));
                // test utf8 to string
                after = Org.Apache.Hadoop.IO.Text.Decode(utf8Java);
                Assert.True(before.Equals(after));
            }
        }
Beispiel #2
0
 /// <summary>Compares this object with the specified object for order.</summary>
 public virtual int CompareTo(Org.Apache.Hadoop.IO.MD5Hash that)
 {
     return(WritableComparator.CompareBytes(this.digest, 0, Md5Len, that.digest, 0, Md5Len
                                            ));
 }
Beispiel #3
0
 public virtual int CompareTo(Org.Apache.Hadoop.IO.RandomDatum o)
 {
     return(WritableComparator.CompareBytes(this.data, 0, this.length, o.data, 0, o.length
                                            ));
 }