本文整理汇总了C#中sones.GraphDB.TypeManagement.GraphDBType.GetAllAttributeIndices方法的典型用法代码示例。如果您正苦于以下问题:C# GraphDBType.GetAllAttributeIndices方法的具体用法?C# GraphDBType.GetAllAttributeIndices怎么用?C# GraphDBType.GetAllAttributeIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sones.GraphDB.TypeManagement.GraphDBType
的用法示例。
在下文中一共展示了GraphDBType.GetAllAttributeIndices方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveDBObject
/// <summary>
/// Removes a DBObject.
/// </summary>
/// <param name="myGraphType">The Type of the DBObject that is to be removed.</param>
/// <param name="myDBObject">The UUID of the DBObject.</param>
public Exceptional RemoveDBObject(GraphDBType myTypeOfDBObject, DBObjectStream myDBObject, DBObjectCache myDBObjectCache, SessionSettings myToken)
{
#region Input exceptions
if (myTypeOfDBObject == null)
{
return new Exceptional(new Error_ArgumentNullOrEmpty("myTypeOfDBObject"));
}
if (myDBObject == null)
{
return new Exceptional(new Error_ArgumentNullOrEmpty("myUUID"));
}
#endregion
#region Data
ObjectLocation myDBObjectLocation;
#endregion
// Get DBObject path
myDBObjectLocation = myDBObject.ObjectLocation;
#region remove from attributeIDX
foreach (var anIndex in myTypeOfDBObject.GetAllAttributeIndices(false))
{
anIndex.Remove(myDBObject, myTypeOfDBObject, _DBContext);
}
#endregion
#region remove from fs
#region Remove DBOBJECTSTREAM
var _RemoveObjectExceptional = _IGraphFSSession.RemoveObjectIfExists(myDBObjectLocation, DBConstants.DBOBJECTSTREAM);
if (_RemoveObjectExceptional.Failed())
{
return _RemoveObjectExceptional;
}
#endregion
#region Remove DBBACKWARDEDGESTREAM
_RemoveObjectExceptional = _IGraphFSSession.RemoveObjectIfExists(myDBObjectLocation, DBConstants.DBBACKWARDEDGESTREAM);
if (_RemoveObjectExceptional.Failed())
{
return _RemoveObjectExceptional;
}
#endregion
#region Remove UNDEFATTRIBUTESSTREAM
_RemoveObjectExceptional = _IGraphFSSession.RemoveObjectIfExists(myDBObjectLocation, DBConstants.UNDEFATTRIBUTESSTREAM);
if (_RemoveObjectExceptional.Failed())
{
return _RemoveObjectExceptional;
}
#endregion
#endregion
return Exceptional.OK;
}
示例2: Update
//.........这里部分代码省略.........
if (CheckConstraint.Failed())
return new QueryResult(CheckConstraint.IErrors);
}
}
#endregion
#region regular update
foreach (var aDBO in myDBObjects)
{
//key: attribute name
//value: TypeAttribute, NewValue
Dictionary<String, Tuple<TypeAttribute, IObject>> attrsForResult = new Dictionary<String, Tuple<TypeAttribute, IObject>>();
if (aDBO.Failed())
{
return new QueryResult(aDBO);
}
#region data
Boolean sthChanged = false;
#endregion
#region iterate tasks
//Exceptional<Boolean> partialResult;
foreach (var attributeUpdateOrAssign in myListOfUpdates)
{
var updateResult = attributeUpdateOrAssign.Update(myDBContext, aDBO.Value, myGraphDBType);
if (updateResult.Failed())
{
return new QueryResult(updateResult);
}
if (updateResult.Value.Count > 0)
{
sthChanged = true;
attrsForResult.AddRange(updateResult.Value);
}
}
#endregion
if (sthChanged)
{
var definedAttributes = ExtractDefinedAttributes(attrsForResult, myDBContext.DBTypeManager);
#region update Idx
foreach (var _AttributeIndex in myGraphDBType.GetAllAttributeIndices())
{
if(definedAttributes.Exists(item => _AttributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.Contains(item.Key.Definition.UUID)))
{
//execute update
_AttributeIndex.Update(aDBO.Value, myGraphDBType, myDBContext);
}
}
#endregion
#region update dbobjects on fs
var flushResult = myDBContext.DBObjectManager.FlushDBObject(aDBO.Value);
if (!flushResult.Success())
{
return new QueryResult(flushResult);
}
#endregion
var resultSet = GetManipulationResultSet(myDBContext, aDBO, myGraphDBType, undefinedAttributes: ExtractUndefindedAttributes(attrsForResult), attributes: definedAttributes);
if (!resultSet.Success())
{
/*
what should happen now
this should not break the update
*/
}
queryResultContent.Add(resultSet.Value);
}
}
#endregion
#region Return all affected dbObjectUUIDs
queryResult.Vertices = queryResultContent;
return queryResult;
#endregion
}
示例3: RemoveTypeFromFs
/// <summary>
/// Removes GraphTypes from filesystem
/// </summary>
/// <param name="typeDir">The directory of the GraphType that is going to be deleted.</param>
/// <returns>True for success or otherwise false.</returns>
private Exceptional<Boolean> RemoveTypeFromFs(GraphDBType toBeDeletedType)
{
using (var _Transaction = _IGraphFSSession.BeginFSTransaction())
{
#region remove Objects directory
foreach (var aObjectDirectoryShard in GetObjectDirectoryShards(toBeDeletedType))
{
#region remove every DBObjectStream
var shardsDir = toBeDeletedType.ObjectLocation + DBConstants.DBObjectsLocation + aObjectDirectoryShard;
foreach (var aDBObject in _IGraphFSSession.GetDirectoryListing(shardsDir, kv => kv.Value.ObjectStreamsList.Contains(DBConstants.DBOBJECTSTREAM)).Value)
{
//make shure that BackwardEdgeStream and UndefinedAttributeStream are also deleted
var removeIdxShardExcept = _IGraphFSSession.RemoveFSObject(shardsDir + aDBObject, DBConstants.DBOBJECTSTREAM, null, null);
if (removeIdxShardExcept.Failed())
{
return new Exceptional<bool>(removeIdxShardExcept); // return and rollback transaction
}
}
#endregion
#region remove the shard directory
var removeObjectShardExcept = _IGraphFSSession.RemoveDirectoryObject(shardsDir, true);
if (removeObjectShardExcept.Failed())
{
return new Exceptional<bool>(removeObjectShardExcept); // return and rollback transaction
}
#endregion
}
#region remove the Objects directory
var removeObjectsDirExcept = _IGraphFSSession.RemoveDirectoryObject(toBeDeletedType.ObjectLocation + DBConstants.DBObjectsLocation, true);
if (removeObjectsDirExcept.Failed())
{
return new Exceptional<bool>(removeObjectsDirExcept); // return and rollback transaction
}
#endregion
#endregion
#region remove Indices directory
foreach (var aAttributeIDX in toBeDeletedType.GetAllAttributeIndices(false))
{
#region remove the shards
var shards = _IGraphFSSession.GetDirectoryListing(aAttributeIDX.FileSystemLocation, kv => kv.Value.ObjectStreamsList.Contains(DBConstants.DBINDEXSTREAM));
foreach (var aIdxShard in shards.Value)
{
var removeIdxShardExcept = _IGraphFSSession.RemoveFSObject(aAttributeIDX.FileSystemLocation + aIdxShard, DBConstants.DBINDEXSTREAM, null, null);
if (removeIdxShardExcept.Failed())
{
return new Exceptional<bool>(removeIdxShardExcept); // return and rollback transaction
}
}
#endregion
#region remove the idx directory itself
var removeIDXDirExcept = _IGraphFSSession.RemoveDirectoryObject(aAttributeIDX.FileSystemLocation, true);
if (removeIDXDirExcept.Failed())
{
return new Exceptional<bool>(removeIDXDirExcept); // return and rollback transaction
}
#endregion
}
#endregion
#region remove the type
var removeObjectExcept = _IGraphFSSession.RemoveFSObject(toBeDeletedType.ObjectLocation, DBConstants.DBTYPESTREAM, null, null);
if (removeObjectExcept.Failed())
{
return new Exceptional<bool>(removeObjectExcept); // return and rollback transaction
}
#endregion
//.........这里部分代码省略.........
示例4: Truncate
public Exceptional Truncate(DBContext myDBContext, GraphDBType myGraphDBType)
{
#region Remove
#region remove dbobjects
var listOfAffectedDBObjects = myDBContext.DBObjectCache.SelectDBObjectsForLevelKey(new LevelKey(myGraphDBType, myDBContext.DBTypeManager), myDBContext).ToList();
foreach (var aDBO in listOfAffectedDBObjects)
{
if (!aDBO.Success())
{
return new Exceptional(aDBO);
}
var dbObjID = aDBO.Value.ObjectUUID;
var dbBackwardEdgeLoadExcept = myDBContext.DBObjectManager.LoadBackwardEdge(aDBO.Value.ObjectLocation);
if (!dbBackwardEdgeLoadExcept.Success())
return new Exceptional(dbBackwardEdgeLoadExcept);
var dbBackwardEdges = dbBackwardEdgeLoadExcept.Value;
var result = myDBContext.DBObjectManager.RemoveDBObject(myGraphDBType, aDBO.Value, myDBContext.DBObjectCache, myDBContext.SessionSettings);
if (!result.Success())
{
return new Exceptional(result);
}
if (dbBackwardEdges != null)
{
var deleteReferences = DeleteObjectReferences(dbObjID, dbBackwardEdges, myDBContext);
if (!deleteReferences.Success())
return new Exceptional(deleteReferences);
}
}
#endregion
#region remove indices
Parallel.ForEach(myGraphDBType.GetAllAttributeIndices(false), aIdx =>
{
//it is not necessary to clear the UUID IDX because this is done by deleting the objects in the fs
aIdx.ClearAndRemoveFromDisc(myDBContext.DBIndexManager);
});
#endregion
#endregion
return Exceptional.OK;
}
示例5: Execute
public override Exceptional Execute(DBContext dbContext, GraphDBType graphDBType)
{
var listOfTypeAttrs = new List<TypeAttribute>();
var retExcept = new Exceptional();
foreach (var attr in _ListOfAttributes)
{
var typeAttr = graphDBType.GetTypeAttributeByName(attr);
if (typeAttr == null)
{
return new Exceptional(new Error_AttributeIsNotDefined(attr));
}
var attrType = dbContext.DBTypeManager.GetTypeByUUID(typeAttr.DBTypeUUID);
if (attrType == null)
return new Exceptional(new Error_TypeDoesNotExist(""));
if (attrType.IsUserDefined)
return new Exceptional(new Error_InvalidReferenceAssignmentOfUndefAttr());
listOfTypeAttrs.Add(typeAttr);
}
var dbobjects = dbContext.DBObjectCache.SelectDBObjectsForLevelKey(new LevelKey(graphDBType, dbContext.DBTypeManager), dbContext);
foreach (var item in dbobjects)
{
if (!item.Success())
{
retExcept.PushIExceptional(item);
}
else
{
foreach (var attr in listOfTypeAttrs)
{
if (item.Value.HasAttribute(attr.UUID, graphDBType))
{
var attrVal = item.Value.GetAttribute(attr.UUID);
var addExcept = item.Value.AddUndefinedAttribute(attr.Name, attrVal, dbContext.DBObjectManager);
if (!addExcept.Success())
retExcept.PushIExceptional(addExcept);
item.Value.RemoveAttribute(attr.UUID);
var saveExcept = dbContext.DBObjectManager.FlushDBObject(item.Value);
if (!saveExcept.Success())
retExcept.PushIExceptional(saveExcept);
}
}
}
}
var indices = graphDBType.GetAllAttributeIndices();
List<AAttributeIndex> idxToDelete = new List<AAttributeIndex>();
//remove attributes from type
foreach (var attr in listOfTypeAttrs)
{
foreach (var item in indices)
{
var index = item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Find(idx => idx == attr.UUID);
if (index != null && item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count == 1)
{
idxToDelete.Add(item);
}
}
//remove indices
foreach (var idx in idxToDelete)
{
var remExcept = graphDBType.RemoveIndex(idx.IndexName, idx.IndexEdition, dbContext.DBTypeManager);
if (!remExcept.Success())
{
retExcept.PushIExceptional(remExcept);
}
}
idxToDelete.Clear();
graphDBType.RemoveAttribute(attr.UUID);
var flushExcept = dbContext.DBTypeManager.FlushType(graphDBType);
if (!flushExcept.Success())
{
retExcept.PushIExceptional(flushExcept);
}
}
//.........这里部分代码省略.........
示例6: CreateGraphDDL
private String CreateGraphDDL(DumpFormats myDumpFormat, GraphDBType myGraphDBType, DBContext myDBContext)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendFormat("{0} ", myGraphDBType.Name);
if (myGraphDBType.ParentTypeUUID != null)
{
stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myGraphDBType.GetParentType(myDBContext.DBTypeManager).Name);//builder.AppendLine();
#region Not backwardEdge attributes
if (myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge).CountIsGreater(0))
{
stringBuilder.Append(S_ATTRIBUTES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfAttributes(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " ");
}
#endregion
#region BackwardEdge attributes
if (myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge).CountIsGreater(0))
{
stringBuilder.Append(S_BACKWARDEDGES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfBackwardEdges(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " ");
}
#endregion
#region Uniques
if (myGraphDBType.GetUniqueAttributes().CountIsGreater(0))
{
stringBuilder.Append(S_UNIQUE.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetUniqueAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
}
#endregion
#region Mandatory attributes
if (myGraphDBType.GetMandatoryAttributes().CountIsGreater(0))
{
stringBuilder.Append(S_MANDATORY.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetMandatoryAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
}
#endregion
#region Indices
if (myGraphDBType.GetAllAttributeIndices(false).CountIsGreater(0))
{
stringBuilder.Append(S_INDICES.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfIndices(myDumpFormat, myGraphDBType.GetAllAttributeIndices(false), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
}
#endregion
}
return stringBuilder.ToString();
}
示例7: GenerateIndicesOutput
/// <summary>
/// output for the type attributes
/// </summary>
/// <param name="myGraphDBType">The db type</param>
/// <param name="myDBContext">The db context</param>
/// <returns>a list of readouts, contains the attributes</returns>
private IEnumerable<IVertex> GenerateIndicesOutput(GraphDBType myGraphDBType, DBContext myDBContext)
{
var _AttributeReadout = new List<Vertex>();
foreach (var idx in myGraphDBType.GetAllAttributeIndices(myDBContext, false))
{
var Attributes = new Dictionary<String, Object>();
Attributes.Add("UUID", idx.ObjectUUID);
Attributes.Add("TYPE", idx.IndexType);
Attributes.Add("Name", idx.IndexName);
Attributes.Add("Edition", idx.IndexEdition);
_AttributeReadout.Add(new Vertex(Attributes));
}
return _AttributeReadout;
}
示例8: RemoveTypeFromFs
/// <summary>
/// Removes GraphTypes from filesystem
/// </summary>
/// <param name="typeDir">The directory of the GraphType that is going to be deleted.</param>
/// <returns>True for success or otherwise false.</returns>
private Exceptional<Boolean> RemoveTypeFromFs(DBContext myDBContext, GraphDBType toBeDeletedType)
{
using (var _Transaction = _IGraphFSSession.BeginFSTransaction())
{
#region remove the Objects directory
var removeObjectsDirExcept = _IGraphFSSession.RemoveDirectoryObject(toBeDeletedType.ObjectLocation + DBConstants.DBObjectsLocation, true);
if (removeObjectsDirExcept.Failed())
{
return new Exceptional<bool>(removeObjectsDirExcept); // return and rollback transaction
}
#endregion
#region remove Indices directory
foreach (var aAttributeIDX in toBeDeletedType.GetAllAttributeIndices(myDBContext, false))
{
aAttributeIDX.ClearAndRemoveFromDisc(_DBContext);
}
#endregion
#region remove the type
var removeObjectExcept = _IGraphFSSession.RemoveFSObject(toBeDeletedType.ObjectLocation, DBConstants.DBTYPESTREAM, null, null);
if (removeObjectExcept.Failed())
{
return new Exceptional<bool>(removeObjectExcept); // return and rollback transaction
}
#endregion
var removeDirExcept = _IGraphFSSession.RemoveDirectoryObject(toBeDeletedType.ObjectLocation, true);
if (removeDirExcept.Failed())
{
return new Exceptional<bool>(removeDirExcept); // return and rollback transaction
}
_Transaction.Commit();
}
return new Exceptional<bool>(true);
}