Example #1
0
        public object SearchScalar(string query)
        {
            string typeName, primaryKeyName, primaryKeyStrValue;

            if (_query_process(query, out typeName, out primaryKeyName, out primaryKeyStrValue))
            {
                Type      t          = _get_type_by_name(typeName);
                ClassInfo schemeInfo = m_catalogTree.Search(t.FullName);
                if (schemeInfo != null)
                {
                    object keyValue = Types.GetValue(primaryKeyStrValue, Types.GetInternalType(Types.GetClassFieldType(t, primaryKeyName)));

                    OOD.Imp.Storage.ObjectTree ot = _get_object_tree(schemeInfo.TopNodeSId);
                    ObjectInfo oInfo = ot.SearchObject(keyValue);
                    if (oInfo != null)
                    {
                        object result = _get_object_from_storage(oInfo, primaryKeyName, t, schemeInfo);

                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /**** User related operations *****/
        public void Put(object persistentObject)
        {
            System.Type t = persistentObject.GetType();
            string      primaryKeyName = _get_primary_key_name(t);

            ClassInfo schemeInfo = SearchClassInfo(t.FullName);
            uint      cid        = 0;
            uint      topNodeSid = 0;

            if (schemeInfo == null)
            {
                //insert it first
                InsertClassIno(t.FullName, _get_other_fields_name(t, primaryKeyName), ref cid, ref topNodeSid);
                schemeInfo = new ClassInfo(cid, t.FullName, _get_other_fields_name(t, primaryKeyName), topNodeSid);
            }
            else
            {
                cid        = schemeInfo.CId;
                topNodeSid = schemeInfo.TopNodeSId;
            }

            Debug.Assert(topNodeSid > 0);

            OOD.Imp.Storage.ObjectTree ot = _get_object_tree(topNodeSid);

            //get the primary key value
            object keyValue = new object();

            //get the serialzed all othe fieldValues
            string[] otherFields;

            _get_data_for_storage(persistentObject, primaryKeyName, schemeInfo.FieldNames, out keyValue, out otherFields);

            Debug.Assert(otherFields != null);

            if (ot.InsertObject(keyValue, otherFields) == false)
            {
                throw new OOD.Exception.DuplicatedPrimaryKey(
                          this,
                          "primary key is dupicated, insertion failed.");
            }
            if (topNodeSid != ot.TopNodeSId)
            {
                //update the top node segment id needed
                m_catalogTree.UpdateTopNodeSId(t.FullName, ot.TopNodeSId);
            }
        }
Example #3
0
		public ObjectTree _get_object_tree(uint topNodeSId)
		{
			if (!m_objectTreeCache.Exists(topNodeSId))
			{
				ObjectTree ot = new ObjectTree(topNodeSId, m_dbSegmentManager);
				m_objectTreeCache.Insert(topNodeSId, ot);
			}
			return (ObjectTree)m_objectTreeCache.Retrive(topNodeSId);
		}