예제 #1
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static int GetInitialPhysicalSize(Key *key, Input *input)
 {
     return
         (RecordInfo.GetLength() +
          Key.GetLength(default(Key *)) +
          Functions.InitialValueLength(key, input));
 }
예제 #2
0
        private void RecoverFromPage(long startRecoveryAddress,
                                     long fromLogicalAddressInPage,
                                     long untilLogicalAddressInPage,
                                     long pageLogicalAddress,
                                     long pagePhysicalAddress,
                                     int version)
        {
            var hash        = default(long);
            var tag         = default(ushort);
            var pointer     = default(long);
            var recordStart = default(long);
            var bucket      = default(HashBucket *);
            var entry       = default(HashBucketEntry);
            var slot        = default(int);

            pointer = fromLogicalAddressInPage;
            while (pointer < untilLogicalAddressInPage)
            {
                recordStart = pagePhysicalAddress + pointer;
                ref RecordInfo info = ref hlog.GetInfo(recordStart);

                if (info.IsNull())
                {
                    pointer += RecordInfo.GetLength();
                    continue;
                }

                if (!info.Invalid)
                {
                    hash = comparer.GetHashCode64(ref hlog.GetKey(recordStart));
                    tag  = (ushort)((ulong)hash >> Constants.kHashTagShift);

                    entry = default(HashBucketEntry);
                    FindOrCreateTag(hash, tag, ref bucket, ref slot, ref entry, hlog.BeginAddress);

                    if (info.Version <= version)
                    {
                        entry.Address   = pageLogicalAddress + pointer;
                        entry.Tag       = tag;
                        entry.Pending   = false;
                        entry.Tentative = false;
                        bucket->bucket_entries[slot] = entry.word;
                    }
                    else
                    {
                        info.Invalid = true;
                        if (info.PreviousAddress < startRecoveryAddress)
                        {
                            entry.Address   = info.PreviousAddress;
                            entry.Tag       = tag;
                            entry.Pending   = false;
                            entry.Tentative = false;
                            bucket->bucket_entries[slot] = entry.word;
                        }
                    }
                }
                pointer += hlog.GetRecordSize(recordStart);
            }
예제 #3
0
        public override int GetRequiredRecordSize(long physicalAddress, int availableBytes)
        {
            // We need at least [record size] + [average key size] + [average value size]
            var reqBytes = GetAverageRecordSize();

            if (availableBytes < reqBytes)
            {
                return(reqBytes);
            }

            // We need at least [record size] + [actual key size] + [average value size]
            reqBytes = RecordInfo.GetLength() + KeySize(physicalAddress) + ValueLength.GetAverageLength();
            if (availableBytes < reqBytes)
            {
                return(reqBytes);
            }

            // We need at least [record size] + [actual key size] + [actual value size]
            reqBytes = RecordInfo.GetLength() + KeySize(physicalAddress) + ValueSize(physicalAddress);
            return(reqBytes);
        }
 private long ValueOffset(long physicalAddress)
 => physicalAddress + RecordInfo.GetLength() + AlignedKeySize(physicalAddress);
예제 #5
0
 public override AddressInfo *GetValueAddressInfo(long physicalAddress)
 {
     return((AddressInfo *)((byte *)physicalAddress + RecordInfo.GetLength() + keySize));
 }
예제 #6
0
 public override AddressInfo *GetKeyAddressInfo(long physicalAddress)
 {
     return((AddressInfo *)((byte *)physicalAddress + RecordInfo.GetLength()));
 }
예제 #7
0
 public override int GetRecordSize(long physicalAddress)
 {
     return(RecordInfo.GetLength() +
            KeySize(physicalAddress) + ValueSize(physicalAddress));
 }
예제 #8
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static Value *GetValue(long physicalAddress)
 {
     return((Value *)((byte *)physicalAddress + RecordInfo.GetLength() + Key.GetLength(default(Key *))));
 }
예제 #9
0
 public override int GetInitialRecordSize <Input>(ref Key key, ref Input input)
 {
     return(RecordInfo.GetLength() +
            KeyLength.GetLength(ref key) +
            ValueLength.GetInitialLength(ref input));
 }
예제 #10
0
 public override int GetAverageRecordSize()
 {
     return(RecordInfo.GetLength() +
            KeyLength.GetAverageLength() +
            ValueLength.GetAverageLength());
 }
예제 #11
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static int GetAveragePhysicalSize()
 {
     return(RecordInfo.GetLength() + Key.GetLength(default(Key *)) + Value.GetLength(default(Value *)));
 }
예제 #12
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static int EstimatePhysicalSize(Key *key, Value *value)
 {
     return(RecordInfo.GetLength() + Key.GetLength(key) + Value.GetLength(value));
 }
예제 #13
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static int GetPhysicalSize(long physicalAddress)
 {
     return(RecordInfo.GetLength() + Key.GetLength(default(Key *)) + Value.GetLength(default(Value *)));
 }
예제 #14
0
 public override ref Key GetKey(long physicalAddress)
 {
     return(ref Unsafe.AsRef <Key>((byte *)physicalAddress + RecordInfo.GetLength()));
 }
예제 #15
0
 public override int GetRecordSize(ref Key key, ref Value value)
 {
     return(RecordInfo.GetLength() +
            KeyLength.GetLength(ref key) +
            ValueLength.GetLength(ref value));
 }
예제 #16
0
 public override ref Value GetValue(long physicalAddress)
 {
     return(ref Unsafe.AsRef <Value>((byte *)physicalAddress + RecordInfo.GetLength() + KeySize(physicalAddress)));
 }
예제 #17
0
파일: Layout.cs 프로젝트: willsmythe/FASTER
 public static Key *GetKey(long physicalAddress)
 {
     return((Key *)((byte *)physicalAddress + RecordInfo.GetLength()));
 }