public NonNativeObjectInfo(ObjectInfoHeader oip, ClassInfo classInfo) : base(null) { _classInfo = classInfo; _objectHeader = oip; if (classInfo != null) { _maxNbattributes = classInfo.MaxAttributeId; _attributeValues = new AbstractObjectInfo[_maxNbattributes]; } }
protected NonNativeObjectInfo(ClassInfo classInfo) : base(null) { _classInfo = classInfo; _objectHeader = new ObjectInfoHeader(-1, null, null, (classInfo != null ? classInfo.ClassInfoId : null), null, null); if (classInfo != null) { _maxNbattributes = classInfo.MaxAttributeId; _attributeValues = new AbstractObjectInfo[_maxNbattributes]; } }
public virtual ObjectInfoHeader GetObjectInfoHeaderFromOid(NeoDatis.Odb.OID oid, bool throwExceptionIfNotFound) { if (oid == null) { throw new ODBRuntimeException(NeoDatisError.CacheNullOid); } ObjectInfoHeader oih = null; objectInfoPointersCacheFromOid.TryGetValue(oid, out oih); if (oih == null && throwExceptionIfNotFound) { throw new ODBRuntimeException(NeoDatisError.ObjectWithOidDoesNotExistInCache.AddParameter(oid)); } nbCallsToGetObjectInfoHeaderFromOid++; return(oih); }
private NonNativeObjectInfo(object @object, ClassInfo info, AbstractObjectInfo[] values, long[] attributesIdentification, int[] attributeIds) : base(OdbType.GetFromName(info.FullClassName)) { _theObject = @object; _classInfo = info; _attributeValues = values; _maxNbattributes = _classInfo.MaxAttributeId; if (_attributeValues == null) _attributeValues = new AbstractObjectInfo[_maxNbattributes]; _objectHeader = new ObjectInfoHeader(-1, null, null, (_classInfo != null ? _classInfo.ClassInfoId : null), attributesIdentification, attributeIds); }
/// <summary>Only adds the Object info - used for non committed objects</summary> public virtual void AddObjectInfo(ObjectInfoHeader objectInfoHeader) { if (objectInfoHeader.GetOid() == null) { throw new ODBRuntimeException(NeoDatisError.CacheNullOid); } if (objectInfoHeader.GetClassInfoId() == null) { throw new ODBRuntimeException(NeoDatisError.CacheObjectInfoHeaderWithoutClassId.AddParameter(objectInfoHeader.GetOid())); } // TODO : Should remove first inserted object and not clear all cache if (objectInfoPointersCacheFromOid.Count > OdbConfiguration.GetMaxNumberOfObjectInCache()) { ManageFullCache(); } objectInfoPointersCacheFromOid[objectInfoHeader.GetOid()] = objectInfoHeader; // For monitoring purpose nbObjects = objects.Count; nbOids = oids.Count; nbOih = objectInfoPointersCacheFromOid.Count; }
public virtual void AddObject(OID oid, object o, ObjectInfoHeader objectInfoHeader) { if (oid == null) { throw new ODBRuntimeException(NeoDatisError.CacheNullOid); } if (CheckHeaderPosition() && objectInfoHeader.GetPosition() == -1) { throw new ODBRuntimeException(NeoDatisError.CacheNegativePosition .AddParameter("Adding OIH with position = -1")); } // TODO : Should remove first inserted object and not clear all cache if (objects.Count > OdbConfiguration.GetMaxNumberOfObjectInCache()) { // clear(); ManageFullCache(); } oids[oid] = o; try { objects[o] = oid; } catch (System.ArgumentNullException) { } // FIXME URL in HashMap What should we do? // In some case, the object can throw exception when added to the // cache // because Map.put, end up calling the equals method that can throw // exception // This is the case of URL that has a transient attribute handler // that is used in the URL.equals method objectInfoPointersCacheFromOid[oid] = objectInfoHeader; // For monitoring purpose nbObjects = objects.Count; nbOids = oids.Count; nbOih = objectInfoPointersCacheFromOid.Count; }
public void SetHeader(ObjectInfoHeader header) { _objectHeader = header; }
/// <summary> /// Create a copy oh this meta object /// </summary> /// <param name="cache"> </param> /// <param name="onlyData"> if true, only copy attributes values </param> /// <returns> </returns> public override AbstractObjectInfo CreateCopy(IDictionary<OID, AbstractObjectInfo> cache, bool onlyData) { NonNativeObjectInfo nnoi; if (_objectHeader.GetOid() != null && cache.ContainsKey(_objectHeader.GetOid())) { nnoi = (NonNativeObjectInfo) cache[_objectHeader.GetOid()]; if (nnoi != null) return nnoi; } if (_theObject == null) return new NonNativeNullObjectInfo(_classInfo); if (onlyData) { var oih = new ObjectInfoHeader(); nnoi = new NonNativeObjectInfo(_theObject, _classInfo, null, oih.GetAttributesIdentification(), oih.GetAttributeIds()); } else { nnoi = new NonNativeObjectInfo(_theObject, _classInfo, null, _objectHeader.GetAttributesIdentification(), _objectHeader.GetAttributeIds()); nnoi.GetHeader().SetOid(GetHeader().GetOid()); } var newAttributeValues = new AbstractObjectInfo[_attributeValues.Length]; for (var i = 0; i < _attributeValues.Length; i++) newAttributeValues[i] = _attributeValues[i].CreateCopy(cache, onlyData); nnoi._attributeValues = newAttributeValues; if (_objectHeader.GetOid() != null) cache.Add(_objectHeader.GetOid(), nnoi); return nnoi; }