Example #1
0
 public override string ToString()
 {
     return(String.Format("Sent: {0} @ {1}/s; Recv: {2} @ {3}/s;",
                          Format.ByteCount(BytesUploaded),
                          Format.ByteCount(UploadSpeed),
                          Format.ByteCount(BytesDownloaded),
                          Format.ByteCount(DownloadSpeed)));
 }
Example #2
0
        /// <summary>
        /// Expert: Construct a direct <seealso cref="Reader"/> from a stream without reading
        /// metadata at the beginning of the stream. this method is useful to restore
        /// data from streams which have been created using
        /// <seealso cref="PackedInts#getWriterNoHeader(DataOutput, Format, int, int, int)"/>.
        /// </p><p>
        /// The returned reader will have very little memory overhead, but every call
        /// to <seealso cref="Reader#get(int)"/> is likely to perform a disk seek.
        /// </summary>
        /// <param name="in">           the stream to read data from </param>
        /// <param name="format">       the format used to serialize </param>
        /// <param name="version">      the version used to serialize the data </param>
        /// <param name="valueCount">   how many values the stream holds </param>
        /// <param name="bitsPerValue"> the number of bits per value </param>
        /// <returns> a direct Reader
        /// @lucene.internal </returns>
        public static Reader GetDirectReaderNoHeader(IndexInput @in, Format format, int version, int valueCount, int bitsPerValue)
        {
            CheckVersion(version);

            if (format == PackedInts.Format.PACKED_SINGLE_BLOCK)
            {
                return new DirectPacked64SingleBlockReader(bitsPerValue, valueCount, @in);
            }
            else if (format == PackedInts.Format.PACKED)
            {
                long byteCount = format.ByteCount(version, valueCount, bitsPerValue);
                if (byteCount != format.ByteCount(VERSION_CURRENT, valueCount, bitsPerValue))
                {
                    Debug.Assert(version == VERSION_START);
                    long endPointer = @in.FilePointer + byteCount;
                    // Some consumers of direct readers assume that reading the last value
                    // will make the underlying IndexInput go to the end of the packed
                    // stream, but this is not true because packed ints storage used to be
                    // long-aligned and is now byte-aligned, hence this additional
                    // condition when reading the last value
                    return new DirectPackedReaderAnonymousInnerClassHelper(bitsPerValue, valueCount, @in, endPointer);
                }
                else
                {
                    return new DirectPackedReader(bitsPerValue, valueCount, @in);
                }
            }
            else
            {
                throw new InvalidOperationException("Unknwown format: " + format);
            }
        }