Exemplo n.º 1
0
        public bool Store(PropertyDatabaseRecord record, bool sync)
        {
            using (LockUpgradeableRead())
            {
                var foundRecord = Find(record.recordKey, out var index);
                var insert      = true;
                if (foundRecord)
                {
                    var oldRecord = m_StoreData[(int)index];
                    if (oldRecord.IsValid())
                    {
                        return(false);
                    }
                    insert = false;
                }

                using (LockWrite())
                {
                    if (insert)
                    {
                        m_StoreData.Insert((int)index, record);
                    }
                    else
                    {
                        m_StoreData[(int)index] = record;
                    }
                    return(true);
                }
            }
        }
Exemplo n.º 2
0
 void InvalidateRange(BinarySearchRange binarySearchRange)
 {
     using (LockWrite())
     {
         for (var i = binarySearchRange.startOffset; i < binarySearchRange.endOffset; ++i)
         {
             var record    = m_StoreData[(int)i];
             var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
             m_StoreData[(int)i] = newRecord;
         }
     }
 }
Exemplo n.º 3
0
 void InvalidateMaskRange(BinarySearchRange binarySearchRange, ulong documentKeyMask)
 {
     using (LockWrite())
     {
         for (var i = binarySearchRange.startOffset; i < binarySearchRange.endOffset; ++i)
         {
             var record = m_StoreData[(int)i];
             if ((record.key.documentKey & documentKeyMask) != 0)
             {
                 var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
                 m_StoreData[(int)i] = newRecord;
             }
         }
     }
 }
Exemplo n.º 4
0
 public bool Store(PropertyDatabaseRecord record)
 {
     {
         if (!record.recordValue.valid)
         {
             return(false);
         }
         var success = m_MemoryStoreView.Store(record, !m_DelayedSync);
         if (success)
         {
             m_PropertyDatabase.StoresChanged();
         }
         return(success);
     }
 }
Exemplo n.º 5
0
 void InvalidateRange(BinarySearchRange binarySearchRange, bool sync)
 {
     using (LockWrite())
     {
         for (var i = binarySearchRange.startOffset; i < binarySearchRange.endOffset; ++i)
         {
             var record    = GetRecord(i);
             var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
             WriteRecord(newRecord, i, false);
         }
         if (sync)
         {
             Sync();
         }
     }
 }
Exemplo n.º 6
0
        PropertyDatabaseRecord GetRecord(long index)
        {
            if (m_Fs == null)
            {
                return(new PropertyDatabaseRecord());
            }
            if (index < 0 || index >= length)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var fileOffset = GetFileOffset((int)index);

            m_Fs.Seek(fileOffset, SeekOrigin.Begin);
            return(PropertyDatabaseRecord.FromBinary(m_Br));
        }
Exemplo n.º 7
0
        public void Invalidate(PropertyDatabaseRecordKey recordKey, bool sync)
        {
            using (LockUpgradeableRead())
            {
                var foundRecord = Find(recordKey, out var index);
                if (!foundRecord)
                {
                    return;
                }

                using (LockWrite())
                {
                    var record    = m_StoreData[(int)index];
                    var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
                    m_StoreData[(int)index] = newRecord;
                }
            }
        }
Exemplo n.º 8
0
 void InvalidateMaskRange(BinarySearchRange binarySearchRange, ulong documentKeyMask, bool sync)
 {
     using (LockWrite())
     {
         for (var i = binarySearchRange.startOffset; i < binarySearchRange.endOffset; ++i)
         {
             var record = GetRecord(i);
             if ((record.key.documentKey & documentKeyMask) != 0)
             {
                 var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
                 WriteRecord(newRecord, i, false);
             }
         }
         if (sync)
         {
             Sync();
         }
     }
 }
Exemplo n.º 9
0
        void WriteRecord(PropertyDatabaseRecord record, long index, bool flush = true)
        {
            if (m_Fs == null)
            {
                return;
            }
            if (index < 0 || index >= length)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var fileOffset = GetFileOffset((int)index);

            m_Bw.Seek(fileOffset, SeekOrigin.Begin);
            record.ToBinary(m_Bw);

            if (flush)
            {
                m_Fs.Flush(true);
            }
        }
Exemplo n.º 10
0
        public PropertyDatabaseMemoryStore ToMemoryStore()
        {
            using (LockRead())
            {
                if (length == 0)
                {
                    return(new PropertyDatabaseMemoryStore());
                }

                var localStore = new List <PropertyDatabaseRecord>((int)length);

                for (var i = 0; i < length; ++i)
                {
                    m_Fs.Seek(GetFileOffset(i), SeekOrigin.Begin);
                    var record = PropertyDatabaseRecord.FromBinary(m_Br);
                    localStore.Add(record);
                }

                return(new PropertyDatabaseMemoryStore(localStore));
            }
        }
        public bool Store(PropertyDatabaseRecord record, bool sync)
        {
            using (LockUpgradeableRead())
            {
                var  foundRecord = Find(record.recordKey, out var index);
                bool insert      = !foundRecord;

                using (LockWrite())
                {
                    if (insert)
                    {
                        m_StoreData.Insert((int)index, record);
                    }
                    else
                    {
                        m_StoreData[(int)index] = record;
                    }
                    return(true);
                }
            }
        }
Exemplo n.º 12
0
        public void Invalidate(PropertyDatabaseRecordKey recordKey, bool sync)
        {
            using (LockUpgradeableRead())
            {
                if (m_Fs == null)
                {
                    return;
                }
                var foundRecord = Find(recordKey, out var index);
                if (!foundRecord)
                {
                    return;
                }

                using (LockWrite())
                {
                    var record    = GetRecord(index);
                    var newRecord = new PropertyDatabaseRecord(record.recordKey, record.recordValue, false);
                    WriteRecord(newRecord, index, sync);
                }
            }
        }
Exemplo n.º 13
0
 public bool Store(PropertyDatabaseRecord record, bool sync)
 {
     // Cannot add anything in this store
     throw new NotSupportedException();
 }
Exemplo n.º 14
0
 public bool Store(PropertyDatabaseRecord record)
 {
     using (var view = GetView())
         return(view.Store(record, true));
 }
Exemplo n.º 15
0
 public bool Store(PropertyDatabaseRecord record, bool sync)
 {
     throw new NotSupportedException();
 }