public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo BuildNnoi
     (object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
     [] values, long[] attributesIdentification, int[] attributeIds, System.Collections.Generic.IDictionary
     <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo> alreadyReadObjects
     )
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                         (o, classInfo, values, attributesIdentification, attributeIds);
     if (storageEngine != null)
     {
         // for unit test purpose
         NeoDatis.Odb.Core.Transaction.ICache cache = storageEngine.GetSession(true).GetCache
                                                          ();
         // Check if object is in the cache, if so sets its oid
         NeoDatis.Odb.OID oid = cache.GetOid(o, false);
         if (oid != null)
         {
             nnoi.SetOid(oid);
             // Sets some values to the new header to keep track of the infos
             // when
             // executing NeoDatis without closing it, just committing.
             // Bug reported by Andy
             NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = cache.GetObjectInfoHeaderFromOid
                                                                             (oid, true);
             nnoi.GetHeader().SetObjectVersion(oih.GetObjectVersion());
             nnoi.GetHeader().SetUpdateDate(oih.GetUpdateDate());
             nnoi.GetHeader().SetCreationDate(oih.GetCreationDate());
         }
     }
     return(nnoi);
 }
Пример #2
0
 public virtual void AddField(string className, System.Type fieldType, string fieldName
                              )
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = storageEngine.GetSession
                                                                    (true).GetMetaModel();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(className
                                                                                , true);
     // The real attribute id (-1) will be set in the ci.addAttribute
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo
                                                                       (-1, fieldName, fieldType.FullName, ci);
     ci.AddAttribute(cai);
     storageEngine.GetObjectWriter().UpdateClassInfo(ci, true);
 }
Пример #3
0
 public virtual void Test1()
 {
     if (!isLocal)
     {
         return;
     }
     DeleteBase("unconnected");
     NeoDatis.Odb.ODB odb = Open("unconnected");
     NeoDatis.Odb.OID oid = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
     odb.Close();
     Println("Oid=" + oid);
     odb = Open("unconnected");
     NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb
                                              .GetObjectFromId(oid);
     f2.SetName("New Function");
     odb.Store(f2);
     NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
     // retrieve the class info to check connected and unconnected zone
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = storageEngine.GetSession(true
                                                                                  ).GetMetaModel().GetClassInfo(typeof(NeoDatis.Odb.Test.VO.Login.Function).FullName
                                                                                                                , true);
     odb.Close();
     AssertEquals(1, ci.GetCommitedZoneInfo().GetNbObjects());
     AssertNotNull(ci.GetCommitedZoneInfo().first);
     AssertNotNull(ci.GetCommitedZoneInfo().last);
     AssertEquals(0, ci.GetUncommittedZoneInfo().GetNbObjects());
     AssertNull(ci.GetUncommittedZoneInfo().first);
     AssertNull(ci.GetUncommittedZoneInfo().last);
     odb = Open("unconnected");
     AssertEquals(1, odb.GetObjects <Function>().Count
                  );
     odb.Close();
 }
Пример #4
0
        public virtual void TestDirectSave()
        {
            if (!isLocal)
            {
                return;
            }
            NeoDatis.Odb.OdbConfiguration.SetSaveHistory(true);
            DeleteBase("btree.neodatis");
            NeoDatis.Odb.ODB odb      = Open("btree.neodatis");
            Function         function = new Function
                                            ("f1");

            odb.Store(function);
            for (int i = 0; i < 2; i++)
            {
                function.SetName(function.GetName() + function.GetName() + function.GetName() + function
                                 .GetName());
                odb.Store(function);
            }
            NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
            if (isLocal)
            {
            }

            NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = engine.GetSession(true).GetMetaModel
                                                                    ().GetClassInfo(typeof(Function).FullName, true);
            Println(ci);
            AssertEquals(null, ci.GetCommitedZoneInfo().first);
            AssertEquals(null, ci.GetCommitedZoneInfo().last);
            AssertEquals(1, ci.GetUncommittedZoneInfo().GetNbObjects());
            odb.Close();
        }
Пример #5
0
 public GenericQueryExecutor(NeoDatis.Odb.Core.Query.IQuery query, NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine
                             engine)
 {
     this.query         = query;
     this.storageEngine = engine;
     this.objectReader  = storageEngine.GetObjectReader();
     this.session       = storageEngine.GetSession(true);
     this.callback      = NeoDatis.Odb.OdbConfiguration.GetQueryExecutorCallback();
     this.executeStartAndEndOfQueryAction = true;
 }
