예제 #1
0
        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));
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 private void ReadPrevLogNumber(Slice slice)
 {
     m_prevLogNumber    = Coding.DecodeVarint64(slice);
     m_hasPrevLogNumber = true;
 }
예제 #4
0
 private void ReadDeletedFiled(Slice slice)
 {
     var level  = Coding.DecodeVarint32(slice);
     var fileNr = Coding.DecodeVarint64(slice);
 }
예제 #5
0
 private void ReadCompactPointer(Slice slice)
 {
     var level   = Coding.DecodeVarint32(slice);
     var pointer = Coding.DecodeLengthPrefixed(slice);
 }
예제 #6
0
 private void ReadLastSequence(Slice slice)
 {
     m_lastSequence    = Coding.DecodeVarint64(slice);
     m_hasLastSequence = true;
 }
예제 #7
0
 private void ReadNextFileNumber(Slice slice)
 {
     m_nextFileNumber    = Coding.DecodeVarint64(slice);
     m_hasNextFileNumber = true;
 }
예제 #8
0
 private void ReadLogNumber(Slice slice)
 {
     m_logNumber    = Coding.DecodeVarint64(slice);
     m_hasLogNumber = true;
 }