コード例 #1
0
ファイル: NotInOperator.cs プロジェクト: Vadi/sones
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var result = myIndex.Contains(lookup, currentType, dbContext);
            if (result.Value)
            {
                var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);

                foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        if (!interestingUUIDs.Contains(aUUID))
                        {
                            yield return aUUID;
                        }
                    }
                }
            }
            else
            {
                foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
コード例 #2
0
ファイル: InRangeOperator.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> IndexOperation(AAttributeIndex myIndex, TupleDefinition myTuple, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            if (myTuple.Count() != 2)
            {
                throw new GraphDBException(new Error_InvalidInRangeInterval(2, myTuple.Count()));
            }

            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            #region As soon as the index supports ranges use them!!

            //limits
            var fromKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(0).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
            var toKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(1).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);

            switch (myTuple.KindOfTuple)
            {
                case KindOfTuple.Inclusive:
                    return myIndex.InRange(fromKey, toKey, true, true, currentType, dbContext);
                case KindOfTuple.LeftExclusive:
                    return myIndex.InRange(fromKey, toKey, false, true, currentType, dbContext);
                case KindOfTuple.RightExclusive:
                    return myIndex.InRange(fromKey, toKey, true, false, currentType, dbContext);
                case KindOfTuple.Exclusive:
                    return myIndex.InRange(fromKey, toKey, false, false, currentType, dbContext);
                default:
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
            }

            #endregion
        }
コード例 #3
0
ファイル: EqualsOperator.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            var myIndeyKey = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            if (myIndex.Contains(myIndeyKey, currentType, dbContext))
            {
                foreach (var aUUID in myIndex.GetValues(myIndeyKey, currentType, dbContext))
                {
                    yield return aUUID;
                }
            }

            yield break;
        }
コード例 #4
0
ファイル: HashTableIndex.cs プロジェクト: Vadi/sones
        /// <summary>
        /// <seealso cref=" IAttributeIndex"/>
        /// </summary>
        public override IEnumerable<ObjectUUID> InRange(IndexKey fromIndexKey, IndexKey toIndexKey, bool myOrEqualFromKey, bool myOrEqualToKey, GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            VerifyIndexDatastructure(myDBContext, myTypeOfDBObject);

            foreach (var aUUID in _indexDatastructure.InRange(fromIndexKey, toIndexKey, myOrEqualFromKey, myOrEqualToKey))
            {
                yield return aUUID;
            }

            yield break;
        }
コード例 #5
0
ファイル: AttributeIndex.cs プロジェクト: TheByte/sones
 /// <summary>
 /// Get the shard id corresponding to an indexKey
 /// </summary>
 /// <param name="aIndexKey">An IndexKey</param>
 /// <returns>The shard id</returns>
 private int GetIndexShardID(IndexKey aIndexKey)
 {
     //stupid... might be solved by constant hashing or sth like that
     return Math.Abs(aIndexKey.GetHashCode()) % AttributeIdxShards;
 }
コード例 #6
0
ファイル: AAttributeIndex.cs プロジェクト: ipbi/sones
 public abstract IEnumerable<ObjectUUID> InRange(IndexKey fromIndexKey, IndexKey toIndexKey, bool myOrEqualFromKey, bool myOrEqualToKey, GraphDBType myTypeOfDBObject, DBContext dbContext);
コード例 #7
0
ファイル: AttributeIndex.cs プロジェクト: ipbi/sones
        public override IEnumerable<ObjectUUID> GetValues(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            #region Get index reference

            var idxRef = GetIndexReference(dbContext.DBIndexManager);
            if (idxRef.Failed())
            {
                throw new GraphDBException(new Error_CouldNotGetIndexReference(idxRef.IErrors, IndexName, IndexEdition));
            }
            var idxRefVal = idxRef.Value;

            #endregion

            if (idxRefVal != null)
            {
                return idxRef.Value[myIndeyKey];
            }
            else
            {
                throw new GraphDBException(new Error_InvalidIndexReference(IndexName, IndexEdition));
            }
        }
コード例 #8
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        internal Exceptional Remove(IndexKey indexKey, int shard, DBIndexManager myDBIndexManager)
        {
            //get the actual shard
            var currentIdxShard = GetIndexReference(myDBIndexManager, shard);

            if (!currentIdxShard.Success())
            {
                return new Exceptional(currentIdxShard);
            }

            HashSet<ObjectUUID> removedItems = null;

            currentIdxShard.Value.TryGetValue(indexKey, out removedItems);

            if (removedItems != null)
            {
                currentIdxShard.Value.Remove(indexKey);

                DecreaseKeyCount();

                DecreaseValueCount((UInt64)removedItems.Count);
            }

            return Exceptional.OK;
        }
