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); }
public override Exceptional<bool> Contains(IndexKey myIndexKey, TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext) { return new Exceptional<bool>(_Index.ContainsKey(myIndexKey)); }
public override Lib.ErrorHandling.Exceptional Clear(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject) { _Index.Clear(); return Exceptional.OK; }
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; }
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; }
public override Lib.ErrorHandling.Exceptional Insert(ObjectManagement.DBObjectStream myDBObject, TypeManagement.GraphDBType myTypeOfDBobject, DBContext myDBContext) { return Insert(myDBObject, IndexSetStrategy.MERGE, myTypeOfDBobject, myDBContext); }
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; }
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; }
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 }
public override ulong GetValueCount(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject) { return _Index.Aggregate(0UL, (result, elem) => result += (ulong)elem.Value.Count); }
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; // } //} }
public override IEnumerable<KeyValuePair<IndexKey, HashSet<GraphFS.DataStructures.ObjectUUID>>> GetKeyValues(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext) { foreach (var elem in _Index) { yield return elem; } }
public override IEnumerable<IndexKey> GetKeys(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext) { return _Index.Keys; }
public override ulong GetKeyCount(DBContext myDBContext, TypeManagement.GraphDBType myTypeOfDBObject) { return (ulong)_Index.Count; }
public override IEnumerable<IEnumerable<GraphFS.DataStructures.ObjectUUID>> GetAllValues(TypeManagement.GraphDBType myTypeOfDBObject, DBContext myDBContext) { foreach (var elem in _Index) { yield return elem.Value; } }
public override TypeManagement.IObject GetReturnType(TypeManagement.IObject myWorkingBase, TypeManagement.DBTypeManager myTypeManager) { return new DBUInt64(); }