private void BuildDisplay(NeoDatis.Btree.IBTreeNode node, int currentHeight, int childIndex, object parentId, bool withIds) { if (currentHeight > lines.Length - 1) { return; } // get string buffer of this line System.Text.StringBuilder line = lines[currentHeight]; if (withIds) { line.Append(node.GetId()).Append(":["); } else { line.Append("["); } for (int i = 0; i < node.GetNbKeys(); i++) { if (i > 0) { line.Append(" , "); } NeoDatis.Btree.IKeyAndValue kav = node.GetKeyAndValueAt(i); line.Append(kav.GetKey()); } if (withIds) { line.Append("]:").Append(node.GetParentId()).Append("/").Append(parentId).Append( " "); } else { line.Append("] "); } for (int i = 0; i < node.GetNbChildren(); i++) { NeoDatis.Btree.IBTreeNode child = node.GetChildAt(i, false); if (child != null) { BuildDisplay(child, currentHeight + 1, i, node.GetId(), withIds); } else { lines[currentHeight + 1].Append("[Child " + (i + 1) + " null!] "); } } }
public override void SetParent(NeoDatis.Btree.IBTreeNode node) { parent = node; if (parent != null) { if (parent.GetId() == null) { btree.GetPersister().SaveNode(parent); } parentOid = (NeoDatis.Odb.OID)parent.GetId(); } else { parentOid = null; } }
public override void SetChildAt(NeoDatis.Btree.IBTreeNode child, int index) { if (child != null) { if (child.GetId() == null) { btree.GetPersister().SaveNode(child); } childrenOids[index] = (NeoDatis.Odb.OID)child.GetId(); child.SetParent(this); } else { childrenOids[index] = null; } }
/// <summary> /// saves the bree node Only puts the current node in an 'modified Node' map /// to be saved on commit /// </summary> public virtual object SaveNode(NeoDatis.Btree.IBTreeNode node) { NeoDatis.Odb.OID oid = null; // Here we only save the node if it does not have id, // else we just save into the hashmap if (node.GetId() == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant .NullObjectId) { try { nbSaveNodes++; // 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 (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("Saved node id " + oid); } // + " : " + // node.toString()); if (tree != null && node.GetBTree() == null) { node.SetBTree(tree); } oids.Add(oid, node); return(oid); } catch (System.Exception e) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError .AddParameter("While saving node"), e); } } nbSaveNodesInCache++; oid = (NeoDatis.Odb.OID)node.GetId(); oids.Add(oid, node); AddModifiedOid(oid); return(oid); }
private int IndexOfChild(NeoDatis.Btree.IBTreeNode parent, NeoDatis.Btree.IBTreeNode child) { for (int i = 0; i < parent.GetNbChildren(); i++) { if (parent.GetChildAt(i, true).GetId() == child.GetId()) { return(i); } } throw new System.Exception("parent " + parent + " does not have the specified child : " + child); }