Example #1
0
        /// <exception cref="System.IO.IOException"/>
        private long WriteRecords(int count, bool knownKeyLength, bool knownValueLength,
                                  bool close)
        {
            long rawDataSize = 0;

            for (int nx = 0; nx < count; nx++)
            {
                string           key    = TestTFileByteArrays.ComposeSortedKey("key", nx);
                DataOutputStream outKey = writer.PrepareAppendKey(knownKeyLength ? key.Length : -
                                                                  1);
                outKey.Write(Runtime.GetBytesForString(key));
                outKey.Close();
                string           value    = "value" + nx;
                DataOutputStream outValue = writer.PrepareAppendValue(knownValueLength ? value.Length
                                         : -1);
                outValue.Write(Runtime.GetBytesForString(value));
                outValue.Close();
                rawDataSize += WritableUtils.GetVIntSize(Runtime.GetBytesForString(key).Length
                                                         ) + Runtime.GetBytesForString(key).Length + WritableUtils.GetVIntSize(Runtime.GetBytesForString
                                                                                                                                   (value).Length) + Runtime.GetBytesForString(value).Length;
            }
            if (close)
            {
                CloseOutput();
            }
            return(rawDataSize);
        }
Example #2
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void TestOneEntryKnownLength()
 {
     if (skip)
     {
         return;
     }
     WriteRecords(1, true, true);
     TestTFileByteArrays.ReadRecords(fs, path, 1, conf);
 }
Example #3
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void TestNoEntry()
 {
     if (skip)
     {
         return;
     }
     CloseOutput();
     TestTFileByteArrays.ReadRecords(fs, path, 0, conf);
 }
Example #4
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void TestTwoEntriesKnownLength()
 {
     if (skip)
     {
         return;
     }
     WriteRecords(2, true, true);
     TestTFileByteArrays.ReadRecords(fs, path, 2, conf);
 }
Example #5
0
 // unknown key length, known value length
 /// <exception cref="System.IO.IOException"/>
 public virtual void TestOneEntryMixedLengths2()
 {
     if (skip)
     {
         return;
     }
     WriteRecords(1, false, true);
     TestTFileByteArrays.ReadRecords(fs, path, 1, conf);
 }
Example #6
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void TestOneEntryUnknownLength()
 {
     if (skip)
     {
         return;
     }
     WriteRecords(1, false, false);
     // TODO: will throw exception at getValueLength, it's inconsistent though;
     // getKeyLength returns a value correctly, though initial length is -1
     TestTFileByteArrays.ReadRecords(fs, path, 1, conf);
 }