Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SearchProcess.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
5
7{
11 public class SearchProcess
12 {
13 private readonly Dictionary<ulong, ObjectReference> references = new Dictionary<ulong, ObjectReference>();
14 private readonly string indexCollection;
15
21 public SearchProcess(IPersistentDictionary Index, string IndexCollection)
22 {
23 this.Index = Index;
24 this.indexCollection = IndexCollection;
25 this.ReferencesByObject = new Dictionary<ulong, MatchInformation>();
26 this.IsRestricted = false;
27 }
28
33
37 public Dictionary<ulong, MatchInformation> ReferencesByObject { get; }
38
42 public bool IsRestricted
43 {
44 get;
45 private set;
46 }
47
51 public Dictionary<ulong, bool> Found
52 {
53 get;
54 private set;
55 }
56
60 public void IncRestricted()
61 {
62 if (!this.IsRestricted)
63 {
64 this.IsRestricted = true;
65 this.Found = new Dictionary<ulong, bool>();
66 }
67 }
68
76 public async Task<ObjectReference> TryGetObjectReference(ulong ObjectIndex, bool CanLoadFromDatabase)
77 {
78 if (this.references.TryGetValue(ObjectIndex, out ObjectReference Ref))
79 return Ref;
80
81 if (CanLoadFromDatabase)
82 {
83 Ref = await Database.FindFirstIgnoreRest<ObjectReference>(new FilterAnd(
84 new FilterFieldEqualTo("IndexCollection", this.indexCollection),
85 new FilterFieldEqualTo("Index", ObjectIndex)));
86
87 this.references[ObjectIndex] = Ref;
88 }
89
90 return Ref;
91 }
92 }
93}
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
This filter selects objects that conform to all child-filters provided.
Definition: FilterAnd.cs:10
This filter selects objects that have a named field equal to a given value.
Contains information about a search process.
async Task< ObjectReference > TryGetObjectReference(ulong ObjectIndex, bool CanLoadFromDatabase)
Tries to get an object reference.
bool IsRestricted
If the search process is restricted.
Dictionary< ulong, bool > Found
Objects found during the processing of the current keyword.
void IncRestricted()
Increments counter of number of restricted keywords.
Dictionary< ulong, MatchInformation > ReferencesByObject
References found.
SearchProcess(IPersistentDictionary Index, string IndexCollection)
Contains information about a search process.
IPersistentDictionary Index
Index dictionary
Contains a reference to an indexed object.
Persistent dictionary that can contain more entries than possible in the internal memory.