当前位置: 首页>>代码示例>>C#>>正文


C# NeoDatis.GetPosition方法代码示例

本文整理汇总了C#中NeoDatis.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# NeoDatis.GetPosition方法的具体用法?C# NeoDatis.GetPosition怎么用?C# NeoDatis.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NeoDatis的用法示例。


在下文中一共展示了NeoDatis.GetPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Persist

		public virtual void Persist(NeoDatis.Odb.Core.Layers.Layer3.Engine.IFileSystemInterface
			 fsi, int index)
		{
			long currentPosition = fsi.GetPosition();
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
			{
			}
			// DLogger.debug("# Writing WriteAction #" + index + " at " +
			// currentPosition+" : " + toString());
			int sizeOfLong = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Long.GetSize();
			int sizeOfInt = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Integer.GetSize();
			// build the full byte array to write once
			byte[] bytes = new byte[sizeOfLong + sizeOfInt + size];
			byte[] bytesOfPosition = byteArrayConverter.LongToByteArray(position);
			byte[] bytesOfSize = byteArrayConverter.IntToByteArray(size);
			for (int i = 0; i < sizeOfLong; i++)
			{
				bytes[i] = bytesOfPosition[i];
			}
			int offset = sizeOfLong;
			for (int i = 0; i < sizeOfInt; i++)
			{
				bytes[offset] = bytesOfSize[i];
				offset++;
			}
			for (int i = 0; i < listOfBytes.Count; i++)
			{
				byte[] tmp = listOfBytes[i];
				System.Array.Copy(tmp, 0, bytes, offset, tmp.Length);
				offset += tmp.Length;
			}
			fsi.WriteBytes(bytes, false, "Transaction");
			int fixedSize = sizeOfLong + sizeOfInt;
			long positionAfterWrite = fsi.GetPosition();
			long writeSize = positionAfterWrite - currentPosition;
			if (writeSize != size + fixedSize)
			{
				throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.DifferentSizeInWriteAction
					.AddParameter(size).AddParameter(writeSize));
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:41,代码来源:DefaultWriteAction.cs

示例2: Read

		public static NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction Read(NeoDatis.Odb.Core.Layers.Layer3.Engine.IFileSystemInterface
			 fsi, int index)
		{
			try
			{
				long position = fsi.ReadLong();
				int size = fsi.ReadInt();
				byte[] bytes = fsi.ReadBytes(size);
				NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction writeAction = new NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
					(position, bytes);
				if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
				{
					NeoDatis.Tool.DLogger.Debug("Loading Write Action # " + index + " at " + fsi.GetPosition
						() + " => " + writeAction.ToString());
				}
				return writeAction;
			}
			catch (NeoDatis.Odb.ODBRuntimeException e)
			{
				NeoDatis.Tool.DLogger.Error("error reading write action " + index + " at position "
					 + fsi.GetPosition());
				throw;
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:24,代码来源:DefaultWriteAction.cs

示例3: WriteClassInfoBody

		/// <summary>Write the class info body to the database file.</summary>
		/// <remarks>
		/// Write the class info body to the database file. TODO Check if we really
		/// must recall the writeClassInfoHeader
		/// </remarks>
		/// <param name="classInfo"></param>
		/// <param name="position">The position</param>
		/// <param name="writeInTransaction"></param>
		/// <></>
		public virtual void WriteClassInfoBody(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 classInfo, long position, bool writeInTransaction)
		{
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
			{
				NeoDatis.Tool.DLogger.Debug(DepthToSpaces() + "Writing new Class info body at " +
					 position + " : " + classInfo.ToString());
			}
			// updates class info
			classInfo.SetAttributesDefinitionPosition(position);
			// FIXME : change this to write only the position and not the whole
			// header
			WriteClassInfoHeader(classInfo, classInfo.GetPosition(), writeInTransaction);
			fsi.SetWritePosition(position, writeInTransaction);
			// block definition
			fsi.WriteInt(0, writeInTransaction, "block size");
			fsi.WriteByte(NeoDatis.Odb.Impl.Core.Layers.Layer3.Block.BlockTypes.BlockTypeClassBody
				, writeInTransaction);
			// number of attributes
			fsi.WriteLong(classInfo.GetAttributes().Count, writeInTransaction, "class nb attributes"
				, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = null;
			for (int i = 0; i < classInfo.GetAttributes().Count; i++)
			{
				cai = classInfo.GetAttributes()[i];
				WriteClassAttributeInfo(cai, writeInTransaction);
			}
			int blockSize = (int)(fsi.GetPosition() - position);
			WriteBlockSizeAt(position, blockSize, writeInTransaction, classInfo);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:39,代码来源:AbstractObjectWriter.cs

示例4: Delete

		public virtual NeoDatis.Odb.OID Delete(NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
			 header)
		{
			NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
			NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
			long objectPosition = header.GetPosition();
			NeoDatis.Odb.OID classInfoId = header.GetClassInfoId();
			NeoDatis.Odb.OID oid = header.GetOid();
			// gets class info from in memory meta model
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = GetSession().GetMetaModel().GetClassInfoFromId
				(classInfoId);
			bool withIndex = !ci.GetIndexes().IsEmpty();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = null;
			// When there is index,we must *always* load the old meta representation
			// to compute index keys
			if (withIndex)
			{
				nnoi = objectReader.ReadNonNativeObjectInfoFromPosition(ci, header.GetOid(), objectPosition
					, true, false);
			}
			// a boolean value to indicate if object is in connected zone or not
			// This will be used to know if work can be done out of transaction
			// for unconnected object,changes can be written directly, else we must
			// use Transaction (using WriteAction)
			bool objectIsInConnectedZone = cache.ObjectWithIdIsInCommitedZone(header.GetOid()
				);
			// triggers
			// FIXME
			triggerManager.ManageDeleteTriggerBefore(ci.GetFullClassName(), null, header.GetOid
				());
			long nbObjects = ci.GetNumberOfObjects();
			NeoDatis.Odb.OID previousObjectOID = header.GetPreviousObjectOID();
			NeoDatis.Odb.OID nextObjectOID = header.GetNextObjectOID();
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
			{
				NeoDatis.Tool.DLogger.Debug("Deleting object with id " + header.GetOid() + " - In connected zone ="
					 + objectIsInConnectedZone + " -  with index =" + withIndex);
				NeoDatis.Tool.DLogger.Debug("position =  " + objectPosition + " | prev oid = " + 
					previousObjectOID + " | next oid = " + nextObjectOID);
			}
			bool isFirstObject = previousObjectOID == null;
			bool isLastObject = nextObjectOID == null;
			bool mustUpdatePreviousObjectPointers = false;
			bool mustUpdateNextObjectPointers = false;
			bool mustUpdateLastObjectOfCI = false;
			if (isFirstObject || isLastObject)
			{
				if (isFirstObject)
				{
					// The deleted object is the first, must update first instance
					// OID field of the class
					if (objectIsInConnectedZone)
					{
						// update first object oid of the class info in memory
						ci.GetCommitedZoneInfo().first = nextObjectOID;
					}
					else
					{
						// update first object oid of the class info in memory
						ci.GetUncommittedZoneInfo().first = nextObjectOID;
					}
					if (nextObjectOID != null)
					{
						// Update next object 'previous object oid' to null
						UpdatePreviousObjectFieldOfObjectInfo(nextObjectOID, null, objectIsInConnectedZone
							);
						mustUpdateNextObjectPointers = true;
					}
				}
				// It can be first and last
				if (isLastObject)
				{
					// The deleted object is the last, must update last instance
					// OID field of the class
					// update last object position of the class info in memory
					if (objectIsInConnectedZone)
					{
						// the object is a committed object
						ci.GetCommitedZoneInfo().last = previousObjectOID;
					}
					else
					{
						// The object is not committed and it is the last and is
						// being deleted
						ci.GetUncommittedZoneInfo().last = previousObjectOID;
					}
					if (previousObjectOID != null)
					{
						// Update 'next object oid' of previous object to null
						// if we are in unconnected zone, change can be done
						// directly,else it must be done in transaction
						UpdateNextObjectFieldOfObjectInfo(previousObjectOID, null, objectIsInConnectedZone
							);
						// Now update data of the cache
						mustUpdatePreviousObjectPointers = true;
						mustUpdateLastObjectOfCI = true;
					}
				}
			}
			else
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例5: UpdateInstanceFieldsOfClassInfo

		/// <summary>
		/// Updates the instance related field of the class info into the database
		/// file Updates the number of objects, the first object oid and the next
		/// class oid
		/// </summary>
		/// <param name="classInfo">The class info to be updated</param>
		/// <param name="writeInTransaction">To specify if it must be part of a transaction @
		/// 	</param>
		public virtual void UpdateInstanceFieldsOfClassInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 classInfo, bool writeInTransaction)
		{
			long currentPosition = fsi.GetPosition();
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogIdDebug))
			{
				NeoDatis.Tool.DLogger.Debug(DepthToSpaces() + "Start of updateInstanceFieldsOfClassInfo for "
					 + classInfo.GetFullClassName());
			}
			long position = classInfo.GetPosition() + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
				.ClassOffsetClassNbObjects;
			fsi.SetWritePosition(position, writeInTransaction);
			long nbObjects = classInfo.GetNumberOfObjects();
			fsi.WriteLong(nbObjects, writeInTransaction, "class info update nb objects", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
				.PointerWriteAction);
			WriteOid(classInfo.GetCommitedZoneInfo().first, writeInTransaction, "class info update first obj oid"
				, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.PointerWriteAction);
			WriteOid(classInfo.GetCommitedZoneInfo().last, writeInTransaction, "class info update last obj oid"
				, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.PointerWriteAction);
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogIdDebug))
			{
				NeoDatis.Tool.DLogger.Debug(DepthToSpaces() + "End of updateInstanceFieldsOfClassInfo for "
					 + classInfo.GetFullClassName());
			}
			fsi.SetWritePosition(currentPosition, writeInTransaction);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:34,代码来源:AbstractObjectWriter.cs

示例6: UpdateUpdateTimeAndObjectVersionNumber

		/// <summary>Upate the version number of the object</summary>
		/// <param name="header"></param>
		/// <param name="writeInTransaction"></param>
		private void UpdateUpdateTimeAndObjectVersionNumber(NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
			 header, bool writeInTransaction)
		{
			long objectPosition = header.GetPosition();
			fsi.SetWritePosition(objectPosition + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
				.ObjectOffsetUpdateDate, writeInTransaction);
			fsi.WriteLong(header.GetUpdateDate(), writeInTransaction, "update date time", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
				.DataWriteAction);
			fsi.WriteInt(header.GetObjectVersion(), writeInTransaction, "object version");
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:13,代码来源:AbstractObjectWriter.cs

示例7: UpdateNonNativeObjectInfo

		/// <summary>Updates an object.</summary>
		/// <remarks>
		/// Updates an object.
		/// <pre>
		/// Try to update in place. Only change what has changed. This is restricted to particular types (fixed size types). If in place update is
		/// not possible, then deletes the current object and creates a new at the end of the database file and updates
		/// OID object position.
		/// &#064;param object The object to be updated
		/// &#064;param forceUpdate when true, no verification is done to check if update must be done.
		/// &#064;return The oid of the object, as a negative number
		/// &#064;
		/// </remarks>
		public virtual NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi, bool forceUpdate)
		{
			nbCallsToUpdate++;
			bool hasObject = true;
			string message = null;
			object @object = nnoi.GetObject();
			NeoDatis.Odb.OID oid = nnoi.GetOid();
			if (@object == null)
			{
				hasObject = false;
			}
			// When there is index,we must *always* load the old meta representation
			// to compute index keys
			bool withIndex = !nnoi.GetClassInfo().GetIndexes().IsEmpty();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oldMetaRepresentation = 
				null;
			// Used to check consistency, at the end, the number of
			// nbConnectedObjects must and nbUnconnected must remain unchanged
			long nbConnectedObjects = nnoi.GetClassInfo().GetCommitedZoneInfo().GetNbObjects(
				);
			long nbNonConnectedObjects = nnoi.GetClassInfo().GetUncommittedZoneInfo().GetNbObjects
				();
			bool objectHasChanged = false;
			try
			{
				NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
				long positionBeforeWrite = fsi.GetPosition();
				NeoDatis.Odb.Core.Transaction.ITmpCache tmpCache = lsession.GetTmpCache();
				NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
				// Get header of the object (position, previous object position,
				// next
				// object position and class info position)
				// The header must be in the cache.
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader lastHeader = cache.GetObjectInfoHeaderFromOid
					(oid, true);
				if (lastHeader == null)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.UnexpectedSituation
						.AddParameter("Header is null in update"));
				}
				if (lastHeader.GetOid() == null)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
						.AddParameter("Header oid is null for oid " + oid));
				}
				bool objectIsInConnectedZone = cache.ObjectWithIdIsInCommitedZone(oid);
				long currentPosition = lastHeader.GetPosition();
				// When using client server mode, we must re-read the position of
				// the object with oid. Because, another session may
				// have updated the object, and in this case, the position of the
				// object in the cache may be invalid
				// TODO It should be done only when the object has been deleted or
				// updated by another session. Should check this
				// Doing this with new objects (created in the current session, the
				// last committed
				// object position will be negative, in this case we must use the
				// currentPosition
				if (!isLocalMode)
				{
					long lastCommitedObjectPosition = idManager.GetObjectPositionWithOid(oid, false);
					if (lastCommitedObjectPosition > 0)
					{
						currentPosition = lastCommitedObjectPosition;
					}
					// Some infos that come from the client are not set
					// So we overwrite them here : example : object version. Update
					// date is not important here
					// Because, as we are updating the object, the update date will
					// be updated too
					nnoi.GetHeader().SetObjectVersion(lastHeader.GetObjectVersion());
					nnoi.GetHeader().SetUpdateDate(lastHeader.GetUpdateDate());
				}
				// for client server
				if (nnoi.GetPosition() == -1)
				{
					nnoi.GetHeader().SetPosition(currentPosition);
				}
				if (currentPosition == -1)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InstancePositionIsNegative
						.AddParameter(currentPosition).AddParameter(oid).AddParameter("In Object Info Header"
						));
				}
				if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
				{
					message = DepthToSpaces() + "start updating object at " + currentPosition + ", oid="
						 + oid + " : " + (nnoi != null ? nnoi.ToString() : "null");
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs


注:本文中的NeoDatis.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。