Пример #6
0
 public virtual void Test2B()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.Core.Layers.Layer3.Engine.IByteArrayConverter byteArrayConverter = NeoDatis.Odb.OdbConfiguration
                                                                                     .GetCoreProvider().GetByteArrayConverter();
     DeleteBase("test78.neodatis");
     // 155 : to avoid protected zone
     NeoDatis.Odb.Core.Transaction.IWriteAction wa1 = new NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
                                                          (300 + 1, byteArrayConverter.IntToByteArray(1), "size");
     NeoDatis.Odb.Core.Transaction.IWriteAction wa2 = new NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
                                                          (300 + 15, byteArrayConverter.StringToByteArray(" 1 - ol√° chico! - 1", true, -1
                                                                                                          , true), "name");
     NeoDatis.Odb.Core.Transaction.IWriteAction wa3 = new NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
                                                          (300 + 1, byteArrayConverter.IntToByteArray(2), "size");
     NeoDatis.Odb.Core.Transaction.IWriteAction wa4 = new NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
                                                          (300 + 15, byteArrayConverter.StringToByteArray(" 2 - ol√° chico! - 2", true, -1
                                                                                                          , true), "name");
     NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine se = NeoDatis.Odb.OdbConfiguration
                                                         .GetCoreProvider().GetClientStorageEngine(new NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter
                                                                                                       (NeoDatis.Odb.Test.ODBTest.Directory + "test78.neodatis", true, null, null));
     // se.close();
     NeoDatis.Odb.Core.Layers.Layer3.Engine.IFileSystemInterface fsi = se.GetObjectWriter
                                                                           ().GetFsi();
     // new FileSystemInterface(null,se.getSession(),new
     // IOFileParameter("test.neodatis",true),false,Configuration.getDefaultBufferSizeForData());
     NeoDatis.Odb.Core.Transaction.ITransaction transaction = se.GetSession(true).GetTransaction
                                                                  ();
     transaction.SetArchiveLog(true);
     transaction.ManageWriteAction(wa1.GetPosition(), wa1.GetBytes(0));
     transaction.ManageWriteAction(wa2.GetPosition(), wa2.GetBytes(0));
     transaction.ManageWriteAction(wa3.GetPosition(), wa3.GetBytes(0));
     transaction.ManageWriteAction(wa4.GetPosition(), wa4.GetBytes(0));
     // transaction.getFsi().flush();
     NeoDatis.Odb.Core.Transaction.IWriteAction wat1 = (NeoDatis.Odb.Core.Transaction.IWriteAction
                                                        )((NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction)transaction).GetWriteActions
                                                           ()[2];
     byte[] bytes = wat1.GetBytes(0);
     transaction.Commit();
     NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction transaction2 = NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction
                                                                          .Read(NeoDatis.Odb.Test.ODBTest.Directory + transaction.GetName());
     NeoDatis.Odb.Core.Transaction.IWriteAction wat2 = (NeoDatis.Odb.Core.Transaction.IWriteAction
                                                        )transaction2.GetWriteActions()[2];
     AssertEquals(NeoDatis.Tool.DisplayUtility.ByteArrayToString(bytes), NeoDatis.Tool.DisplayUtility
                  .ByteArrayToString(wat2.GetBytes(0)));
     AssertEquals(wat1.GetPosition(), wat2.GetPosition());
     transaction2.Rollback();
     fsi.Close();
     DeleteBase("test78.neodatis");
     DeleteBase(transaction.GetName());
 }
Пример #7
0
 public virtual void Info(object o)
 {
     if (i % 20 == 0)
     {
         if (engine != null)
         {
             System.Console.Out.WriteLine(engine.GetSession(true).GetCache().ToString());
         }
     }
     System.Console.Out.WriteLine(o);
     i++;
 }
