Esempio n. 1
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            if(!val.IsString) return false;

            return val.AsString.StartsWith(_value.AsString);
        }
Esempio n. 2
0
        internal override bool ExecuteFullScan(BsonDocument doc)
        {
            var val = doc.Get(this.Field);

            if (!val.IsString)
            {
                return(false);
            }

            return(val.AsString.StartsWith(_value.AsString));
        }
Esempio n. 3
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            if (!val.IsString)
            {
                return(false);
            }

            return(val.AsString.StartsWith(_value.AsString));
        }
Esempio n. 4
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            foreach (var value in _values.Distinct())
            {
                var diff = val.CompareTo(value);

                if (diff == 0) return true;
            }

            return false;
        }
Esempio n. 5
0
        internal override bool ExecuteFullScan(BsonDocument doc)
        {
            var val = doc.Get(this.Field);

            foreach (var value in _values.Distinct())
            {
                var diff = val.CompareTo(value);

                if (diff == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
        private bool UpdateDoc(BsonValue id, BsonDocument doc)
        {
            // serialize object
            var bytes = BsonSerializer.Serialize(doc);

            // start transaction
            this.Database.Transaction.Begin();

            try
            {
                var col = this.GetCollectionPage(false);

                // if no collection, no updates
                if (col == null)
                {
                    this.Database.Transaction.Abort();
                    return(false);
                }

                // find indexNode from pk index
                var indexNode = this.Database.Indexer.Find(col.PK, id, false, Query.Ascending);

                // if not found document, no updates
                if (indexNode == null)
                {
                    this.Database.Transaction.Abort();
                    return(false);
                }

                // update data storage
                var dataBlock = this.Database.Data.Update(col, indexNode.DataBlock, bytes);

                // delete/insert indexes - do not touch on PK
                foreach (var index in col.GetIndexes(false))
                {
                    var key = doc.Get(index.Field);

                    var node = this.Database.Indexer.GetNode(dataBlock.IndexRef[index.Slot]);

                    // check if my index node was changed
                    if (node.Key.CompareTo(key) != 0)
                    {
                        // remove old index node
                        this.Database.Indexer.Delete(index, node.Position);

                        // and add a new one
                        var newNode = this.Database.Indexer.AddNode(index, key);

                        // point my index to data object
                        newNode.DataBlock = dataBlock.Position;

                        // point my dataBlock
                        dataBlock.IndexRef[index.Slot] = newNode.Position;

                        dataBlock.Page.IsDirty = true;
                    }
                }

                this.Database.Transaction.Commit();

                return(true);
            }
            catch
            {
                this.Database.Transaction.Rollback();
                throw;
            }
        }
Esempio n. 7
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            return(val.CompareTo(_value) >= (_equals ? 0 : 1));
        }
Esempio n. 8
0
 internal override bool ExecuteFullScan(BsonDocument doc)
 {
     return(doc.Get(this.Field).CompareTo(_value) <= (_equals ? 0 : -1));
 }
Esempio n. 9
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            return val.CompareTo(_value) != 0;
        }
Esempio n. 10
0
        internal override bool ExecuteFullScan(BsonDocument doc, IndexOptions options)
        {
            var val = doc.Get(this.Field).Normalize(options);

            return(val.CompareTo(_start) >= 0 && val.CompareTo(_end) <= 0);
        }
Esempio n. 11
0
        internal override bool ExecuteFullScan(BsonDocument doc)
        {
            var val = doc.Get(this.Field);

            return(val.CompareTo(_start) >= 0 && val.CompareTo(_end) <= 0);
        }