|
@@ -95,32 +95,30 @@ impl<'a> Stream for Cursor<'a> {
|
|
loop {
|
|
loop {
|
|
let secondary_index = if let Some(iterator) = this.secondary_index_iterator.as_mut() {
|
|
let secondary_index = if let Some(iterator) = this.secondary_index_iterator.as_mut() {
|
|
iterator
|
|
iterator
|
|
|
|
+ } else if this.namespace.is_some() {
|
|
|
|
+ let _ = this.select_next_prefix_using_secondary_index();
|
|
|
|
+ if let Some(iterator) = this.secondary_index_iterator.as_mut() {
|
|
|
|
+ iterator
|
|
|
|
+ } else {
|
|
|
|
+ return Poll::Ready(None);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- if this.namespace.is_some() {
|
|
|
|
- let _ = this.select_next_prefix_using_secondary_index();
|
|
|
|
- if let Some(iterator) = this.secondary_index_iterator.as_mut() {
|
|
|
|
- iterator
|
|
|
|
- } else {
|
|
|
|
- return Poll::Ready(None);
|
|
|
|
|
|
+ // No secondary index is used to query, this means the query is
|
|
|
|
+ // using the ID filter, so it is more efficient to use the
|
|
|
|
+ // primary index to prefetch events that may satisfy the query
|
|
|
|
+ return if let Some(prefix) = this.prefixes.pop_front() {
|
|
|
|
+ this.future_event = Some(db.get_event(prefix));
|
|
|
|
+ match check_future_call(&mut this.future_event, &this.filter, cx) {
|
|
|
|
+ FutureValue::Found(event) => {
|
|
|
|
+ this.returned += 1;
|
|
|
|
+ Poll::Ready(Some(event))
|
|
|
|
+ }
|
|
|
|
+ FutureValue::Pending => Poll::Pending,
|
|
|
|
+ FutureValue::FoundNotMatch | FutureValue::Ended => continue,
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- // No secondary index is used to query, this means the query is
|
|
|
|
- // using the ID filter, so it is more efficient to use the
|
|
|
|
- // primary index to prefetch events that may satisfy the query
|
|
|
|
- return if let Some(prefix) = this.prefixes.pop_front() {
|
|
|
|
- this.future_event = Some(db.get_event(prefix));
|
|
|
|
- match check_future_call(&mut this.future_event, &this.filter, cx) {
|
|
|
|
- FutureValue::Found(event) => {
|
|
|
|
- this.returned += 1;
|
|
|
|
- Poll::Ready(Some(event))
|
|
|
|
- }
|
|
|
|
- FutureValue::Pending => Poll::Pending,
|
|
|
|
- FutureValue::FoundNotMatch | FutureValue::Ended => continue,
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Poll::Ready(None)
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
|
|
+ Poll::Ready(None)
|
|
|
|
+ };
|
|
};
|
|
};
|
|
|
|
|
|
return match secondary_index.next() {
|
|
return match secondary_index.next() {
|