本文整理汇总了C#中NeoDatis.SetId方法的典型用法代码示例。如果您正苦于以下问题:C# NeoDatis.SetId方法的具体用法?C# NeoDatis.SetId怎么用?C# NeoDatis.SetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeoDatis
的用法示例。
在下文中一共展示了NeoDatis.SetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveBTree
public virtual NeoDatis.Odb.OID SaveBTree(NeoDatis.Btree.IBTree treeToSave)
{
nbSaveTree++;
try
{
NeoDatis.Odb.OID oid = (NeoDatis.Odb.OID)treeToSave.GetId();
if (oid == null)
{
// first get the oid. -2 : it could be any value
oid = engine.GetObjectWriter().GetIdManager().GetNextObjectId(-2);
treeToSave.SetId(oid);
oid = engine.Store(oid, treeToSave);
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug("Saved btree " + treeToSave.GetId() + " with id " + oid
+ " and root " + treeToSave.GetRoot());
}
if (this.tree == null)
{
this.tree = treeToSave;
}
oids.Add(oid, treeToSave);
}
else
{
oids.Add(oid, treeToSave);
AddModifiedOid(oid);
}
return oid;
}
catch (System.Exception e)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError
, e);
}
}
示例2: WriteClassInfoHeader
public virtual void WriteClassInfoHeader(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
classInfo, long position, bool writeInTransaction)
{
NeoDatis.Odb.OID classId = classInfo.GetId();
if (classId == null)
{
classId = idManager.GetNextClassId(position);
classInfo.SetId(classId);
}
else
{
idManager.UpdateClassPositionForId(classId, position, true);
}
fsi.SetWritePosition(position, writeInTransaction);
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug(DepthToSpaces() + "Writing new Class info header at "
+ position + " : " + classInfo.ToString());
}
// Real value of block size is only known at the end of the writing
fsi.WriteInt(0, writeInTransaction, "block size");
fsi.WriteByte(NeoDatis.Odb.Impl.Core.Layers.Layer3.Block.BlockTypes.BlockTypeClassHeader
, writeInTransaction, "class header block type");
fsi.WriteByte(classInfo.GetClassCategory(), writeInTransaction, "Class info category"
);
fsi.WriteLong(classId.GetObjectId(), writeInTransaction, "class id", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
.DataWriteAction);
WriteOid(classInfo.GetPreviousClassOID(), writeInTransaction, "prev class oid", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
.DataWriteAction);
WriteOid(classInfo.GetNextClassOID(), writeInTransaction, "next class oid", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
.DataWriteAction);
fsi.WriteLong(classInfo.GetCommitedZoneInfo().GetNbObjects(), writeInTransaction,
"class nb objects", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction
);
WriteOid(classInfo.GetCommitedZoneInfo().first, writeInTransaction, "class first obj pos"
, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction);
WriteOid(classInfo.GetCommitedZoneInfo().last, writeInTransaction, "class last obj pos"
, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction);
// FIXME : append extra info if not empty (.net compatibility)
fsi.WriteString(classInfo.GetFullClassName(), false, writeInTransaction);
fsi.WriteInt(classInfo.GetMaxAttributeId(), writeInTransaction, "Max attribute id"
);
if (classInfo.GetAttributesDefinitionPosition() != -1)
{
fsi.WriteLong(classInfo.GetAttributesDefinitionPosition(), writeInTransaction, "class att def pos"
, NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction);
}
else
{
// @todo check this
fsi.WriteLong(-1, writeInTransaction, "class att def pos", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
.DataWriteAction);
}
int blockSize = (int)(fsi.GetPosition() - position);
WriteBlockSizeAt(position, blockSize, writeInTransaction, classInfo);
}
示例3: SaveNode
/// <summary>
/// saves the bree node Only puts the current node in an 'modified Node' map
/// to be saved on commit
/// </summary>
public virtual object SaveNode(NeoDatis.Btree.IBTreeNode node)
{
NeoDatis.Odb.OID oid = null;
// Here we only save the node if it does not have id,
// else we just save into the hashmap
if (node.GetId() == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.NullObjectId)
{
try
{
nbSaveNodes++;
// first get the oid. : -2:it could be any value
oid = engine.GetObjectWriter().GetIdManager().GetNextObjectId(-2);
node.SetId(oid);
oid = engine.Store(oid, node);
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug("Saved node id " + oid);
}
// + " : " +
// node.toString());
if (tree != null && node.GetBTree() == null)
{
node.SetBTree(tree);
}
oids.Add(oid, node);
return oid;
}
catch (System.Exception e)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError
.AddParameter("While saving node"), e);
}
}
nbSaveNodesInCache++;
oid = (NeoDatis.Odb.OID)node.GetId();
oids.Add(oid, node);
AddModifiedOid(oid);
return oid;
}
示例4: PersistClass
/// <summary>Persist a single class info - This method is used by the XML Importer.</summary>
/// <remarks>Persist a single class info - This method is used by the XML Importer.</remarks>
public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo PersistClass(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
newClassInfo, int lastClassInfoIndex, bool addClass, bool addDependentClasses)
{
NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = GetSession().GetMetaModel
();
NeoDatis.Odb.OID classInfoId = newClassInfo.GetId();
if (classInfoId == null)
{
classInfoId = GetIdManager().GetNextClassId(-1);
newClassInfo.SetId(classInfoId);
}
long writePosition = fsi.GetAvailablePosition();
newClassInfo.SetPosition(writePosition);
GetIdManager().UpdateClassPositionForId(classInfoId, writePosition, true);
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug("Persisting class into database : " + newClassInfo.GetFullClassName
() + " with oid " + classInfoId + " at pos " + writePosition);
NeoDatis.Tool.DLogger.Debug("class " + newClassInfo.GetFullClassName() + " has "
+ newClassInfo.GetNumberOfAttributes() + " attributes : " + newClassInfo.GetAttributes
());
}
// The class info oid is created in ObjectWriter.writeClassInfoHeader
if (metaModel.GetNumberOfClasses() > 0 && lastClassInfoIndex != -2)
{
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo lastClassinfo = null;
if (lastClassInfoIndex == -1)
{
lastClassinfo = metaModel.GetLastClassInfo();
}
else
{
lastClassinfo = metaModel.GetClassInfo(lastClassInfoIndex);
}
lastClassinfo.SetNextClassOID(newClassInfo.GetId());
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug("changing next class oid. of class info " + lastClassinfo
.GetFullClassName() + " @ " + lastClassinfo.GetPosition() + " + offset " + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.ClassOffsetNextClassPosition + " to " + newClassInfo.GetId() + "(" + newClassInfo
.GetFullClassName() + ")");
}
fsi.SetWritePosition(lastClassinfo.GetPosition() + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.ClassOffsetNextClassPosition, true);
fsi.WriteLong(newClassInfo.GetId().GetObjectId(), true, "next class oid", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
.PointerWriteAction);
newClassInfo.SetPreviousClassOID(lastClassinfo.GetId());
}
if (addClass)
{
metaModel.AddClass(newClassInfo);
}
// updates number of classes
WriteNumberOfClasses(metaModel.GetNumberOfClasses(), true);
// If it is the first class , updates the first class OID
if (newClassInfo.GetPreviousClassOID() == null)
{
WriteFirstClassInfoOID(newClassInfo.GetId(), true);
}
// Writes the header of the class - out of transaction (FIXME why out of
// transaction)
WriteClassInfoHeader(newClassInfo, writePosition, false);
if (addDependentClasses)
{
NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo
> dependingAttributes = newClassInfo.GetAllNonNativeAttributes();
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = null;
for (int i = 0; i < dependingAttributes.Count; i++)
{
cai = dependingAttributes[i];
try
{
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo existingCI = metaModel.GetClassInfo
(cai.GetFullClassname(), false);
if (existingCI == null)
{
// TODO check if this getClassInfo is ok. Maybe, should
// use
// a buffered one
AddClasses(classIntrospector.Introspect(cai.GetFullClassname(), true));
}
else
{
// Even,if it exist,take the one from metamodel
cai.SetClassInfo(existingCI);
}
}
catch (System.Exception e)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClassIntrospectionError
.AddParameter(cai.GetFullClassname()), e);
}
}
}
WriteClassInfoBody(newClassInfo, fsi.GetAvailablePosition(), true);
return newClassInfo;
}