private System.Collections.Generic.IDictionary <AbstractObjectInfo, AbstractObjectInfo> IntrospectGenericMap(
     System.Collections.Generic.IDictionary <object, object> map,
     bool introspect,
     IDictionary <object, NonNativeObjectInfo> alreadyReadObjects, IIntrospectionCallback callback)
 {
     System.Collections.Generic.IDictionary <AbstractObjectInfo, AbstractObjectInfo> mapCopy = new OdbHashMap <AbstractObjectInfo, AbstractObjectInfo>();
     System.Collections.Generic.ICollection <object> keySet = map.Keys;
     System.Collections.IEnumerator keys = keySet.GetEnumerator();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo          ciKey       = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo          ciValue     = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForKey   = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForValue = null;
     while (keys.MoveNext())
     {
         object key   = keys.Current;
         object value = map[key];
         if (key != null)
         {
             ciKey = GetClassInfo(OdbClassUtil.GetFullName(key.GetType()));
             if (value != null)
             {
                 ciValue = GetClassInfo(OdbClassUtil.GetFullName(value.GetType()));
             }
             aoiForKey   = GetObjectInfo(key, ciKey, introspect, alreadyReadObjects, callback);
             aoiForValue = GetObjectInfo(value, ciValue, introspect, alreadyReadObjects, callback);
             mapCopy.Add(aoiForKey, aoiForValue);
         }
     }
     return(mapCopy);
 }
Пример #2
0
        public virtual void TestPerformanceOid()
		{
			int size = 300000;
            OdbHashMap<OID,string> oidMap = new OdbHashMap<OID, string>();
			
			// OID
			NeoDatis.Tool.StopWatch timeOidMapCreation = new NeoDatis.Tool.StopWatch();
			timeOidMapCreation.Start();
			// Creates a hashmap with 100000 Longs
			for (int i = 0; i < size; i++)
			{
				oidMap.Add(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(i), i.ToString());
			}
			timeOidMapCreation.End();
			NeoDatis.Tool.StopWatch timeOidMapGet = new NeoDatis.Tool.StopWatch();
			timeOidMapGet.Start();
			// get all map elements
			for (int i = 0; i < size; i++)
			{
				AssertNotNull(oidMap[NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(i)]);
			}
			timeOidMapGet.End();
			Println(size + " objects : OID Map creation=" + timeOidMapCreation.GetDurationInMiliseconds
				() + " - get=" + timeOidMapGet.GetDurationInMiliseconds());
		}
Пример #3
0
        public virtual void TestPerformanceOid()
        {
            var size   = 300000;
            var oidMap = new OdbHashMap <OID, string>();

            // OID
            var timeOidMapCreation = new StopWatch();

            timeOidMapCreation.Start();
            // Creates a hashmap with 100000 Longs
            for (var i = 0; i < size; i++)
            {
                oidMap.Add(OIDFactory.BuildObjectOID(i), i.ToString());
            }
            timeOidMapCreation.End();
            var timeOidMapGet = new StopWatch();

            timeOidMapGet.Start();
            // get all map elements
            for (var i = 0; i < size; i++)
            {
                AssertNotNull(oidMap[OIDFactory.BuildObjectOID(i)]);
            }
            timeOidMapGet.End();
            Println(size + " objects : OID Map creation=" + timeOidMapCreation.GetDurationInMiliseconds() + " - get=" +
                    timeOidMapGet.GetDurationInMiliseconds());
        }
Пример #4
0
 public virtual void AddEntry(object key, object value)
 {
     if (map == null)
     {
         map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <object, object>();
     }
     map.Add(key, value);
 }
Пример #5
0
 public virtual void AddEntry(object key, object value)
 {
     if (map == null)
     {
         map = new OdbHashMap <object, object>();
     }
     map.Add(key, value);
 }
Пример #6
0
        public virtual void TestOIdInMap()
        {
            var oid1 = OIDFactory.BuildObjectOID(1);
            var oid2 = OIDFactory.BuildObjectOID(1);
            var map  = new OdbHashMap <OID, string>();

            map.Add(oid1, "oid1");
            AssertNotNull(map[oid2]);
        }
