Exemplo n.º 1
0
 public TreeSystemStack(TreeSystemTransaction ts)
 {
     this.ts = ts;
     stackSize = 0;
     stack = new long[StackFrameSize*13];
     currentLeaf = null;
     currentLeafKey = null;
     leafOffset = 0;
 }
            internal DataFile(TreeSystemTransaction transaction, Key key, bool fileReadOnly)
            {
                stack = new TreeSystemStack(transaction);
                this.transaction = transaction;
                this.key = key;
                p = 0;

                version = -1;
                this.fileReadOnly = fileReadOnly;
                start = -1;
                end = -1;
            }
Exemplo n.º 3
0
        private long WriteVersionsList(long versionId, TreeSystemTransaction tran)
        {
            // Write the version info and the deleted refs to a new area,
            long rootNodeId = tran.RootNodeId;
            if (rootNodeId < 0)
                throw new ApplicationException("Assertion failed, root_node is on heap.");

            // Get the list of all nodes deleted in the transaction
            IList<long> deletedNodes = tran.DeletedNodes;

            // Sort it
            ((List<long>)deletedNodes).Sort();

            // Check for any duplicate entries (we shouldn't double delete stuff).
            for (int i = 1; i < deletedNodes.Count; ++i) {
                if (deletedNodes[i - 1] == deletedNodes[i]) {
                    // Oops, duplicated delete
                    throw new ApplicationException("Duplicate records in delete list.");
                }
            }

            long verId = WriteVersionInfo(versionId, rootNodeId, deletedNodes);

            // Now update the version list by copying the list and adding the new ref
            // to the end.

            // Get the current version list
            IMutableArea headerArea = store.GetMutableArea(headerId);
            headerArea.Position = 8;
            long versionListId = headerArea.ReadInt8();

            // Read information from the old version info,
            IArea verListArea = store.GetArea(versionListId);
            verListArea.ReadInt4();  // The magic
            int versionCount = verListArea.ReadInt4();

            // Create a new list,
            IAreaWriter newVerListArea = store.CreateArea(8 + (8 * (versionCount + 1)));
            newVerListArea.WriteInt4(0x01433);
            newVerListArea.WriteInt4(versionCount + 1);
            for (int i = 0; i < versionCount; ++i) {
                newVerListArea.WriteInt8(verListArea.ReadInt8());
            }
            newVerListArea.WriteInt8(verId);
            newVerListArea.Finish();

            // Write the new area to the header,
            headerArea.Position = 8;
            headerArea.WriteInt8(newVerListArea.Id);

            // Delete the old version list Area,
            store.DeleteArea(versionListId);

            // Done,
            return verId;
        }
Exemplo n.º 4
0
 public PlaceholderLeaf(TreeSystemTransaction ts, NodeId nodeId, int size)
 {
     this.ts = ts;
     this.nodeId = nodeId;
     this.size = size;
 }
Exemplo n.º 5
0
        private long WriteVersionsList(long versionId, TreeSystemTransaction tran)
        {
            lock (this) {
                // Write the version info and the deleted refs to a new area,
                NodeId rootNodeId = tran.RootNodeId;
                if (rootNodeId.IsInMemory)
                    throw new ApplicationException("Assertion failed, root_node is on heap.");

                // Get the list of all nodes deleted in the transaction
                List<NodeId> deletedRefs = tran.NodeDeletes;
                    // Sort it
                    deletedRefs.Sort();
                    // Check for any duplicate entries (we shouldn't double delete stuff).
                    for (int i = 1; i < deletedRefs.Count; ++i) {
                        if (deletedRefs[i - 1].Equals(deletedRefs[i])) {
                            // Oops, duplicated delete
                            throw new ApplicationException("PRAGMATIC_CHECK failed: duplicate records in delete list.");
                        }
                    }

                long theVersionId = WriteSingleVersionInfo(versionId, rootNodeId, deletedRefs);

                // Now update the version list by copying the list and adding the new ref
                // to the end.

                // Get the current version list
                IMutableArea headerArea = nodeStore.GetMutableArea(headerId);
                headerArea.Position = 8;

                long versionListId = headerArea.ReadInt8();

                // Read information from the old version info,
                IArea versionListArea = nodeStore.GetArea(versionListId);
                versionListArea.ReadInt4(); // The magic
                int versionCount = versionListArea.ReadInt4();

                // Create a new list,
                IAreaWriter newVersionList = nodeStore.CreateArea(8 + (8*(versionCount + 1)));
                newVersionList.WriteInt4(0x01433);
                newVersionList.WriteInt4(versionCount + 1);
                for (int i = 0; i < versionCount; ++i) {
                    newVersionList.WriteInt8(versionListArea.ReadInt8());
                }
                newVersionList.WriteInt8(theVersionId);
                newVersionList.Finish();

                // Write the new area to the header,
                headerArea.Position = 8;
                headerArea.WriteInt8(newVersionList.Id);

                // Delete the old version list Area,
                nodeStore.DeleteArea(versionListId);

                // Done,
                return theVersionId;
            }
        }