コード例 #1
0
        public override Exceptional<bool> Contains(ObjectManagement.DBObjectStream myDBObject, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            var result =  GetIndexkeysFromDBObject(myDBObject, myTypeOfDBObject, myDBContext);
            if (result.Failed())
            {
                return result.Convert<bool>();
            }

            foreach (var aIndexKex in result.Value)
            {
                HashSet<ObjectUUID> values = null;
                if (_Index.TryGetValue(aIndexKex, out values))
                {
                    if (values.Contains(myDBObject.ObjectUUID))
                    {
                        return new Exceptional<bool>(true);
                    }
                }
            }

            return new Exceptional<bool>(false);
        }
コード例 #2
0
 public override Exceptional<bool> Contains(IndexKey myIndexKey, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
 {
     return new Exceptional<bool>(_Index.ContainsKey(myIndexKey));
 }
コード例 #3
0
 public override Lib.ErrorHandling.Exceptional Clear(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject)
 {
     _Index.Clear();
     return Exceptional.OK;
 }
コード例 #4
0
        public override Lib.ErrorHandling.Exceptional Remove(ObjectManagement.DBObjectStream myDBObject, TypeManagement.GraphDBType myTypeOfDBObjects, DBContext myDBContext)
        {
            var result = GetIndexkeysFromDBObject(myDBObject, myTypeOfDBObjects, myDBContext);

            if (result.Failed())
            {
                return result;
            }

            foreach (var aIndexKey in result.Value)
            {
                HashSet<ObjectUUID> values = null;
                if (_Index.TryGetValue(aIndexKey, out values))
                {
                    values.Remove(myDBObject.ObjectUUID);
                    if (values.Count == 0)
                    {
                        _Index.Remove(aIndexKey);
                    }
                }
            }

            return Exceptional.OK;
        }
コード例 #5
0
        public override Lib.ErrorHandling.Exceptional Update(ObjectManagement.DBObjectStream myDBObject, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            #region insert new values

            if (myDBObject.HasAtLeastOneAttribute(this.IndexKeyDefinition.IndexKeyAttributeUUIDs, myTypeOfDBObject, myDBContext.SessionSettings))
            {
                var result = GetIndexkeysFromDBObject(myDBObject, myTypeOfDBObject, myDBContext);
                if (result.Failed())
                {
                    return result;
                }
                //insert
                foreach (var aIndexKey in result.Value)
                {
                    SetIndexKeyAndValue(aIndexKey, myDBObject.ObjectUUID, IndexSetStrategy.MERGE);
                }
            }

            #endregion

            return Exceptional.OK;
        }
コード例 #6
0
 public override Lib.ErrorHandling.Exceptional Insert(ObjectManagement.DBObjectStream myDBObject, TypeManagement.GraphDBType myTypeOfDBobject, DBContext myDBContext)
 {
     return Insert(myDBObject, IndexSetStrategy.MERGE, myTypeOfDBobject, myDBContext);
 }
コード例 #7
0
        public override Lib.ErrorHandling.Exceptional Insert(ObjectManagement.DBObjectStream myDBObject, Lib.DataStructures.Indices.IndexSetStrategy myIndexSetStrategy, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            var result = GetIndexkeysFromDBObject(myDBObject, myTypeOfDBObject, myDBContext);
            if (result.Failed())
            {
                return result;
            }

            foreach (var aIndexKex in result.Value)
            {
                #region Check for uniqueness - TODO: remove me as soon as we have a unique indexObject implementation

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

                #endregion

                SetIndexKeyAndValue(aIndexKex, myDBObject.ObjectUUID, myIndexSetStrategy);
            }

            return Exceptional.OK;
        }
コード例 #8
0
        public override Lib.ErrorHandling.Exceptional Initialize(DBContext myDBContext, string indexName, IndexKeyDefinition idxKey, TypeManagement.GraphDBType correspondingType, string indexEdition = DBConstants.DEFAULTINDEX)
        {
            _Index = new Dictionary<IndexKey, HashSet<ObjectUUID>>();
            IndexKeyDefinition = idxKey;
            IndexEdition = indexEdition;
            IndexName = indexName;
            IndexRelatedTypeUUID = correspondingType.UUID;

            _IsUUIDIndex = idxKey.IndexKeyAttributeUUIDs.Count == 1 && idxKey.IndexKeyAttributeUUIDs[0].Equals(myDBContext.DBTypeManager.GetUUIDTypeAttribute().UUID);

            return Exceptional.OK;
        }
コード例 #9
0
        public override IEnumerable<GraphFS.DataStructures.ObjectUUID> InRange(IndexKey myFromKey, IndexKey myToKey, bool myOrEqualFromKey, bool myOrEqualToKey, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
        {
            HashSet<ObjectUUID> resultSet;

            #region myFromKey == myToKey

            if (myFromKey.CompareTo(myToKey) == 0) //from and to are the same
            {
                //lower or upper bound included?
                if (myOrEqualFromKey || myOrEqualToKey)
                {
                    if (_Index.TryGetValue(myFromKey, out resultSet))
                    {
                        foreach (var val in resultSet)
                        {
                            yield return val;
                        }
                    }
                }
                //keys are equal, but the bounds themselves are not included in the search
            }

            #endregion

            #region myFromKey > myToKey

            else if (myFromKey.CompareTo(myToKey) == 1)
            {
                //check bounds

                //1st return all values between fromKey and most right key in the tree
                foreach (var kvp in _Index.Where((kv) => ((myOrEqualFromKey) ? kv.Key.CompareTo(myFromKey) >= 0 : kv.Key.CompareTo(myFromKey) > 0)))
                {
                    foreach (var val in kvp.Value)
                    {
                        yield return val;
                    }
                }

                //2nd return all values between the most left key in the tree and the toKey
                foreach (var kvp in _Index.Where((kv) => ((myOrEqualToKey) ? kv.Key.CompareTo(myToKey) <= 0 : kv.Key.CompareTo(myToKey) < 0)))
                {
                    foreach (var val in kvp.Value)
                    {
                        yield return val;
                    }
                }
            }

            #endregion

            #region myFromKey < myToKey

            else if (myFromKey.CompareTo(myToKey) == -1)
            {
                #region start returning values

                //get indexValueHistoryLists
                var keyValuePairs = _Index.Where(
                        (kv) =>
                            ((myOrEqualFromKey) ? kv.Key.CompareTo(myFromKey) >= 0 : kv.Key.CompareTo(myFromKey) > 0)
                            &&
                            ((myOrEqualToKey) ? kv.Key.CompareTo(myToKey) <= 0 : kv.Key.CompareTo(myToKey) < 0));

                foreach (var kvp in keyValuePairs)
                {
                    foreach (var val in kvp.Value)
                    {
                        yield return val;
                    }
                }

                #endregion
            }

            #endregion
        }
コード例 #10
0
 public override ulong GetValueCount(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject)
 {
     return _Index.Aggregate(0UL, (result, elem) => result += (ulong)elem.Value.Count);
 }
コード例 #11
0
 public override IEnumerable<GraphFS.DataStructures.ObjectUUID> GetValues(IndexKey myIndeyKey, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
 {
     HashSet<ObjectUUID> retVal;
     if (_Index.TryGetValue(myIndeyKey, out retVal))
     {
         return retVal;
     }
     return new HashSet<ObjectUUID>();
     //foreach (var elem in _Index)
     //{
     //    foreach (var obj in elem.Value)
     //    {
     //        yield return obj;
     //    }
     //}
 }
コード例 #12
0
 public override IEnumerable<KeyValuePair<IndexKey, HashSet<GraphFS.DataStructures.ObjectUUID>>> GetKeyValues(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
 {
     foreach (var elem in _Index)
     {
         yield return elem;
     }
 }
コード例 #13
0
 public override IEnumerable<IndexKey> GetKeys(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
 {
     return _Index.Keys;
 }
コード例 #14
0
 public override ulong GetKeyCount(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject)
 {
     return (ulong)_Index.Count;
 }
コード例 #15
0
 public override IEnumerable<IEnumerable<GraphFS.DataStructures.ObjectUUID>> GetAllValues(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext)
 {
     foreach (var elem in _Index)
     {
         yield return elem.Value;
     }
 }
コード例 #16
0
ファイル: CountFunc.cs プロジェクト: Vadi/sones
 public override TypeManagement.IObject GetReturnType(TypeManagement.IObject myWorkingBase, TypeManagement.DBTypeManager myTypeManager)
 {
     return new DBUInt64();
 }