Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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;
        }