Esempio n. 1
0
        InsertResult <JSONDocument> IDocumentStore.InsertDocument(InsertOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            InsertResult <JSONDocument> result = new InsertResult <JSONDocument>();
            CacheItem citem = new CacheItem();

            citem.Document = operation.Document;
            citem.Flag.SetBit(BitsetConstants.DocumentDirty);
            citem.Flag.SetBit(BitsetConstants.MetaDataDirty);
            citem.Flag.UnsetBit(BitsetConstants.MarkedForDeletion);

            CacheInsert(operation.RowId, citem, false);
            _indexManager.AddToIndex(operation.RowId, operation.Document, operation.OperationId);

            _parent.MetadataIndex.Add(new DocumentKey(operation.Document.Key), operation.RowId, operation.Document, operation.Context);

            PersistenceOperation persistenceOperation = new PersistenceInsertOperation(operation.OperationId, _parent.Name, operation.RowId, citem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            result.RowId = operation.RowId;

            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgInsertTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.InsertsPerSec);
            }
            return(result);
        }