/// <summary>Loads a node from its id.</summary>
 /// <remarks>
 /// Loads a node from its id. Tries to get if from memory, if not present
 /// then loads it from odb storage
 /// </remarks>
 /// <param name="id">The id of the nod</param>
 /// <returns>The node with the specific id</returns>
 public virtual NeoDatis.Btree.IBTreeNode LoadNodeById(object id)
 {
     NeoDatis.Odb.OID oid = (NeoDatis.Odb.OID)id;
     // Check if node is in memory
     NeoDatis.Btree.IBTreeNode node = (NeoDatis.Btree.IBTreeNode)oids[oid];
     if (node != null)
     {
         nbLoadNodesFromCache++;
         return(node);
     }
     nbLoadNodes++;
     // else load from odb
     try
     {
         if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
         {
             NeoDatis.Tool.DLogger.Debug("Loading node with id " + oid);
         }
         if (oid == null)
         {
             throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InvalidIdForBtree
                                                        .AddParameter(oid));
         }
         NeoDatis.Btree.IBTreeNode pn = (NeoDatis.Btree.IBTreeNode)engine.GetObjectFromOid
                                            (oid);
         pn.SetId(oid);
         if (tree != null)
         {
             pn.SetBTree(tree);
         }
         // Keep the node in memory
         oids.Add(oid, pn);
         return(pn);
     }
     catch (System.Exception e)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError
                                                    , e);
     }
 }
 /// <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);
 }