Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RequiredKeyword.cs
2using System.Threading.Tasks;
5
7{
11 public class RequiredKeyword : Keyword
12 {
18 : base()
19 {
20 this.Keyword = Keyword;
21 }
22
26 public Keyword Keyword { get; }
27
31 public override bool Optional => false;
32
36 public override bool Required => true;
37
41 public override int OrderCategory => 1;
42
46 public override int OrderComplexity => this.Keyword.OrderComplexity;
47
51 public override bool Ignore => this.Keyword.Ignore;
52
54 public override bool Equals(object obj)
55 {
56 return obj is RequiredKeyword k && this.Keyword.Equals(k.Keyword);
57 }
58
60 public override string ToString()
61 {
62 return "+" + this.Keyword.ToString();
63 }
64
70 public override Task<IEnumerable<KeyValuePair<string, TokenReferences>>> GetTokenReferences(SearchProcess Process)
71 {
73 }
74
80 public override async Task<bool> Process(SearchProcess Process)
81 {
82 IEnumerable<KeyValuePair<string, TokenReferences>> Records = await this.GetTokenReferences(Process);
83
84 foreach (KeyValuePair<string, TokenReferences> Rec in Records)
85 {
86 string Token = Rec.Key;
87 TokenReferences References = Rec.Value;
88
89 int j, d = References.ObjectReferences.Length;
90
91 for (j = 0; j < d; j++)
92 {
93 ulong ObjectReference = References.ObjectReferences[j];
94
95 if (Process.IsRestricted)
96 Process.Found[ObjectReference] = true;
97
98 if (!Process.ReferencesByObject.TryGetValue(ObjectReference, out MatchInformation ByObjectReference))
99 {
100 if (Process.IsRestricted)
101 continue;
102
103 ByObjectReference = new MatchInformation();
104 Process.ReferencesByObject[ObjectReference] = ByObjectReference;
105 }
106
107 ByObjectReference.AddTokenReference(new TokenReference()
108 {
109 Count = References.Counts[j],
110 LastBlock = References.LastBlock,
112 Timestamp = References.Timestamps[j],
113 Token = Token
114 });
115 }
116 }
117
118 if (Process.IsRestricted)
119 {
120 ChunkedList<ulong> ToRemove = null;
121
122 foreach (ulong ObjectReference in Process.ReferencesByObject.Keys)
123 {
124 if (!Process.Found.ContainsKey(ObjectReference))
125 {
126 if (ToRemove is null)
127 ToRemove = new ChunkedList<ulong>();
128
129 ToRemove.Add(ObjectReference);
130 }
131 }
132
133 if (!(ToRemove is null))
134 {
135 foreach (ulong ObjectReference in ToRemove)
136 Process.ReferencesByObject.Remove(ObjectReference);
137 }
138 }
139
140 if (Process.ReferencesByObject.Count == 0)
141 return false;
142
143 Process.IncRestricted();
144
145 return true;
146 }
147
148 }
149}
Abstract base class for keywords.
Definition: Keyword.cs:11
virtual bool Ignore
If keyword should be ignored.
Definition: Keyword.cs:47
virtual int OrderComplexity
Order complexity (within category) of keyword
Definition: Keyword.cs:42
abstract Task< IEnumerable< KeyValuePair< string, TokenReferences > > > GetTokenReferences(SearchProcess Process)
Gets available token references.
override async Task< bool > Process(SearchProcess Process)
Processes the keyword in a search process.
override bool Ignore
If keyword should be ignored.
override Task< IEnumerable< KeyValuePair< string, TokenReferences > > > GetTokenReferences(SearchProcess Process)
Gets available token references.
override int OrderComplexity
Order complexity (within category) of keyword
RequiredKeyword(Keyword Keyword)
Represents a required keyword.
override int OrderCategory
Order category of keyword
Contains information about a search process.
Contains a reference to an indexed object.
Contains matching information about a document in a search.
Contains a sequence of object references that include the token in its indexed text properties.
DateTime[] Timestamps
Timestamps when corresponding object refernces were indexed.
uint[] Counts
Token counts for respective object reference.
ulong[] ObjectReferences
References to objects containing the token.
uint LastBlock
Index to last block in index representing the same token.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54