Пример #8
0
 /// <summary>
 /// Used to check if object must be reconnected to current session
 /// <pre>
 /// An object must be reconnected to session if OdbConfiguration.reconnectObjectsToSession() is true
 /// and object is not in local cache and is in cross session cache.
 /// </summary>
 /// <remarks>
 /// Used to check if object must be reconnected to current session
 /// <pre>
 /// An object must be reconnected to session if OdbConfiguration.reconnectObjectsToSession() is true
 /// and object is not in local cache and is in cross session cache. In this case
 /// we had it to local cache
 /// </pre>
 /// </remarks>
 /// <param name="@object"></param>
 private void CheckIfObjectMustBeReconnected(object @object)
 {
     if (engine == null)
     {
         // This protection is for JUnit
         return;
     }
     NeoDatis.Odb.Core.Transaction.ISession session = engine.GetSession(true);
     // If object is in local cache, no need to reconnect it
     if (session.GetCache().ExistObject(@object))
     {
         return;
     }
     NeoDatis.Odb.OID oidCrossSession = crossSessionCache.GetOid(@object);
     if (oidCrossSession != null)
     {
         // reconnect object
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = engine.GetObjectInfoHeaderFromOid
                                                                         (oidCrossSession);
         session.AddObjectToCache(oidCrossSession, @object, oih);
     }
 }
Пример #9
0
 public LocalInstanceBuilder(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine
                             ) : base(engine)
 {
     this.session = engine.GetSession(true);
 }
Пример #10
0
        public virtual void Test1WithoutCommit()
        {
            if (!runAll)
            {
                return;
            }
            NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch();
            stopWatch.Start();
            int size        = 10000;
            int size2       = 5000;
            int nbFunctions = 10;

            DeleteBase(FileName);
            NeoDatis.Odb.ODB odb = Open(FileName);
            Function         f1  = new Function(
                "function 1");

            // Create Objects
            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number "
                                                                                              + i, f1);
                for (int j = 0; j < nbFunctions; j++)
                {
                    p.AddFunction(new Function(" inner function of profile : number "
                                               + i + " - " + j));
                }
                User user = new User("user name "
                                     + i, "user email " + i, p);
                odb.Store(user);
            }
            Println("created");
            // Updates 10 times the objects
            NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>();
            for (int k = 0; k < 10; k++)
            {
                objects.Reset();
                for (int i = 0; i < size2; i++)
                {
                    User user = (User)objects.Next
                                    ();
                    user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
                    odb.Store(user);
                }
            }
            Println("updated");
            // Delete the rest of the objects
            for (int i = size2; i < size; i++)
            {
                odb.Delete(objects.Next());
            }
            Println("deleted");
            // Check object count
            objects = odb.GetObjects <User>();
            AssertEquals(size2, objects.Count);
            // Check data of the objects
            int a = 0;

            while (objects.HasNext())
            {
                User user = (User)objects.Next
                                ();
                AssertEquals("user name " + a, user.GetName());
                AssertEquals("user email " + a, user.GetEmail());
                AssertEquals("profile number " + a + "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated"
                             , user.GetProfile().GetName());
                a++;
            }
            Println("checked");
            for (int k = 0; k < 10; k++)
            {
                objects.Reset();
                for (int i = 0; i < size2; i++)
                {
                    User user = (User)objects.Next
                                    ();
                    user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
                    odb.Store(user);
                }
            }
            Println("re-updated");
            objects = odb.GetObjects <User>();
            NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo uncommited = engine.GetSession(true
                                                                                           ).GetMetaModel().GetClassInfo(typeof(User).FullName,
                                                                                                                         true).GetUncommittedZoneInfo();
            NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo commited = engine.GetSession(true
                                                                                         ).GetMetaModel().GetClassInfo(typeof(User).FullName,
                                                                                                                       true).GetCommitedZoneInfo();
            Println("Before commit : uncommited=" + uncommited);
            Println("Before commit : commited=" + commited);
            a = 0;
            while (objects.HasNext())
            {
                // println("a="+a);
                odb.Delete(objects.Next());
                a++;
            }
            AssertEquals(size2, a);
            AssertEquals(0, odb.GetObjects <User>().Count);
            AssertEquals(0, odb.Count(new CriteriaQuery(typeof(User))));
            Println("deleted");
            odb.Close();
            stopWatch.End();
            Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds());
            if (stopWatch.GetDurationInMiliseconds() > 108438)
            {
                Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds());
            }
        }
Пример #11
0
 public virtual NeoDatis.Odb.Core.Transaction.ISession GetSession()
 {
     return(storageEngine.GetSession(true));
 }
Пример #12
0
 public LocalObjectWriter(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine) :
     base(engine)
 {
     this.session = engine.GetSession(true);
 }
