/// <summary> /// A reference to this index after it was loaded into the memory /// or connected by a proxy class /// </summary> private Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>> GetIndexReference(DBIndexManager indexManager) { if (_indexReference == null) { if (!indexManager.HasIndex(IndexType)) { // the index type does not exist anymore - return null or throw exception return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(new GraphDBError("Index is away!")); } var emptyIdx = indexManager.GetIndex(IndexType); if (!emptyIdx.Success()) { return emptyIdx; } var indexExceptional = indexManager.LoadOrCreateDBIndex(FileSystemLocation, emptyIdx.Value); if (indexExceptional.Failed()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(indexExceptional); } _indexReference = indexExceptional.Value; } return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(_indexReference); }
public override Exceptional ClearAndRemoveFromDisc(DBIndexManager indexManager) { _indexReference = null; return indexManager.RemoveDBIndex(FileSystemLocation); }
internal Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>> LoadOrCreateDBIndex(ObjectLocation myShardObjectLocation, IVersionedIndexObject<IndexKey, ObjectUUID> myIIndexObject, AAttributeIndex correspondingIDX) { if (!(myIIndexObject is AFSObject)) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(new Error_IndexIsNotPersistent(myIIndexObject)); } var result = _IGraphFSSession.GetOrCreateFSObject<AFSObject>(myShardObjectLocation, DBConstants.DBINDEXSTREAM, () => myIIndexObject as AFSObject); if (!result.Success()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result); } else { if (result.Value.isNew) { //TODO: might be a performance bug if (!_IGraphFSSession.ObjectExists(correspondingIDX.FileSystemLocation).Value) { result.PushIExceptional(_IGraphFSSession.CreateDirectoryObject(correspondingIDX.FileSystemLocation)); } // Uncomment as soon as index is serializeable result.PushIExceptional(_IGraphFSSession.StoreFSObject(result.Value, false)); //result.AddErrorsAndWarnings(result.Value.Save()); //ToDo: Fehler beim Speichern werden im Weiterm ignoriert statt darauf reagiert! } return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result.Value as IVersionedIndexObject<IndexKey, ObjectUUID>); } }
private void SetIndexKeyAndValue(IVersionedIndexObject<IndexKey, ObjectUUID> currentIdxShardValue, IndexKey aIndexKex, ObjectUUID objectUUID, IndexSetStrategy myIndexSetStrategy) { UInt64 previousKeyCount = currentIdxShardValue.KeyCount(); currentIdxShardValue.Set(aIndexKex, objectUUID, myIndexSetStrategy); UInt64 afterKeyCount = currentIdxShardValue.KeyCount(); if (afterKeyCount > previousKeyCount) { //so there is one more key... IncreaseKeyCount(); } IncreaseValueCount(1UL); }
internal Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>> LoadOrCreateDBIndex(ObjectLocation myObjectLocation, IVersionedIndexObject<IndexKey, ObjectUUID> myIIndexObject) { if (!(myIIndexObject is AFSObject)) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(new Error_IndexIsNotPersistent(myIIndexObject)); } var result = _IGraphFSSession.GetOrCreateFSObject<AFSObject>(myObjectLocation, DBConstants.DBINDEXSTREAM, () => myIIndexObject as AFSObject); if (!result.Success()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result); } else { if (result.Value.isNew) { // Uncomment as soon as index is serializeable result.PushIExceptional(_IGraphFSSession.StoreFSObject(result.Value, false)); //result.AddErrorsAndWarnings(result.Value.Save()); //ToDo: Fehler beim Speichern werden im Weiterm ignoriert statt darauf reagiert! } return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result.Value as IVersionedIndexObject<IndexKey, ObjectUUID>); } }