Exemplo n.º 1
0
 private object BuildOneInstance(NativeObjectInfo objectInfo)
 {
     if (objectInfo.IsAtomicNativeObject())
         return BuildOneInstance((AtomicNativeObjectInfo) objectInfo);
     if (objectInfo.IsArrayObject())
         return BuildArrayInstance((ArrayObjectInfo) objectInfo);
     if (objectInfo.IsNull())
         return null;
     throw new OdbRuntimeException(
         NDatabaseError.InstanceBuilderNativeType.AddParameter(OdbType.GetNameFromId(objectInfo.GetOdbTypeId())));
 }
Exemplo n.º 2
0
 // This will be done by the mainStoreObject method
 // Context.getCache().endInsertingObject(object);
 /// <param name="noi"> The native object meta representation The object to be inserted in the database </param>
 /// <returns> The position of the inserted object </returns>
 private long InsertNativeObject(NativeObjectInfo noi)
 {
     var writePosition = FileSystemProcessor.FileSystemInterface.GetAvailablePosition();
     FileSystemProcessor.FileSystemInterface.SetWritePosition(writePosition, true);
     // true,false = update pointers,do not write in transaction, writes
     // directly to hard disk
     return WriteNativeObjectInfo(noi, writePosition, false);
 }
Exemplo n.º 3
0
 /// <summary>
 ///   Store a meta representation of a native object(already as meta representation)in ODBFactory database.
 /// </summary>
 /// <remarks>
 ///   Store a meta representation of a native object(already as meta representation)in ODBFactory database. A Native object is an object that use native language type, String for example To detect if object must be updated or insert, we use the cache. To update an object, it must be first selected from the database. When an object is to be stored, if it exist in the cache, then it will be updated, else it will be inserted as a new object. If the object is null, the cache will be used to check if the meta representation is in the cache
 /// </remarks>
 /// <param name="noi"> The meta representation of an object </param>
 /// <returns> The object position @ </returns>
 public long InternalStoreObject(NativeObjectInfo noi)
 {
     return InsertNativeObject(noi);
 }
Exemplo n.º 4
0
        /// <summary>
        ///   Actually write the object data to the database file
        /// </summary>
        /// <param name="noi"> The object meta infor The object info to be written </param>
        /// <param name="position"> if -1, it is a new instance, if not, it is an update </param>
        /// <param name="writeInTransaction"> </param>
        /// <returns> The object posiiton or id(if &lt; 0) </returns>
        private long WriteNativeObjectInfo(NativeObjectInfo noi, long position, bool writeInTransaction)
        {
            if (OdbConfiguration.IsLoggingEnabled())
            {
                var positionAsString = position.ToString();
                DLogger.Debug(string.Concat("ObjectWriter: Writing native object at", positionAsString,
                                            string.Format(" : Type={0} | Value={1}",
                                                          OdbType.GetNameFromId(noi.GetOdbTypeId()), noi)));
            }

            if (noi.IsAtomicNativeObject())
                return WriteAtomicNativeObject((AtomicNativeObjectInfo) noi, writeInTransaction);
            if (noi.IsNull())
            {
                WriteNullNativeObjectHeader(noi.GetOdbTypeId(), writeInTransaction);
                return position;
            }
            if (noi.IsArrayObject())
                return WriteArray((ArrayObjectInfo) noi, writeInTransaction);
            if (noi.IsEnumObject())
                return WriteEnumNativeObject((EnumNativeObjectInfo) noi, writeInTransaction);
            throw new OdbRuntimeException(NDatabaseError.NativeTypeNotSupported.AddParameter(noi.GetOdbTypeId()));
        }