Beispiel #1
0
        /// <summary>
        /// Creates the alias to this entry and returnes data which can be used to aliasing the target.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <returns>
        /// Alias data fro the newly created aliases.
        /// </returns>
        public AliasData CreateAliasToEntry(Snapshot snapshot)
        {
            //Collect alias indexes
            AssignCollector indexesCollector = new AssignCollector(snapshot);

            indexesCollector.ProcessPath(path);

            //Memory locations where to get data from
            ReadCollector valueCollector = new ReadCollector(snapshot);

            valueCollector.ProcessPath(path);

            //Get data from locations
            ReadWorker  worker = new ReadWorker(snapshot);
            MemoryEntry value  = worker.ReadValue(valueCollector);

            //Makes deep copy of data to prevent changes after assign alias
            TemporaryIndex            temporaryIndex = snapshot.CreateTemporary();
            MergeWithinSnapshotWorker mergeWorker    = new MergeWithinSnapshotWorker(snapshot);

            mergeWorker.MergeMemoryEntry(temporaryIndex, value);

            AliasData data = new AliasData(indexesCollector.MustIndexes, indexesCollector.MayIndexes, temporaryIndex);

            data.TemporaryIndexToRealease(temporaryIndex);

            return(data);
        }
Beispiel #2
0
        /// <summary>
        /// Determines whether this index is part of acces path of the other index.
        /// </summary>
        /// <param name="otherIndex">Index of the other.</param>
        /// <returns>
        /// True whether this index is prefix of the given one.
        /// </returns>
        internal override bool IsPrefixOf(MemoryIndex otherIndex)
        {
            TemporaryIndex tempIndex = otherIndex as TemporaryIndex;

            if (tempIndex != null)
            {
                return(rootId.Equals(tempIndex.rootId) && base.IsPrefixOf(otherIndex));
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            TemporaryIndex otherIndex = obj as TemporaryIndex;

            if (otherIndex != null)
            {
                return(rootId.Equals(otherIndex.rootId) && base.Equals(obj));
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets the snapshot entry of temporary index associated with this memory entry.
        /// </summary>
        /// <param name="context">The context.</param>
        private SnapshotEntry getTemporary(SnapshotBase context)
        {
            Snapshot snapshot = SnapshotEntry.ToSnapshot(context);

            if (temporaryLocation == null)
            {
                temporaryIndex = snapshot.CreateTemporary();
                MergeWithinSnapshotWorker mergeWorker = new MergeWithinSnapshotWorker(snapshot);
                mergeWorker.MergeMemoryEntry(temporaryIndex, dataEntry);

                temporaryLocation = new SnapshotEntry(MemoryPath.MakePathTemporary(temporaryIndex));
            }

            return(temporaryLocation);
        }
Beispiel #5
0
        /// <summary>
        /// Writes the memory normal.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="value">The value.</param>
        /// <param name="forceStrongWrite">if set to <c>true</c> [force strong write].</param>
        private void writeMemoryNormal(Snapshot snapshot, MemoryEntry value, bool forceStrongWrite)
        {
            TemporaryIndex            temporaryIndex = snapshot.CreateTemporary();
            MergeWithinSnapshotWorker mergeWorker    = new MergeWithinSnapshotWorker(snapshot);

            mergeWorker.MergeMemoryEntry(temporaryIndex, value);

            AssignCollector collector = new AssignCollector(snapshot);

            collector.ProcessPath(path);

            if (forceStrongWrite)
            {
                collector.SetAllToMust();
            }

            AssignWorker worker = new AssignWorker(snapshot);

            worker.Assign(collector, temporaryIndex);

            snapshot.ReleaseTemporary(temporaryIndex);
        }
Beispiel #6
0
 /// <summary>
 /// Sets the temporary index which can be released using Release method.
 /// </summary>
 /// <param name="temporaryIndex">Temporary index to realease.</param>
 internal void TemporaryIndexToRealease(TemporaryIndex temporaryIndex)
 {
     this.temporaryIndex = temporaryIndex;
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryPathSegment"/> class.
 /// </summary>
 /// <param name="temporaryIndex">Index of the temporary.</param>
 public TemporaryPathSegment(TemporaryIndex temporaryIndex)
     : base(true)
 {
     this.TemporaryIndex = temporaryIndex;
 }
Beispiel #8
0
 /// <summary>
 /// Makes the path to temporary memory location.
 /// </summary>
 /// <param name="temporaryIndex">Index of the temporary.</param>
 /// <returns>New path to temporary memory location</returns>
 public static MemoryPath MakePathTemporary(TemporaryIndex temporaryIndex)
 {
     return(new MemoryPath(new TemporaryPathSegment(temporaryIndex), GlobalContext.LocalOnly, temporaryIndex.CallLevel));
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryIndex"/> class.
 /// </summary>
 /// <param name="parentIndex">Index of the parent.</param>
 /// <param name="callLevel">The call level.</param>
 public TemporaryIndex(TemporaryIndex parentIndex, int callLevel)
     : base(parentIndex.MemoryPath, callLevel)
 {
     rootId = parentIndex.rootId;
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryIndex"/> class.
 /// </summary>
 /// <param name="parentIndex">Index of the parent.</param>
 /// <param name="path">The path.</param>
 public TemporaryIndex(TemporaryIndex parentIndex, List <IndexSegment> path)
     : base(path, parentIndex.CallLevel)
 {
     rootId = parentIndex.rootId;
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryIndex"/> class.
 /// </summary>
 /// <param name="parentIndex">Index of the parent.</param>
 /// <param name="pathName">Name of the path.</param>
 public TemporaryIndex(TemporaryIndex parentIndex, IndexSegment pathName)
     : base(parentIndex, pathName)
 {
     rootId = parentIndex.rootId;
 }