/// <summary> /// A reference to this index after it was loaded into the memory /// or connected by a proxy class /// </summary> /// <param name="indexManager">The database index manager</param> /// <param name="idxShard">The shard that should be loaded</param> /// <returns>A versioned idx object</returns> public Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>> GetIndexReference(DBIndexManager indexManager, int idxShard) { 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 = new VersionedHashIndexObject<IndexKey, ObjectUUID>(); var indexExceptional = indexManager.LoadOrCreateShardedDBIndex(FileSystemLocation + idxShard.ToString(), emptyIdx, this); if (indexExceptional.Failed()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(indexExceptional); } return indexExceptional; }
/// <summary> /// A reference to this index after it was loaded into the memory /// or connected by a proxy class /// </summary> /// <param name="indexManager">The database index manager</param> /// <param name="idxShard">The shard that should be loaded</param> /// <returns>A versioned idx object</returns> private Exceptional SetIndexReference(DBContext myDBContext) { var result = myDBContext.IGraphFSSession.GetOrCreateFSObject<AFSObject>(FileSystemLocation, DBConstants.DBINDEXSTREAM, () => new VersionedHashIndexObject<IndexKey, ObjectUUID>()); if (!result.Success()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result); } else { if (result.Value.isNew) { // Uncomment as soon as index is serializeable result.PushIExceptional(myDBContext.IGraphFSSession.StoreFSObject(result.Value, false)); if (result.Failed()) { return new Exceptional<IVersionedIndexObject<IndexKey, ObjectUUID>>(result); } //result.AddErrorsAndWarnings(result.Value.Save()); //ToDo: Fehler beim Speichern werden im Weiterm ignoriert statt darauf reagiert! } _indexDatastructure = result.Value as VersionedHashIndexObject<IndexKey, ObjectUUID>; } return Exceptional.OK; // var indexExceptional = indexManager.LoadOrCreateVersionedDBIndex(FileSystemLocation, new VersionedHashIndexObject<IndexKey, ObjectUUID>(), this); // if (indexExceptional.Failed()) // { // return new Exceptional(indexExceptional); // } // _indexDatastructure = indexExceptional.Value as VersionedHashIndexObject<IndexKey, ObjectUUID>; // return Exceptional.OK; //} }