Пример #7
0
        public virtual void TestInsertWithCommitsSimpleObject()
        {
            DeleteBase("commits");
            IOdb odb            = null;
            var  size           = 10000;
            var  commitInterval = 1000;

            try
            {
                odb = Open("commits");
                for (var i = 0; i < size; i++)
                {
                    odb.Store(new VO.Login.Function("function " + i));
                    if (i % commitInterval == 0)
                    {
                        odb.Commit();
                        Console.WriteLine(i);
                    }
                }
            }
            finally
            {
                // println("commiting "+i);
                odb.Close();
            }
            odb = Open("commits");
            var query     = odb.Query <VO.Login.Function>();
            var objects   = query.Execute <VO.Login.Function>();
            var nbObjects = objects.Count;
            var map       = new OdbHashMap <VO.Login.Function, int>();

            VO.Login.Function function = null;
            var j = 0;

            while (objects.HasNext())
            {
                function = objects.Next();
                var ii = map[function];
                if (ii != 0)
                {
                    Println(j + ":" + function.GetName() + " already exist at " + ii);
                }
                else
                {
                    map.Add(function, j);
                }
                j++;
            }
            odb.Close();
            DeleteBase("commits");
            Println("Nb objects=" + nbObjects);
            AssertEquals(size, nbObjects);
        }
Пример #8
0
        private void AddModifiedOid(OID oid)
        {
            if (_modifiedObjectOids.ContainsKey(oid))
            {
                // Object is already in the list
                return;
            }

            _modifiedObjectOidList.Add(oid);
            // Keep the position of the oid in the list as the value of the map.
            // Used for the delete.
            _modifiedObjectOids.Add(oid, _modifiedObjectOidList.Count - 1);
        }
Пример #9
0
		public override AbstractObjectInfo CreateCopy(IDictionary<OID, AbstractObjectInfo> cache, bool onlyData)
		{
            IDictionary<AbstractObjectInfo, AbstractObjectInfo> m = GetMap();
			IDictionary<AbstractObjectInfo,AbstractObjectInfo> newMap = new OdbHashMap<AbstractObjectInfo, AbstractObjectInfo>();
			System.Collections.IEnumerator iterator = m.Keys.GetEnumerator();
			while (iterator.MoveNext())
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo keyAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
					)iterator.Current;
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo valueAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
					)m[keyAoi];
				// create copies
				keyAoi = keyAoi.CreateCopy(cache, onlyData);
				valueAoi = valueAoi.CreateCopy(cache, onlyData);
				newMap.Add(keyAoi, valueAoi);
			}
			MapObjectInfo moi = new MapObjectInfo(newMap, odbType, realMapClassName);
			return moi;
		}
Пример #10
0
        public override AbstractObjectInfo CreateCopy(IDictionary <OID, AbstractObjectInfo> cache, bool onlyData)
        {
            IDictionary <AbstractObjectInfo, AbstractObjectInfo> m      = GetMap();
            IDictionary <AbstractObjectInfo, AbstractObjectInfo> newMap = new OdbHashMap <AbstractObjectInfo, AbstractObjectInfo>();

            System.Collections.IEnumerator iterator = m.Keys.GetEnumerator();
            while (iterator.MoveNext())
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo keyAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                                  )iterator.Current;
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo valueAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                                    )m[keyAoi];
                // create copies
                keyAoi   = keyAoi.CreateCopy(cache, onlyData);
                valueAoi = valueAoi.CreateCopy(cache, onlyData);
                newMap.Add(keyAoi, valueAoi);
            }
            MapObjectInfo moi = new MapObjectInfo(newMap, odbType, realMapClassName);

            return(moi);
        }
Пример #11
0
        /// <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 IOdbList <string> GetAllInvolvedFields()
        {
            IOdbList <string> list = new OdbList <string>();

            // To check field duplicity
            IDictionary <string, string> map = new OdbHashMap <string, string>();

            list.AddAll(base.GetAllInvolvedFields());

            if (!list.IsNullOrEmpty())
            {
                foreach (var value in list)
                {
                    map.Add(value, value);
                }
            }

            var    iterator = _objectActions.GetEnumerator();
            string name;

            while (iterator.MoveNext())
            {
                var queryFieldAction = iterator.Current;
                if (queryFieldAction is CountAction)
                {
                    continue;
                }

                name = queryFieldAction.GetAttributeName();
                if (map.ContainsKey(name))
                {
                    continue;
                }

                list.Add(name);
                map.Add(name, name);
            }

            if (_hasGroupBy)
            {
                foreach (var groupByField in _groupByFieldList)
                {
                    name = groupByField;

                    if (map.ContainsKey(name))
                    {
                        continue;
                    }

                    list.Add(name);
                    map.Add(name, name);
                }
            }

            if (HasOrderBy())
            {
                foreach (var field in OrderByFields)
                {
                    name = field;
                    if (map.ContainsKey(name))
                    {
                        continue;
                    }

                    list.Add(name);
                    map.Add(name, name);
                }
            }
            map.Clear();

            return(list);
        }
