public override IOdbList <string> GetAllInvolvedFields () { IEnumerator iterator = criteria.GetEnumerator(); ICriterion criterion = null; IOdbList <string> fields = new OdbArrayList <string>(10); while (iterator.MoveNext()) { criterion = (ICriterion)iterator.Current; IOdbList <string> l = criterion.GetAllInvolvedFields(); // check duplicate for (int i = 0; i < l.Count; i++) { string f = l.Get(i); if (!fields.Contains(f)) { fields.Add(f); } } } return(fields); }
public virtual System.Collections.Generic.IDictionary <string, object> GetHistory( ) { System.Collections.Generic.IDictionary <string, object> map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <string, object>(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = null; System.Collections.Generic.IEnumerator <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo > iterator = allClassInfos.GetEnumerator(); while (iterator.MoveNext()) { ci = iterator.Current; map.Add(ci.GetFullClassName(), ci.GetHistory()); } return(map); }
/// <summary>Adds a write action to the transaction</summary> /// <param name="writeAction">The write action to be added</param> /// <param name="persistWriteAcion">To indicate if write action must be persisted</param> public virtual void AddWriteAction(NeoDatis.Odb.Core.Transaction.IWriteAction writeAction , bool persistWriteAcion) { if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Info("Adding WA in Transaction of session " + session.GetId ()); } if (writeAction.IsEmpty()) { return; } CheckRollback(); if (!hasBeenPersisted && persistWriteAcion) { Persist(); } if (persistWriteAcion) { writeAction.Persist(fsi, numberOfWriteActions + 1); } // Only adds the writeaction to the list if the transaction keeps all in // memory if (hasAllWriteActionsInMemory) { writeActions.Add(writeAction); } numberOfWriteActions++; if (hasAllWriteActionsInMemory && numberOfWriteActions > NeoDatis.Odb.OdbConfiguration .GetMaxNumberOfWriteObjectPerTransaction()) { hasAllWriteActionsInMemory = false; System.Collections.IEnumerator iterator = writeActions.GetEnumerator(); NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction wa = null; while (iterator.MoveNext()) { wa = (NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction)iterator.Current; wa.Clear(); } writeActions.Clear(); if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Info("Number of objects has exceeded the max number " + numberOfWriteActions + "/" + NeoDatis.Odb.OdbConfiguration.GetMaxNumberOfWriteObjectPerTransaction() + ": switching to persistent transaction managment"); } } }
public virtual void Persist() { nbPersist++; if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("persist " + nbPersist + " : Saving " + modifiedObjectOids .Count + " objects - " + GetHashCode()); } NeoDatis.Odb.OID oid = null; int nbCommited = 0; long t0 = 0; long t1 = 0; int i = 0; int size = modifiedObjectOids.Count; System.Collections.IEnumerator iterator = modifiedObjectOidList.GetEnumerator(); while (iterator.MoveNext()) { oid = (NeoDatis.Odb.OID)iterator.Current; if (oid != null) { nbCommited++; try { t0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); object o = oids[oid]; engine.Store(o); t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); } catch (System.Exception e) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError .AddParameter("Error while storing object with oid " + oid), e); } if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("Committing oid " + oid + " | " + i + "/" + size + " | " + (t1 - t0)); } i++; } } if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug(nbCommited + " commits / " + size); } }
private void ManageCommitListenersBefore() { NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer3.ICommitListener > listeners = session.GetStorageEngine().GetCommitListeners(); if (listeners == null || listeners.IsEmpty()) { return; } System.Collections.Generic.IEnumerator <NeoDatis.Odb.Core.Layers.Layer3.ICommitListener > iterator = listeners.GetEnumerator(); NeoDatis.Odb.Core.Layers.Layer3.ICommitListener commitListener = null; while (iterator.MoveNext()) { commitListener = iterator.Current; commitListener.BeforeCommit(); } }
/// <summary>Returns the list of involved fields for this query.</summary> /// <remarks> /// Returns the list of involved fields for this query. List of String /// <pre> /// If query must return sum("value") and field("name"), involvedField will contain "value","name" /// </pre> /// </remarks> public override NeoDatis.Tool.Wrappers.List.IOdbList <string> GetAllInvolvedFields () { NeoDatis.Tool.Wrappers.List.IOdbList <string> l = new NeoDatis.Tool.Wrappers.List.OdbArrayList <string>(); // To check field duplicity System.Collections.Generic.IDictionary <string, string> map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <string, string>(); l.AddAll(base.GetAllInvolvedFields()); if (!l.IsEmpty()) { for (int i = 0; i < l.Count; i++) { map.Add(l[i], l[i]); } } System.Collections.Generic.IEnumerator <NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction > iterator = objectActions.GetEnumerator(); NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction oa = null; string name = null; while (iterator.MoveNext()) { oa = iterator.Current; if (oa.GetType() != typeof(NeoDatis.Odb.Impl.Core.Query.Values.CountAction)) { name = oa.GetAttributeName(); if (!map.ContainsKey(name)) { l.Add(name); map.Add(name, name); } } } if (hasGroupBy) { for (int i = 0; i < groupByFieldList.Length; i++) { name = groupByFieldList[i]; if (!map.ContainsKey(name)) { l.Add(name); map.Add(name, name); } } } if (HasOrderBy()) { for (int i = 0; i < orderByFields.Length; i++) { name = orderByFields[i]; if (!map.ContainsKey(name)) { l.Add(name); map.Add(name, name); } } } map.Clear(); map = null; return(l); }