コード例 #1
0
ファイル: CollectionIndex.cs プロジェクト: zamis/LiteDB
 public void UpdateBuffer(BufferWriter writer)
 {
     writer.Write(this.Slot);
     writer.Write(this.IndexType);
     writer.WriteCString(this.Name);
     writer.WriteCString(this.Expression);
     writer.Write(this.Unique);
     writer.Write(this.Head);
     writer.Write(this.Tail);
     writer.Write(this.MaxLevel);
     writer.Write(this.FreeIndexPageList);
 }
コード例 #2
0
ファイル: CollectionPage.cs プロジェクト: zhb123456789/LiteDB
        public override PageBuffer UpdateBuffer()
        {
            // if page was deleted, do not write in content area (must keep with 0 only)
            if (this.PageType == PageType.Empty)
            {
                return(base.UpdateBuffer());
            }

            var area = _buffer.Slice(PAGE_HEADER_SIZE, PAGE_SIZE - PAGE_HEADER_SIZE);

            using (var w = new BufferWriter(area))
            {
                // read position for FreeDataPage and FreeIndexPage
                for (var i = 0; i < PAGE_FREE_LIST_SLOTS; i++)
                {
                    w.Write(this.FreeDataPageID[i]);
                    w.Write(this.FreeIndexPageID[i]);
                }

                // write creation/last analyzed (16 bytes)
                w.Write(this.CreationTime);
                w.Write(this.LastAnalyzed);

                // update collection only if needed
                if (_isIndexesChanged)
                {
                    // skip reserved area (indexes starts at position 96)
                    w.Skip(P_INDEXES - w.Position);

                    w.Write((byte)_indexes.Count); // 1 byte

                    foreach (var index in _indexes.Values)
                    {
                        w.Write(index.Slot);
                        w.WriteCString(index.Name);
                        w.WriteCString(index.Expression);
                        w.Write(index.Unique);
                        w.Write(index.Head);
                        w.Write(index.Tail);
                        w.Write(index.MaxLevel);
                        w.Write(index.KeyCount);
                        w.Write(index.UniqueKeyCount);
                    }

                    _isIndexesChanged = false;
                }
            }

            return(base.UpdateBuffer());
        }