コード例 #9
0
ファイル: AAttributeIndex.cs プロジェクト: ipbi/sones
 public abstract bool Contains(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext);
コード例 #10
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        /// <summary>
        /// <seealso cref=" IAtributeIndex"/>
        /// </summary>        
        public override Exceptional<bool> Contains(IndexKey myIndexKey, GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            #region get the shard

            //get the actual shard
            var currentIdxShard = GetIndexReference(myDBContext.DBIndexManager, myDBContext.DBIndexManager.GetIndexShardID(myIndexKey, this.AttributeIdxShards));

            if (!currentIdxShard.Success())
            {
                throw new GraphDBException(new Error_CouldNotGetIndexReference(currentIdxShard.IErrors, IndexName, IndexEdition, myDBContext.DBIndexManager.GetIndexShardID(myIndexKey, this.AttributeIdxShards)));
            }

            var currentIdxShardValue = currentIdxShard.Value;

            #endregion

            return new Exceptional<bool>(currentIdxShardValue.ContainsKey(myIndexKey));
        }
コード例 #11
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        /// <summary>
        /// <seealso cref=" IShardedHashTableIndex"/>
        /// </summary>
        public override IEnumerable<ObjectUUID> InRange(IndexKey fromIndexKey, IndexKey toIndexKey, bool myOrEqualFromKey, bool myOrEqualToKey, GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            //TODO: PERFORMANCE BUG!!!!!!!

            foreach (var aIdxShardExceptional in GetAllIdxShards(myDBContext))
            {
                #region get the shard

                if (!aIdxShardExceptional.Item2.Success())
                {
                    throw new GraphDBException(new Error_CouldNotGetIndexReference(aIdxShardExceptional.Item2.IErrors, IndexName, IndexEdition, aIdxShardExceptional.Item1));
                }

                var idxRefVal = aIdxShardExceptional.Item2.Value;

                #endregion

                foreach (var aUUID in idxRefVal.InRange(fromIndexKey, toIndexKey, myOrEqualFromKey, myOrEqualToKey))
                {
                    yield return aUUID;
                }
            }

            yield break;
        }
コード例 #12
0
ファイル: UUIDIndex.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> GetValues(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            if (Contains(myIndeyKey, myTypeOfDBObject, dbContext))
            {
                //this has to work, because the same thing has been tested during contains
                yield return (ObjectUUID)myIndeyKey.IndexKeyValues[0].Value;
            }

            yield break;
        }
コード例 #13
0
ファイル: UUIDIndex.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> InRange(IndexKey fromIndexKey, IndexKey toIndexKey, bool myOrEqualFromKey, bool myOrEqualToKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            var fromUUID = (ObjectUUID)fromIndexKey.IndexKeyValues[0].Value;
            var toUUID = (ObjectUUID)toIndexKey.IndexKeyValues[0].Value;

            if (fromUUID <= toUUID)
            {
                #region <=

                if (myOrEqualFromKey && myOrEqualToKey)
                {
                    foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item >= fromUUID) && (item <= toUUID);
                        }))
                    {
                        yield return aUUID;
                    }
                }
                else
                {
                    if (!myOrEqualFromKey && myOrEqualToKey)
                    {
                        foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item > fromUUID) && (item <= toUUID);
                        }))
                        {
                            yield return aUUID;
                        }
                    }
                    else
                    {
                        if (myOrEqualFromKey && !myOrEqualToKey)
                        {
                            foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                            {
                                return (item >= fromUUID) && (item < toUUID);
                            }))
                            {
                                yield return aUUID;
                            }
                        }
                        else
                        {
                            foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                            {
                                return (item > fromUUID) && (item < toUUID);
                            }))
                            {
                                yield return aUUID;
                            }
                        }
                    }
                }

                #endregion
            }
            else
            {
                if (fromUUID == toUUID)
                {
                    #region ==

                    if (Contains(fromIndexKey, myTypeOfDBObject, dbContext))
                    {
                        yield return (ObjectUUID)fromIndexKey.IndexKeyValues[0].Value;
                    }

                    #endregion
                }
                else
                {
                    #region >

                    #region part 1

                    if (myOrEqualToKey)
                    {
                        foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item >= fromUUID);
                        }))
                        {
                            yield return aUUID;
                        }
                    }
                    else
                    {
                        foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item > fromUUID);
                        }))
                        {
                            yield return aUUID;
                        }
                    }

                    #endregion

                    #region part 2

                    if (myOrEqualFromKey)
                    {
                        foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item <= toUUID);
                        }))
                        {
                            yield return aUUID;
                        }
                    }
                    else
                    {
                        foreach (var aUUID in GetAllUUIDs(myTypeOfDBObject, dbContext).Where(item =>
                        {
                            return (item < toUUID);
                        }))
                        {
                            yield return aUUID;
                        }
                    }

                    #endregion

                    #endregion
                }
            }

            yield break;
        }