Пример #13
0
        public virtual void TestInsertUserODB()
        {
            DeleteBase(OdbFileName);
            long t1;
            long t2;
            long t3;
            long t4;
            long t5;
            long t6;
            long t7;
            long t77;
            long t8;

            t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            NeoDatis.Odb.ODB odb = Open(OdbFileName);
            for (int i = 0; i < TestSize; i++)
            {
                object o = GetUserInstance();
                odb.Store(o);
                if (i % 1000 == 0)
                {
                    System.Console.Out.Write(".");
                }
            }
            t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // assertEquals(TEST_SIZE,
            // odb.getSession().getCache().getNumberOfObjects ());
            NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
            if (isLocal)
            {
                Println("NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                            ());
            }
            odb.Commit();
            t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            Println("end of insert");
            NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(false);
            t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            int nbObjects = l.Count;

            Println(nbObjects + " objects ");
            User user = null;

            while (l.HasNext())
            {
                // println(i);
                user = (User)l.Next();
            }
            // assertEquals(TEST_SIZE,
            // odb.getSession().getCache().getNumberOfObjects ());
            Println("end of real get objects");
            t5   = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            user = null;
            int j = 0;

            l.Reset();
            while (l.HasNext())
            {
                // println(i);
                user = (User)l.Next();
                user.SetName(user.GetName() + " updated" + j);
                odb.Store(user);
                j++;
            }
            t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            Println("end of update");
            odb.Close();
            t7  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = Open(OdbFileName);
            l   = odb.GetObjects <User>();
            t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            j   = 0;
            while (l.HasNext())
            {
                user = (User)l.Next();
                Println(j + " " + user.GetName());
                AssertTrue(user.GetName().EndsWith("updated" + j));
                odb.Delete(user);
                j++;
            }
            odb.Close();
            t8  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = Open(OdbFileName);
            AssertEquals(0, odb.GetObjects <User>().Count);
            odb.Close();
            DisplayResult("ODB " + TestSize + " User objects ", t1, t2, t3, t4, t5, t6, t7, t77
                          , t8);
            DeleteBase(OdbFileName);
        }
Пример #14
0
        public virtual void TestInsertSimpleObjectODB()
        {
            DeleteBase(OdbFileName);
            long t1  = 0;
            long t2  = 0;
            long t3  = 0;
            long t4  = 0;
            long t5  = 0;
            long t6  = 0;
            long t7  = 0;
            long t77 = 0;
            long t8  = 0;

            NeoDatis.Odb.ODB odb = null;
            NeoDatis.Odb.Objects <SimpleObject> l = null;
            SimpleObject so = null;

            t1  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = Open(OdbFileName);
            for (int i = 0; i < TestSize; i++)
            {
                object o = GetSimpleObjectInstance(i);
                odb.Store(o);
                if (i % 20000 == 0)
                {
                    System.Console.Out.Write(".");
                    Println("After insert=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine
                                (odb).GetSession(true).GetCache().ToString());
                }
            }
            //
            NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
                                                                    .GetEngine(odb);
            if (isLocal)
            {
                // println("NB WA="+WriteAction.count);
                Println("NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                            ());
            }
            t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb.Commit();
            if (isLocal)
            {
                Println("after commit : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                            ());
            }
            // if(true)return;
            // println("After commit="+Dummy.getEngine(odb).getSession().getCache().toString());
            // println("NB WA="+WriteAction.count);
            t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // println("end of insert");
            l = odb.GetObjects <SimpleObject>(false);
            // println("end of getObjects ");
            t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            // println("After getObjects ="+Dummy.getEngine(odb).getSession().getCache().toString());
            // println("NB WA="+WriteAction.count);
            if (isLocal)
            {
                Println("after select : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                            ());
            }
            int nbObjects = l.Count;

            Println(nbObjects + " objects ");
            int k = 0;

            while (l.HasNext())
            {
                object o = l.Next();
                if (k % 9999 == 0)
                {
                    Println(((SimpleObject)o).GetName());
                }
                k++;
            }
            // println("end of real get ");
            t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            Println("select " + (t5 - t3) + " - " + (t5 - t4));
            so = null;
            k  = 0;
            l.Reset();
            while (l.HasNext())
            {
                so = (SimpleObject)l.Next();
                so.SetName(so.GetName() + " updated");
                odb.Store(so);
                if (k % 10000 == 0)
                {
                    Println("update " + k);
                    if (isLocal)
                    {
                        Println("after update : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                                    ());
                        Println("After update=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine
                                    (odb).GetSession(true).GetCache().ToString());
                    }
                }
                k++;
            }
            if (isLocal)
            {
                Println("after update : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions
                            ());
            }
            t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb.Close();
            t7  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = Open(OdbFileName);
            l   = odb.GetObjects <SimpleObject>(false);
            t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            int j = 0;

            while (l.HasNext())
            {
                so = (SimpleObject)l.Next();
                AssertTrue(so.GetName().EndsWith("updated"));
                odb.Delete(so);
                if (j % 10000 == 0)
                {
                    Println("delete " + j);
                }
                j++;
            }
            odb.Close();
            t8  = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
            odb = Open(OdbFileName);
            AssertEquals(0, odb.GetObjects <SimpleObject>().Count);
            odb.Close();
            DisplayResult("ODB " + TestSize + " SimpleObject objects ", t1, t2, t3, t4, t5, t6
                          , t7, t77, t8);
        }
Пример #15
0
        /// <summary>Execute query using index</summary>
        /// <param name="index"></param>
        /// <param name="inMemory"></param>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        /// <param name="returnObjects"></param>
        /// <returns></returns>
        /// <exception cref="System.Exception">System.Exception</exception>
        private NeoDatis.Odb.Objects <T> ExecuteUsingIndex <T>(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex
                                                               index, bool inMemory, int startIndex, int endIndex, bool returnObjects, NeoDatis.Odb.Core.Query.Execution.IMatchingObjectAction
                                                               queryResultAction)
        {
            // Index that have not been used yet do not have persister!
            if (index.GetBTree().GetPersister() == null)
            {
                index.GetBTree().SetPersister(new NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister
                                                  (storageEngine));
            }
            bool objectMatches = false;
            long nbObjects     = classInfo.GetNumberOfObjects();
            long btreeSize     = index.GetBTree().GetSize();

            // the two values should be equal
            if (nbObjects != btreeSize)
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = storageEngine.GetSession(true
                                                                                             ).GetMetaModel().GetClassInfoFromId(index.GetClassInfoId());
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IndexIsCorrupted
                                                           .AddParameter(index.GetName()).AddParameter(ci.GetFullClassName()).AddParameter(
                                                               nbObjects).AddParameter(btreeSize));
            }
            if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
            {
                NeoDatis.Tool.DLogger.Debug("loading " + nbObjects + " instance(s) of " + classInfo
                                            .GetFullClassName());
            }
            if (ExecuteStartAndEndOfQueryAction())
            {
                queryResultAction.Start();
            }
            PrepareQuery();
            if (query != null)
            {
                queryHasOrderBy = query.HasOrderBy();
            }
            NeoDatis.Btree.IBTree tree = index.GetBTree();
            bool isUnique = index.IsUnique();

            // Iterator iterator = new BTreeIterator(tree,
            // OrderByConstants.ORDER_BY_ASC);
            System.IComparable       key  = ComputeIndexKey(classInfo, index);
            System.Collections.IList list = null;
            // If index is unique, get the object
            if (isUnique)
            {
                NeoDatis.Btree.IBTreeSingleValuePerKey treeSingle = (NeoDatis.Btree.IBTreeSingleValuePerKey
                                                                     )tree;
                object o = treeSingle.Search(key);
                if (o != null)
                {
                    list = new System.Collections.ArrayList();
                    list.Add(o);
                }
            }
            else
            {
                NeoDatis.Btree.IBTreeMultipleValuesPerKey treeMultiple = (NeoDatis.Btree.IBTreeMultipleValuesPerKey
                                                                          )tree;
                list = treeMultiple.Search(key);
            }
            if (list != null)
            {
                System.Collections.IEnumerator iterator = list.GetEnumerator();
                while (iterator.MoveNext())
                {
                    NeoDatis.Odb.OID oid = (NeoDatis.Odb.OID)iterator.Current;
                    // FIXME Why calling this method
                    long position = objectReader.GetObjectPositionFromItsOid(oid, true, true);
                    orderByKey    = null;
                    objectMatches = MatchObjectWithOid(oid, returnObjects, inMemory);
                    if (objectMatches)
                    {
                        queryResultAction.ObjectMatch(oid, GetCurrentObjectMetaRepresentation(), orderByKey
                                                      );
                    }
                }
                queryResultAction.End();
                return(queryResultAction.GetObjects <T>());
            }
            if (ExecuteStartAndEndOfQueryAction())
            {
                queryResultAction.End();
            }
            return(queryResultAction.GetObjects <T>());
        }