本文整理汇总了C#中Format.ByteCount方法的典型用法代码示例。如果您正苦于以下问题:C# Format.ByteCount方法的具体用法?C# Format.ByteCount怎么用?C# Format.ByteCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Format
的用法示例。
在下文中一共展示了Format.ByteCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectReaderNoHeader
/// <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);
}
}