-
|
Trying to implementing a FIFO approach to process each record. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Certainly the filter by RID (`SELECT ... WHERE @Rid > ...) given that this is the only filter used. However, I needed to build something like that a while ago and ended up with the second variant. Because my type uses multiple buckets, the RIDs' ordering does not correspond to the entry time (only the second RID component does), thus I could not use the comparison operation. When using a single bucket this could work though. |
Beta Was this translation helpful? Give feedback.
-
|
It depends on the use case. Do you have one FIFO for all the users? Or a FIFO per user or other entity? The problem with RIDs is that now are recycled. So if you delete the entry from the queue, the new assigned RID could be recycled, that means a lower number than the previous inserted. The easiest and safe way is using edges. Edges are always added in sequence, so the last edge inserted is always the first one in the list (more a LIFO approach). We didn't set a link to the first element, it's something we should have done since the beginning in EdgeLinkedList classes: 2 pointers to browse in both directions. How many elements in the queue you plan to have? You could have a "Queue" vertex type representing the queue and a "QueueEntry" vertex type containing the element. Then you could have a "QueueHasEntry" edge type to connect both. At this point to get the 1st element, you should traverse the whole list and get the last that is the first. Linked lists are very efficient, but it all depends on how many entries you have. Having the last entry first speeds up the insertion in the queue, at least, but the "pop" operation has higher complexity. I wish I added a double linked pointers in the linked list, but there are not, and not so fast to change now. |
Beta Was this translation helpful? Give feedback.
It depends on the use case. Do you have one FIFO for all the users? Or a FIFO per user or other entity? The problem with RIDs is that now are recycled. So if you delete the entry from the queue, the new assigned RID could be recycled, that means a lower number than the previous inserted.
The easiest and safe way is using edges. Edges are always added in sequence, so the last edge inserted is always the first one in the list (more a LIFO approach). We didn't set a link to the first element, it's something we should have done since the beginning in EdgeLinkedList classes: 2 pointers to browse in both directions.
How many elements in the queue you plan to have?
You could have a "Queue" verte…