Esempio n. 1
0
        /// <summary>
        /// Creates the snapshot contexts.
        /// </summary>
        private void createSnapshotContexts()
        {
            foreach (Snapshot sourceSnapshot in sourceSnapshots)
            {
                SnapshotContext context = new SnapshotContext(sourceSnapshot);
                context.SourceStructure    = sourceSnapshot.Structure.Readonly;
                context.SourceData         = sourceSnapshot.CurrentData.Readonly;
                context.CallLevel          = sourceSnapshot.CallLevel;
                context.ChangedIndexesTree = new MemoryIndexTree();

                snapshotContexts.Add(context);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Collects the structure changes and find ancestor.
        /// </summary>
        /// <returns></returns>
        private IReadonlyChangeTracker <IReadOnlySnapshotStructure> collectStructureChangesAndFindAncestor()
        {
            SnapshotContext ancestorContext = snapshotContexts[0];
            IReadonlyChangeTracker <IReadOnlySnapshotStructure> ancestor = ancestorContext.SourceStructure.ReadonlyChangeTracker;

            List <MemoryIndexTree> changes = new List <MemoryIndexTree>();

            changes.Add(snapshotContexts[0].ChangedIndexesTree);
            for (int x = 1; x < snapshotContexts.Count; x++)
            {
                SnapshotContext context        = snapshotContexts[x];
                MemoryIndexTree currentChanges = context.ChangedIndexesTree;
                changes.Add(currentChanges);

                ancestor = getFirstCommonAncestor(context.SourceStructure.ReadonlyChangeTracker, ancestor, currentChanges, changes);
            }

            return(ancestor);
        }
Esempio n. 3
0
        /// <summary>
        /// Processes the merge operation.
        /// </summary>
        /// <param name="operation">The operation.</param>
        private void processMergeOperation(MergeOperation operation)
        {
            MemoryIndex targetIndex            = operation.TargetIndex;
            var         targetIndexDatasources = targetSnapshot.MergeInfo.GetOrCreateDatasourcesContaier(targetIndex);

            // Iterate sources
            foreach (MergeOperationContext operationContext in operation.Indexes)
            {
                // Retreive source context and definition
                MemoryIndex      sourceIndex      = operationContext.Index;
                SnapshotContext  context          = operationContext.SnapshotContext;
                IIndexDefinition sourceDefinition = context.SourceStructure.GetIndexDefinition(sourceIndex);

                // Collect array and aliases data
                arrayWorker.collectSourceArray(targetIndex, operation, operationContext, sourceDefinition.Array);
                aliasWorker.collectSourceAliases(sourceDefinition.Aliases);
                objectWorker.collectSourceObjects(sourceDefinition.Objects);

                // Store datasource for data and info merging
                targetIndexDatasources.SetDatasource(context.SourceSnapshot, sourceIndex);
            }

            IIndexDefinition targetDefinition;

            if (targetStructure.TryGetIndexDefinition(targetIndex, out targetDefinition))
            {
                // Index is set in target snapshot
                if (targetDefinition.Array != null)
                {
                    arrayWorker.SetTargetArray(targetDefinition.Array);
                }
            }
            else
            {
                // Index is not set in target snapshot - create it
                writeableTargetStructure.NewIndex(targetIndex);
            }

            aliasWorker.MergeAliasesAndClear(targetIndex, operation);
            arrayWorker.MergeArraysAndClear(targetSnapshot, targetIndex, operation);
            objectWorker.MergeObjectsAndClear(targetIndex);
        }
Esempio n. 4
0
        /// <summary>
        /// Collects the call structure changes.
        /// </summary>
        /// <param name="callSnapshot">The call snapshot.</param>
        private void collectCallStructureChanges(Snapshot callSnapshot)
        {
            List <MemoryIndexTree> changes = new List <MemoryIndexTree>();
            var ancestor = callSnapshot.Structure.Readonly.ReadonlyChangeTracker;

            for (int x = 0; x < snapshotContexts.Count; x++)
            {
                SnapshotContext context = snapshotContexts[x];

                MemoryIndexTree currentChanges = context.ChangedIndexesTree;
                changes.Add(currentChanges);

                collectSingleFunctionChanges(callSnapshot, context.SourceStructure.ReadonlyChangeTracker, currentChanges, changes);
            }

            if (targetSnapshot.StructureCallChanges != null)
            {
                CollectionMemoryUtils.AddAll(this.changeTree, targetSnapshot.StructureCallChanges);
            }

            targetSnapshot.StructureCallChanges = changeTree.StoredIndexes;
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainerContext"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="indexContainer">The index container.</param>
 /// <param name="operationType">Type of the operation.</param>
 public ContainerContext(SnapshotContext context, IReadonlyIndexContainer indexContainer, MergeOperationType operationType = MergeOperationType.ChangedOnly)
 {
     this.SnapshotContext = context;
     this.IndexContainer  = indexContainer;
     this.OperationType   = operationType;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MergeOperationContext"/> class.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="snapshotContext">The snapshot context.</param>
 /// <param name="operationType">Type of the operation.</param>
 public MergeOperationContext(MemoryIndex index, SnapshotContext snapshotContext, MergeOperationType operationType = MergeOperationType.ChangedOnly)
 {
     this.Index           = index;
     this.SnapshotContext = snapshotContext;
     this.OperationType   = operationType;
 }