public static FullTextSegmentInfo DeserializeSegmentInfo(Stream stream) { //var wordPositions = stream.ReadByte() == 1; var fieldCountBytes = new byte[sizeof(int)]; stream.Read(fieldCountBytes, 0, sizeof(int)); var fieldCount = BitConverter.ToInt32(fieldCountBytes, 0); var fieldOffsets = DocumentSerializer.DeserializeUlongLongDic(stream, fieldCount).ToDictionary(x => x.Key, y => y.Value); var versionBytes = new byte[sizeof(long)]; stream.Read(versionBytes, 0, sizeof(long)); var docCountBytes = new byte[sizeof(int)]; stream.Read(docCountBytes, 0, sizeof(int)); var compression = new byte[sizeof(int)]; stream.Read(compression, 0, sizeof(int)); var postingsOffsetBytes = new byte[sizeof(long)]; stream.Read(postingsOffsetBytes, 0, sizeof(long)); var docHashOffsetBytes = new byte[sizeof(long)]; stream.Read(docHashOffsetBytes, 0, sizeof(long)); var docAddressesOffsetBytes = new byte[sizeof(long)]; stream.Read(docAddressesOffsetBytes, 0, sizeof(long)); var keyIndexOffsetBytes = new byte[sizeof(long)]; stream.Read(keyIndexOffsetBytes, 0, sizeof(long)); var keyIndexSizeBytes = new byte[sizeof(int)]; stream.Read(keyIndexSizeBytes, 0, sizeof(int)); var lenBytes = new byte[sizeof(long)]; stream.Read(lenBytes, 0, sizeof(long)); var pkFnLenBytes = new byte[sizeof(int)]; stream.Read(pkFnLenBytes, 0, sizeof(int)); if (!BitConverter.IsLittleEndian) { Array.Reverse(pkFnLenBytes); } var pkFnLen = BitConverter.ToInt32(pkFnLenBytes, 0); var pkFieldNameBytes = new byte[pkFnLen]; if (pkFnLen > 0) { stream.Read(pkFieldNameBytes, 0, pkFieldNameBytes.Length); } if (!BitConverter.IsLittleEndian) { Array.Reverse(versionBytes); Array.Reverse(docCountBytes); Array.Reverse(compression); Array.Reverse(postingsOffsetBytes); Array.Reverse(docHashOffsetBytes); Array.Reverse(docAddressesOffsetBytes); Array.Reverse(pkFieldNameBytes); Array.Reverse(keyIndexOffsetBytes); Array.Reverse(keyIndexSizeBytes); Array.Reverse(lenBytes); } var postingsOffset = BitConverter.ToInt64(postingsOffsetBytes, 0); var docHashOffset = BitConverter.ToInt64(docHashOffsetBytes, 0); var docAddressesOffset = BitConverter.ToInt64(docAddressesOffsetBytes, 0); var keyIndexOffset = BitConverter.ToInt64(keyIndexOffsetBytes, 0); var keyIndexSize = BitConverter.ToInt32(keyIndexSizeBytes, 0); return(new FullTextSegmentInfo { Version = BitConverter.ToInt64(versionBytes, 0), DocumentCount = BitConverter.ToInt32(docCountBytes, 0), Compression = (Compression)BitConverter.ToInt32(compression, 0), PrimaryKeyFieldName = Encoding.GetString(pkFieldNameBytes), PostingsOffset = postingsOffset, DocHashOffset = docHashOffset, DocAddressesOffset = docAddressesOffset, FieldOffsets = fieldOffsets, KeyIndexOffset = keyIndexOffset, KeyIndexSize = keyIndexSize, Length = BitConverter.ToInt64(lenBytes, 0), }); }