コード例 #14
0
ファイル: UUIDIndex.cs プロジェクト: TheByte/sones
        public override Boolean Contains(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            if (myIndeyKey.IndexKeyValues.Count == 1)
            {
                var uuid = myIndeyKey.IndexKeyValues[0].Value as ObjectUUID;

                if(uuid == null)
                {
                    throw new GraphDBException(new Error_InvalidIndexOperation(IndexName));
                }
                else
                {
                    return GetDirectoryObject(myTypeOfDBObject, uuid, dbContext).ObjectExists(uuid.ToString());
                }
            }
            else
            {
                throw new GraphDBException(new Error_InvalidIndexOperation(IndexName));
            }
        }
コード例 #15
0
ファイル: AAttributeIndex.cs プロジェクト: Vadi/sones
 /// <summary>
 /// This method checks if the current attribute index contains a DBObject
 /// </summary>
 /// <param name="myIndexKey">The DBObject that should be checked</param>
 /// <param name="myTypeOfDBObject">The Type of the DBObject</param>
 /// <param name="myDBContext">The db context</param>
 /// <returns>boolean</returns>
 public abstract Exceptional<bool> Contains(IndexKey myIndexKey, GraphDBType myTypeOfDBObject, DBContext myDBContext);
コード例 #16
0
ファイル: HashTableIndex.cs プロジェクト: Vadi/sones
        private void SetIndexKeyAndValue(IndexKey myIndexKey, ObjectUUID objectUUID, IndexSetStrategy myIndexSetStrategy)
        {
            HashSet<ObjectUUID> value = null;

            var valueCount = 1UL;

            if (!_indexDatastructure.TryGetValue(myIndexKey, out value))
            {
                //so there is one more key...
                IncreaseKeyCount();
                IncreaseValueCount(valueCount);
            }
            else
            {
                if (!value.Contains(objectUUID))
                {
                    IncreaseValueCount(valueCount);
                }
            }

            _indexDatastructure.Set(myIndexKey, objectUUID, myIndexSetStrategy);
            this.Save();
        }
コード例 #17
0
ファイル: HashTableIndex.cs プロジェクト: Vadi/sones
        private Exceptional Insert(IndexKey indexKey, HashSet<ObjectUUID> hashSet, int shard, DBIndexManager dBIndexManager, GraphDBType myTypeOfDBObject)
        {
            #region Check for uniqueness - TODO: remove me as soon as we have a unique indexObject implementation

            if (IsUniqueAttributeIndex)
            {
                if (_indexDatastructure.ContainsKey(indexKey))
                {
                    return new Exceptional(new Error_UniqueConstrainViolation(myTypeOfDBObject.Name, IndexName));
                }
            }

            #endregion

            UInt64 previousKeyCount = _keyCount;

            HashSet<ObjectUUID> value = null;

            _indexDatastructure.TryGetValue(indexKey, out value);

            if (value == null)
            {
                _indexDatastructure.Set(indexKey, hashSet, IndexSetStrategy.MERGE);

                IncreaseKeyCount();

                IncreaseValueCount((UInt64)hashSet.Count);
            }
            else
            {
                _indexDatastructure.Add(indexKey, hashSet);

                IncreaseValueCount((UInt64)_indexDatastructure[indexKey].Count);
            }

            return Exceptional.OK;
        }
コード例 #18
0
ファイル: HashTableIndex.cs プロジェクト: Vadi/sones
        internal Exceptional Remove(IndexKey indexKey)
        {
            HashSet<ObjectUUID> removedItems = null;

            _indexDatastructure.TryGetValue(indexKey, out removedItems);

            if (removedItems != null)
            {
                _indexDatastructure.Remove(indexKey);

                DecreaseKeyCount();

                DecreaseValueCount((UInt64)removedItems.Count);
            }

            return Exceptional.OK;
        }
