public static Footer DecodeFrom(Slice slice) { uint startOffset = slice.Offset; uint startLength = slice.Length; uint magic_lo = Coding.DecodeFixed32(slice.NewSlice(kEncodedLength - 8, 4)); uint magic_hi = Coding.DecodeFixed32(slice.NewSlice(kEncodedLength - 4, 4)); ulong magic = (unchecked ((ulong)magic_hi) << 32) | unchecked ((ulong)magic_lo); if (magic != kTableMagicNumber) { throw new Exception("not an sstable (bad magic number)"); } var metaIndexHandle = BlockHandle.DecodeFrom(slice); var indexHandle = BlockHandle.DecodeFrom(slice); slice.Update(startOffset + kEncodedLength, startLength - kEncodedLength); return(new Footer(metaIndexHandle, indexHandle)); }
public void Add(Record record) { var actionDict = new Action <Slice>[] { Error, ReadComparator, ReadLogNumber, ReadNextFileNumber, ReadLastSequence, ReadCompactPointer, ReadDeletedFiled, ReadNewFile, Error, ReadPrevLogNumber, }; var slice = new Slice(record.Bytes); while (slice.Length > 0) { var type = Coding.DecodeVarint32(slice); actionDict[type].Invoke(slice); } }
private void ReadPrevLogNumber(Slice slice) { m_prevLogNumber = Coding.DecodeVarint64(slice); m_hasPrevLogNumber = true; }
private void ReadDeletedFiled(Slice slice) { var level = Coding.DecodeVarint32(slice); var fileNr = Coding.DecodeVarint64(slice); }
private void ReadCompactPointer(Slice slice) { var level = Coding.DecodeVarint32(slice); var pointer = Coding.DecodeLengthPrefixed(slice); }
private void ReadLastSequence(Slice slice) { m_lastSequence = Coding.DecodeVarint64(slice); m_hasLastSequence = true; }
private void ReadNextFileNumber(Slice slice) { m_nextFileNumber = Coding.DecodeVarint64(slice); m_hasNextFileNumber = true; }
private void ReadLogNumber(Slice slice) { m_logNumber = Coding.DecodeVarint64(slice); m_hasLogNumber = true; }