@@ -6,8 +6,8 @@ use crate::{
6
6
} ,
7
7
protocol:: value:: Value ,
8
8
} ;
9
+ use heed3:: { RoTxn , byteorder:: BE } ;
9
10
use helix_macros:: debug_trace;
10
- use heed3:: { byteorder:: BE , RoTxn } ;
11
11
use serde:: Serialize ;
12
12
use std:: sync:: Arc ;
13
13
@@ -16,18 +16,25 @@ pub struct NFromIndex<'a> {
16
16
heed3:: RoPrefix < ' a , heed3:: types:: Bytes , heed3:: types:: LazyDecode < heed3:: types:: U128 < BE > > > ,
17
17
txn : & ' a RoTxn < ' a > ,
18
18
storage : Arc < HelixGraphStorage > ,
19
+ label : & ' a str ,
19
20
}
20
21
21
22
impl < ' a > Iterator for NFromIndex < ' a > {
22
23
type Item = Result < TraversalVal , GraphError > ;
23
24
24
25
#[ debug_trace( "N_FROM_INDEX" ) ]
25
26
fn next ( & mut self ) -> Option < Self :: Item > {
26
- if let Some ( value) = self . iter . by_ref ( ) . next ( ) {
27
+ for value in self . iter . by_ref ( ) {
27
28
let ( _, value) = value. unwrap ( ) ;
28
29
match value. decode ( ) {
29
30
Ok ( value) => match self . storage . get_node ( self . txn , & value) {
30
- Ok ( node) => return Some ( Ok ( TraversalVal :: Node ( node) ) ) ,
31
+ Ok ( node) => {
32
+ if node. label == self . label {
33
+ return Some ( Ok ( TraversalVal :: Node ( node) ) ) ;
34
+ } else {
35
+ continue ;
36
+ }
37
+ }
31
38
Err ( e) => {
32
39
println ! ( "{} Error getting node: {:?}" , line!( ) , e) ;
33
40
return Some ( Err ( GraphError :: ConversionError ( e. to_string ( ) ) ) ) ;
@@ -55,7 +62,7 @@ pub trait NFromIndexAdapter<'a, K: Into<Value> + Serialize>:
55
62
///
56
63
/// Note that both the `index` and `key` must be provided.
57
64
/// The index must be a valid and existing secondary index and the key should match the type of the index.
58
- fn n_from_index ( self , index : & ' a str , key : & ' a K ) -> Self :: OutputIter
65
+ fn n_from_index ( self , label : & ' a str , index : & ' a str , key : & ' a K ) -> Self :: OutputIter
59
66
where
60
67
K : Into < Value > + Serialize + Clone ;
61
68
}
@@ -66,7 +73,7 @@ impl<'a, I: Iterator<Item = Result<TraversalVal, GraphError>>, K: Into<Value> +
66
73
type OutputIter = RoTraversalIterator < ' a , NFromIndex < ' a > > ;
67
74
68
75
#[ inline]
69
- fn n_from_index ( self , index : & ' a str , key : & ' a K ) -> Self :: OutputIter
76
+ fn n_from_index ( self , label : & ' a str , index : & ' a str , key : & ' a K ) -> Self :: OutputIter
70
77
where
71
78
K : Into < Value > + Serialize + Clone ,
72
79
{
@@ -88,6 +95,7 @@ impl<'a, I: Iterator<Item = Result<TraversalVal, GraphError>>, K: Into<Value> +
88
95
iter : res,
89
96
txn : self . txn ,
90
97
storage : Arc :: clone ( & self . storage ) ,
98
+ label,
91
99
} ;
92
100
93
101
RoTraversalIterator {
0 commit comments