コード例 #19
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        /// <summary>
        /// <seealso cref=" IShardedHashTableIndex"/>
        /// </summary>
        public override IEnumerable<ObjectUUID> GetValues(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            #region get the shard

            //get the actual shard
            var currentIdxShard = GetIndexReference(dbContext.DBIndexManager, dbContext.DBIndexManager.GetIndexShardID(myIndeyKey, this.AttributeIdxShards));

            if (!currentIdxShard.Success())
            {
                throw new GraphDBException(new Error_CouldNotGetIndexReference(currentIdxShard.IErrors, IndexName, IndexEdition, dbContext.DBIndexManager.GetIndexShardID(myIndeyKey, this.AttributeIdxShards)));
            }
            var currentIdxShardValue = currentIdxShard.Value;

            #endregion

            return currentIdxShardValue[myIndeyKey];
        }
コード例 #20
0
ファイル: DBIndexManager.cs プロジェクト: Vadi/sones
 /// <summary>
 /// Get the shard id corresponding to an indexKey
 /// </summary>
 /// <param name="aIndexKey">An IndexKey</param>
 /// <returns>The shard id</returns>
 public int GetIndexShardID(IndexKey aIndexKey, UInt16 shardCount)
 {
     //stupid... might be solved by constant hashing or sth like that
     return Math.Abs(aIndexKey.GetHashCode()) % shardCount;
 }
コード例 #21
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        internal Exceptional Insert(IndexKey indexKey, HashSet<ObjectUUID> hashSet, int shard, DBIndexManager dBIndexManager, GraphDBType myTypeOfDBObject)
        {
            //get the actual shard
            var currentIdxShard = GetIndexReference(dBIndexManager, shard);

            if (!currentIdxShard.Success())
            {
                return new Exceptional(currentIdxShard);
            }

            #region Check for uniqueness - TODO: remove me as soon as we have a unique indexObject implementation

            if (IsUniqueAttributeIndex)
            {
                if (currentIdxShard.Value.ContainsKey(indexKey))
                {
                    return new Exceptional(new Error_UniqueConstrainViolation(myTypeOfDBObject.Name, IndexName));
                }
            }

            #endregion

            UInt64 previousKeyCount = currentIdxShard.Value.KeyCount();

            HashSet<ObjectUUID> value = null;

            currentIdxShard.Value.TryGetValue(indexKey, out value);

            if (value == null)
            {
                currentIdxShard.Value.Set(indexKey, hashSet, IndexSetStrategy.MERGE);

                IncreaseKeyCount();

                IncreaseValueCount((UInt64)hashSet.Count);
            }
            else
            {
                currentIdxShard.Value.Add(indexKey, hashSet);

                IncreaseValueCount((UInt64)currentIdxShard.Value[indexKey].Count);
            }

            return Exceptional.OK;
        }
コード例 #22
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
        public Boolean Equals(IndexKey p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            if (this._indexKeyValues.Count != p.IndexKeyValues.Count)
            {
                return false;
            }

            for (int i = 0; i < _indexKeyValues.Count; i++)
            {
                if (!p.IndexKeyValues[i].Equals(this._indexKeyValues[i]))
                {
                    return false;
                }
            }

            return true;
        }
コード例 #23
0
ファイル: ShardedHashTableIndex.cs プロジェクト: Vadi/sones
        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);
        }
コード例 #24
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
        private object Deserialize(ref SerializationReader mySerializationReader, IndexKey myValue)
        {
            UInt32 count = mySerializationReader.ReadUInt32();
            for (UInt32 i = 0; i < count; i++)
            {
                var a = (ADBBaseObject)mySerializationReader.ReadObject();

                myValue._indexKeyValues.Add(a);

                CalcNewHashCode(a, ref myValue._hashCode);
            }

            return myValue;
        }
コード例 #25
0
ファイル: AAttributeIndex.cs プロジェクト: ipbi/sones
 public abstract IEnumerable<ObjectUUID> GetValues(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext);
コード例 #26
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
 private void Serialize(ref SerializationWriter mySerializationWriter, IndexKey myValue)
 {
     mySerializationWriter.WriteUInt32((UInt32)myValue.IndexKeyValues.Count);
     foreach (var attr in myValue.IndexKeyValues)
     {
         //attr.Serialize(ref mySerializationWriter);
         mySerializationWriter.WriteObject(attr);
     }
 }
