当前位置: 首页>>代码示例>>C#>>正文


C# Format.ByteCount方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:48,代码来源:PackedInts.cs


注:本文中的Format.ByteCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。