public BasePipe(TransactionService transaction, IDocumentLookup lookup, SortDisk tempDisk, EnginePragmas pragmas) { _transaction = transaction; _lookup = lookup; _tempDisk = tempDisk; _pragmas = pragmas; }
/// <summary> /// Load page content based on page buffer /// </summary> public void LoadPage() { // check database file format var info = _buffer.ReadString(P_HEADER_INFO, HEADER_INFO.Length); var ver = _buffer[P_FILE_VERSION]; if (string.CompareOrdinal(info, HEADER_INFO) != 0 || ver != FILE_VERSION) { throw LiteException.InvalidDatabase(); } // CreateTime is readonly this.FreeEmptyPageList = _buffer.ReadUInt32(P_FREE_EMPTY_PAGE_ID); this.LastPageID = _buffer.ReadUInt32(P_LAST_PAGE_ID); // initialize engine pragmas this.Pragmas = new EnginePragmas(_buffer, this); // create new buffer area to store BsonDocument collections var area = _buffer.Slice(P_COLLECTIONS, COLLECTIONS_SIZE); using (var r = new BufferReader(new[] { area }, false)) { _collections = r.ReadDocument(); } _isCollectionsChanged = false; }
public FileReaderV7(Stream stream, string password) { _stream = stream; // only userVersion was avaiable in old file format versions _header = this.ReadPage(0); this.Pragmas = new EnginePragmas(null); this.Pragmas.Set("USER_VERSION", _header["userVersion"], true); if (password == null && _header["salt"].AsBinary.IsFullZero() == false) { throw new LiteException(0, "Current data file requires password"); } else if (password != null) { if (_header["salt"].AsBinary.IsFullZero()) { throw new LiteException(0, "Current data file has no encryption - do not use password"); } var hash = AesEncryption.HashSHA1(password); if (hash.SequenceEqual(_header["password"].AsBinary) == false) { throw new LiteException(0, "Invalid password"); } } _aes = password == null ? null : new AesEncryption(password, _header["salt"].AsBinary); }
/// <summary> /// Select corrent pipe /// </summary> public BasePipe GetPipe(TransactionService transaction, Snapshot snapshot, EnginePragmas pragmas) { //if (this.GroupBy == null) { return(new QueryPipe(transaction, this.GetLookup(snapshot, pragmas), pragmas)); } //else { // return new GroupByPipe(transaction, this.GetLookup(snapshot, pragmas), tempDisk, pragmas); } }
public SortDisk(IStreamFactory factory, int containerSize, EnginePragmas pragmas) { ENSURE(containerSize % PAGE_SIZE == 0, "size must be PAGE_SIZE multiple"); _factory = factory; _containerSize = containerSize; _pragmas = pragmas; _lastContainerPosition = -containerSize; _pool = new Lazy <StreamPool>(() => new StreamPool(_factory, false)); }
public FileReaderV8(HeaderPage header, DiskService disk) { // get a copy of pragmas this.Pragmas = new EnginePragmas(header.UpdateBuffer(), header); _collections = header.GetCollections().ToDictionary(x => x.Key, x => x.Value); // using writer stream from pool (no need to return) _stream = disk.GetPool(FileOrigin.Data).Writer; _buffer = BufferPool.Rent(PAGE_SIZE); }
public SortService(SortDisk disk, int order, EnginePragmas pragmas) { _disk = disk; _order = order; _pragmas = pragmas; _containerSize = disk.ContainerSize; _reader = new Lazy <Stream>(() => _disk.GetReader()); var bytes = BufferPool.Rent(disk.ContainerSize); _buffer = new BufferSlice(bytes, 0, _containerSize); }
public QueryExecutor(LiteEngine engine, EnginePragmas pragmas, string collection, Query query, IEnumerable <BsonDocument> source) { _engine = engine; _pragmas = pragmas; _collection = collection; _query = query; _cursor = new CursorInfo(collection, query); LOG(_query.ToSQL(_collection).Replace(Environment.NewLine, " "), "QUERY"); // source will be != null when query will run over external data source, like system collections or files (not user collection) _source = source; }
/// <summary> /// Create new Header Page /// </summary> public HeaderPage(PageBuffer buffer, uint pageID) : base(buffer, 0, PageType.Header) { // initialize page version this.CreationTime = DateTime.UtcNow; this.FreeEmptyPageList = uint.MaxValue; this.LastPageID = 0; // initialize pragmas this.Pragmas = new EnginePragmas(this); // writing direct into buffer in Ctor() because there is no change later (write once) _buffer.Write(HEADER_INFO, P_HEADER_INFO); _buffer.Write(FILE_VERSION, P_FILE_VERSION); _buffer.Write(this.CreationTime, P_CREATION_TIME); // initialize collections _collections = new BsonDocument(); }
/// <summary> /// Get corrent IDocumentLookup /// </summary> public IDocumentLookup GetLookup(Snapshot snapshot, EnginePragmas pragmas) { var data = new DataService(snapshot); var indexer = new IndexService(snapshot, pragmas.Collation); // define document loader // if index are VirtualIndex - it's also lookup document if (!(this.Index is IDocumentLookup lookup)) { if (this.IsIndexKeyOnly) { lookup = new IndexLookup(indexer, this.Fields.Single()); } else { lookup = new DatafileLookup(data, pragmas.UtcDate, this.Fields); } } return(lookup); }
public BasePipe(TransactionService transaction, IDocumentLookup lookup, EnginePragmas pragmas) { _transaction = transaction; _lookup = lookup; _pragmas = pragmas; }
public QueryPipe(TransactionService transaction, IDocumentLookup loader, SortDisk tempDisk, EnginePragmas pragmas) : base(transaction, loader, tempDisk, pragmas) { }
internal LockService(EnginePragmas pragmas) { _pragmas = pragmas; }
internal LockService(EnginePragmas variables, bool @readonly) { _variables = variables; _readonly = @readonly; }