public bool ContainsRelatedResource(ulong resourceId, ulong predicateId, ulong relatedResourceId, int graphId, BrightstarProfiler profiler) { using (profiler.Step("ContainsRelatedResource")) { byte[] valueBuff = null; PredicateRelatedResourceIndex predicateIndex = GetPredicateIndex(predicateId, profiler); return(predicateIndex != null && predicateIndex.Search(MakePredicateIndexKey(resourceId, graphId, relatedResourceId), valueBuff, profiler)); } }
public ulong CountPredicateRelationships(ulong predicateId, BrightstarProfiler profiler) { PredicateRelatedResourceIndex predicateIndex = GetPredicateIndex(predicateId, profiler); if (predicateIndex != null) { return((ulong)predicateIndex.Scan(MakePredicateIndexKey(0, 0, 0), MakePredicateIndexKey(ulong.MaxValue, int.MaxValue, ulong.MaxValue), profiler) .LongCount()); } return(0UL); }
private PredicateRelatedResourceIndex GetPredicateIndex(ulong predicateId, ulong rootPageId, BrightstarProfiler profiler) { lock (_predicateIndexes) { PredicateRelatedResourceIndex predicateIndex; if (_predicateIndexes.TryGetValue(predicateId, out predicateIndex)) { return(predicateIndex); } predicateIndex = new PredicateRelatedResourceIndex(PageStore, rootPageId); _predicateIndexes[predicateId] = predicateIndex; return(predicateIndex); } }
/// <summary> /// Enumerates all of the related resources stored for a single predicate /// </summary> /// <param name="predicateId"></param> /// <param name="profiler"></param> /// <returns></returns> public IEnumerable <IResourceRelationship> EnumeratePredicateRelationships(ulong predicateId, BrightstarProfiler profiler) { PredicateRelatedResourceIndex predicateIndex = GetPredicateIndex(predicateId, profiler); if (predicateIndex != null) { foreach (var entry in predicateIndex.Scan(MakePredicateIndexKey(0, 0, 0), MakePredicateIndexKey(ulong.MaxValue, int.MaxValue, ulong.MaxValue), profiler)) { var thisResource = GetResourceIdFromKey(entry.Key); var graphId = GetGraphIdFromKey(entry.Key); var relatedResource = GetRelatedResourceIdFromKey(entry.Key); yield return(new ResourceRelationship(thisResource, predicateId, relatedResource, graphId)); } } }
private PredicateRelatedResourceIndex AssertPredicateIndex(ulong transactionId, ulong predicateId, BrightstarProfiler profiler) { using (profiler.Step("AssertPredicateIndex")) { PredicateRelatedResourceIndex predicateIndex = GetPredicateIndex(predicateId, profiler); if (predicateIndex == null) { using (profiler.Step("New Predicate Index")) { predicateIndex = new PredicateRelatedResourceIndex(transactionId, PageStore); _predicateIndexes[predicateId] = predicateIndex; } } return(predicateIndex); } }
private PredicateRelatedResourceIndex GetPredicateIndex(ulong predicateId, BrightstarProfiler profiler) { lock (_predicateIndexes) { PredicateRelatedResourceIndex predicateIndex; if (_predicateIndexes.TryGetValue(predicateId, out predicateIndex)) { return(predicateIndex); } var buff = new byte[8]; if (Search(predicateId, buff, profiler)) { ulong predicateIndexRoot = BitConverter.ToUInt64(buff, 0); predicateIndex = new PredicateRelatedResourceIndex(PageStore, predicateIndexRoot); _predicateIndexes[predicateId] = predicateIndex; return(predicateIndex); } return(null); } }
private PredicateRelatedResourceIndex GetPredicateIndex(ulong predicateId, BrightstarProfiler profiler) { lock (_predicateIndexes) { PredicateRelatedResourceIndex predicateIndex; if (_predicateIndexes.TryGetValue(predicateId, out predicateIndex)) { return predicateIndex; } var buff = new byte[8]; if (Search(predicateId, buff, profiler)) { ulong predicateIndexRoot = BitConverter.ToUInt64(buff, 0); predicateIndex = new PredicateRelatedResourceIndex(PageStore, predicateIndexRoot); _predicateIndexes[predicateId] = predicateIndex; return predicateIndex; } return null; } }
private PredicateRelatedResourceIndex GetPredicateIndex(ulong predicateId, ulong rootPageId, BrightstarProfiler profiler) { lock(_predicateIndexes) { PredicateRelatedResourceIndex predicateIndex; if (_predicateIndexes.TryGetValue(predicateId, out predicateIndex)) return predicateIndex; predicateIndex = new PredicateRelatedResourceIndex(PageStore, rootPageId); _predicateIndexes[predicateId] = predicateIndex; return predicateIndex; } }
private PredicateRelatedResourceIndex AssertPredicateIndex(ulong transactionId, ulong predicateId, BrightstarProfiler profiler) { using (profiler.Step("AssertPredicateIndex")) { PredicateRelatedResourceIndex predicateIndex = GetPredicateIndex(predicateId, profiler); if (predicateIndex == null) { using (profiler.Step("New Predicate Index")) { predicateIndex = new PredicateRelatedResourceIndex(transactionId, PageStore); _predicateIndexes[predicateId] = predicateIndex; } } return predicateIndex; } }