コード例 #27
0
ファイル: InOperator.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> IndexOperation(AAttributeIndex myIndex, TupleDefinition myTuple, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            HashSet<ObjectUUID> interestingUUIDs = new HashSet<ObjectUUID>();
            IndexKey idxLookupKey = null;
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var myOperationValues = myTuple;

            switch (typeOfBinExpr)
            {
                case TypesOfBinaryExpression.LeftComplex:

                    if (!myIndex.IsListOfBaseObjectsIndex)
                    {
                        foreach (var aItem in myOperationValues)
                        {
                            idxLookupKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (aItem.Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
                            interestingUUIDs.UnionWith(myIndex.GetValues(idxLookupKey, currentType, dbContext));
                        }
                    }
                    else
                    {
                        #region In case the index is from a set or list of baseobjects we use this way to get the values

                        foreach (var aItem in myOperationValues)
                        {
                            idxLookupKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (aItem.Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
                            interestingUUIDs.UnionWith(myIndex.GetValues(idxLookupKey, currentType, dbContext));
                        }

                        /* What the hack is that??? - This is too slow for any usual usage of in operator! */

                        var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

                        foreach (var aKey in myIndex.GetKeys(currentType, dbContext).Where(item => !myOperationValues.Contains(new TupleElement(new ValueDefinition(item.IndexKeyValues[0])))))
                        {
                            foreach (var aMatch in myIndex.GetValues(aKey, indexRelatedType, dbContext).Intersect(interestingUUIDs))
                            {
                                interestingUUIDs.Remove(aMatch);
                            }
                        }

                        #endregion
                    }

                    break;

                case TypesOfBinaryExpression.RightComplex:

                    var myEnumerator = myOperationValues.GetEnumerator();

                    if (myEnumerator.MoveNext())
                    {
                        idxLookupKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myEnumerator.Current.Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);

                        interestingUUIDs.UnionWith(myIndex.GetValues(idxLookupKey, currentType, dbContext));

                        while (myEnumerator.MoveNext())
                        {
                            idxLookupKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myEnumerator.Current.Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
                            interestingUUIDs.IntersectWith(myIndex.GetValues(idxLookupKey, currentType, dbContext));
                        }
                    }

                    break;

                case TypesOfBinaryExpression.Atom:
                case TypesOfBinaryExpression.Complex:
                case TypesOfBinaryExpression.Unknown:
                default:
                    break;
            }

            foreach (var aValidUUID in interestingUUIDs)
            {
                yield return aValidUUID;
            }

            yield break;
        }
コード例 #28
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
        /// <summary>
        /// Instantiates a new IndexKey on the base of another one. Additionally a AADBBaseObject is added.
        /// </summary>
        /// <param name="myStartingIndexKey">The base of the new IndexKey</param>
        /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
        /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
        /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
        public IndexKey(IndexKey myStartingIndexKey, AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
        {
            _hashCode = myStartingIndexKey.GetHashCode();

            _indexKeyValues.AddRange(myStartingIndexKey.IndexKeyValues);

            if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
            {
                throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
            }
            else
            {
                AddAAKey(myAttributeUUID, myIndexKeyPayload);
            }
        }
コード例 #29
0
ファイル: AttributeIndex.cs プロジェクト: ipbi/sones
        public override IEnumerable<ObjectUUID> InRange(IndexKey fromIndexKey, IndexKey toIndexKey, bool myOrEqualFromKey, bool myOrEqualToKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            #region Get index reference

            var idxRef = GetIndexReference(dbContext.DBIndexManager);
            if (idxRef.Failed())
            {
                throw new GraphDBException(new Error_CouldNotGetIndexReference(idxRef.IErrors, IndexName, IndexEdition));
            }
            var idxRefVal = idxRef.Value;

            #endregion

            if (idxRefVal != null)
            {
                return idxRefVal.InRange(fromIndexKey, toIndexKey, myOrEqualFromKey, myOrEqualToKey);
            }
            else
            {
                throw new GraphDBException(new Error_InvalidIndexReference(IndexName, IndexEdition));
            }
        }
コード例 #30
0
ファイル: AttributeIndex.cs プロジェクト: TheByte/sones
        public override Boolean Contains(IndexKey myIndeyKey, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            #region get the shard

            //get the actual shard
            var currentIdxShard = GetIndexReference(dbContext.DBIndexManager, GetIndexShardID(myIndeyKey));

            if (!currentIdxShard.Success())
            {
                throw new GraphDBException(new Error_CouldNotGetIndexReference(currentIdxShard.IErrors, IndexName, IndexEdition, GetIndexShardID(myIndeyKey)));
            }

            var currentIdxShardValue = currentIdxShard.Value;

            #endregion

            return currentIdxShardValue.ContainsKey(myIndeyKey);
        }