private void BuildDisplay(IBTreeNode node, int currentHeight, object parentId, bool withIds) { if (currentHeight > _lines.Length - 1) { return; } // get string buffer of this line var line = _lines[currentHeight]; if (withIds) { line.Append(node.GetId()).Append(":["); } else { line.Append("["); } for (var i = 0; i < node.GetNbKeys(); i++) { if (i > 0) { line.Append(" , "); } var keyAndValue = node.GetKeyAndValueAt(i); line.Append(keyAndValue.GetKey()); } if (withIds) { line.Append("]:").Append(node.GetParentId()).Append("/").Append(parentId).Append(" "); } else { line.Append("] "); } for (var i = 0; i < node.GetNbChildren(); i++) { var child = node.GetChildAt(i, false); if (child != null) { BuildDisplay(child, currentHeight + 1, node.GetId(), withIds); } else { _lines[currentHeight + 1].Append(string.Concat("[Child {0} null!] ", (i + 1).ToString())); } } }
public override void SetChildAt(IBTreeNode child, int index) { if (child != null) { if (child.GetId() == null) Btree.GetPersister().SaveNode(child); _childrenOids[index] = (OID) child.GetId(); child.SetParent(this); } else { _childrenOids[index] = null; } }
public override void SetParent(IBTreeNode node) { _parent = node; if (_parent != null) { if (_parent.GetId() == null) Btree.GetPersister().SaveNode(_parent); _parentOid = (OID) _parent.GetId(); } else { _parentOid = null; } }
public override void SetChildAt(IBTreeNode child, int index) { if (child != null) { if (child.GetId() == null) { Btree.GetPersister().SaveNode(child); } _childrenOids[index] = (OID)child.GetId(); child.SetParent(this); } else { _childrenOids[index] = null; } }
public override void SetParent(IBTreeNode node) { _parent = node; if (_parent != null) { if (_parent.GetId() == null) { Btree.GetPersister().SaveNode(_parent); } _parentOid = (OID)_parent.GetId(); } else { _parentOid = null; } }
/// <summary> /// saves the bree node Only puts the current node in an 'modified Node' map to be saved on commit /// </summary> public void SaveNode(IBTreeNode node) { OID oid; // Here we only save the node if it does not have id, // else we just save into the hashmap if (node.GetId() == StorageEngineConstant.NullObjectId) { try { // first get the oid. : -2:it could be any value oid = _engine.GetObjectWriter().GetIdManager().GetNextObjectId(-2); node.SetId(oid); oid = _engine.Store(oid, node); if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Format("LazyOdbBtreePersister: Saved node id {0}", oid)); } // + " : " + // node.toString()); if (_tree != null && node.GetBTree() == null) { node.SetBTree(_tree); } _oids.Add(oid, node); return; } catch (Exception e) { throw new OdbRuntimeException(BTreeError.InternalError.AddParameter("While saving node"), e); } } oid = (OID)node.GetId(); _oids.Add(oid, node); AddModifiedOid(oid); }
private static int IndexOfChild(IBTreeNode parent, IBTreeNode child) { for (var i = 0; i < parent.GetNbChildren(); i++) { if (parent.GetChildAt(i, true).GetId().Equals(child.GetId())) { return(i); } } var errorMessage = string.Format("parent {0} does not have the specified child : {1}", parent, child); throw new OdbRuntimeException(NDatabaseError.InternalError.AddParameter(errorMessage)); }
private void BuildDisplay(IBTreeNode node, int currentHeight, object parentId, bool withIds) { if (currentHeight > _lines.Length - 1) return; // get string buffer of this line var line = _lines[currentHeight]; if (withIds) line.Append(node.GetId()).Append(":["); else line.Append("["); for (var i = 0; i < node.GetNbKeys(); i++) { if (i > 0) line.Append(" , "); var keyAndValue = node.GetKeyAndValueAt(i); line.Append(keyAndValue.GetKey()); } if (withIds) line.Append("]:").Append(node.GetParentId()).Append("/").Append(parentId).Append(" "); else line.Append("] "); for (var i = 0; i < node.GetNbChildren(); i++) { var child = node.GetChildAt(i, false); if (child != null) BuildDisplay(child, currentHeight + 1, node.GetId(), withIds); else _lines[currentHeight + 1].Append(string.Concat("[Child {0} null!] ", (i + 1).ToString())); } }
/// <summary> /// saves the bree node Only puts the current node in an 'modified Node' map to be saved on commit /// </summary> public void SaveNode(IBTreeNode node) { OID oid; // Here we only save the node if it does not have id, // else we just save into the hashmap if (node.GetId() == StorageEngineConstant.NullObjectId) { try { // first get the oid. : -2:it could be any value oid = _engine.GetObjectWriter().GetIdManager().GetNextObjectId(-2); node.SetId(oid); oid = _engine.Store(oid, node); if (OdbConfiguration.IsLoggingEnabled()) DLogger.Debug(string.Format("LazyOdbBtreePersister: Saved node id {0}", oid)); // + " : " + // node.toString()); if (_tree != null && node.GetBTree() == null) node.SetBTree(_tree); _oids.Add(oid, node); return; } catch (Exception e) { throw new OdbRuntimeException(BTreeError.InternalError.AddParameter("While saving node"), e); } } oid = (OID) node.GetId(); _oids.Add(oid, node); AddModifiedOid(oid); }