Пример #12
0
        public virtual void TestPerformanceOid()
        {
            var size = 300000;
            var oidMap = new OdbHashMap<OID, string>();

            // OID
            var timeOidMapCreation = new StopWatch();
            timeOidMapCreation.Start();
            // Creates a hashmap with 100000 Longs
            for (var i = 0; i < size; i++)
                oidMap.Add(OIDFactory.BuildObjectOID(i), i.ToString());
            timeOidMapCreation.End();
            var timeOidMapGet = new StopWatch();
            timeOidMapGet.Start();
            // get all map elements
            for (var i = 0; i < size; i++)
                AssertNotNull(oidMap[OIDFactory.BuildObjectOID(i)]);
            timeOidMapGet.End();
            Println(size + " objects : OID Map creation=" + timeOidMapCreation.GetDurationInMiliseconds() + " - get=" +
                    timeOidMapGet.GetDurationInMiliseconds());
        }
Пример #13
0
 public virtual void TestOIdInMap()
 {
     var oid1 = OIDFactory.BuildObjectOID(1);
     var oid2 = OIDFactory.BuildObjectOID(1);
     var map = new OdbHashMap<OID, string>();
     map.Add(oid1, "oid1");
     AssertNotNull(map[oid2]);
 }
Пример #14
0
 public virtual void TestInsertWithCommitsSimpleObject()
 {
     DeleteBase("commits");
     IOdb odb = null;
     var size = 10000;
     var commitInterval = 1000;
     try
     {
         odb = Open("commits");
         for (var i = 0; i < size; i++)
         {
             odb.Store(new VO.Login.Function("function " + i));
             if (i % commitInterval == 0)
             {
                 odb.Commit();
                 Console.WriteLine(i);
             }
         }
     }
     finally
     {
         // println("commiting "+i);
         odb.Close();
     }
     odb = Open("commits");
     var query = odb.Query<VO.Login.Function>();
     var objects = query.Execute<VO.Login.Function>();
     var nbObjects = objects.Count;
     var map = new OdbHashMap<VO.Login.Function, int>();
     VO.Login.Function function = null;
     var j = 0;
     while (objects.HasNext())
     {
         function = objects.Next();
         var ii = map[function];
         if (ii != 0)
             Println(j + ":" + function.GetName() + " already exist at " + ii);
         else
             map.Add(function, j);
         j++;
     }
     odb.Close();
     DeleteBase("commits");
     Println("Nb objects=" + nbObjects);
     AssertEquals(size, nbObjects);
 }
Пример #15
0
 public void Set(int index, string alias, object value)
 {
     _valuesByIndex[index] = value;
     _valuesByAlias.Add(alias, value);
 }
 private System.Collections.Generic.IDictionary<AbstractObjectInfo, AbstractObjectInfo> IntrospectGenericMap(
     System.Collections.Generic.IDictionary<object,object> map,
     bool introspect,
     IDictionary<object, NonNativeObjectInfo> alreadyReadObjects, IIntrospectionCallback callback)
 {
     System.Collections.Generic.IDictionary<AbstractObjectInfo, AbstractObjectInfo> mapCopy = new OdbHashMap<AbstractObjectInfo, AbstractObjectInfo>();
     System.Collections.Generic.ICollection<object> keySet = map.Keys;
     System.Collections.IEnumerator keys = keySet.GetEnumerator();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ciKey = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ciValue = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForKey = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForValue = null;
     while (keys.MoveNext())
     {
         object key = keys.Current;
         object value = map[key];
         if (key != null)
         {
             ciKey = GetClassInfo(OdbClassUtil.GetFullName(key.GetType()));
             if (value != null)
             {
                 ciValue = GetClassInfo(OdbClassUtil.GetFullName(value.GetType()));
             }
             aoiForKey = GetObjectInfo(key, ciKey, introspect, alreadyReadObjects, callback);
             aoiForValue = GetObjectInfo(value, ciValue, introspect, alreadyReadObjects, callback);
             mapCopy.Add(aoiForKey, aoiForValue);
         }
     }
     return mapCopy;
 }