@@ -3,7 +3,8 @@ use std::collections::{BTreeMap, HashMap};
3
3
use std:: iter:: FromIterator ;
4
4
use std:: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
5
5
6
- use graph:: prelude:: q;
6
+ use graph:: components:: store:: EntityType ;
7
+ use graph:: prelude:: { q, DeploymentHash , EntityKey } ;
7
8
use rand:: { thread_rng, Rng } ;
8
9
use structopt:: StructOpt ;
9
10
@@ -48,7 +49,7 @@ trait Template<T>: CacheWeight + Default {
48
49
// Return a sample of this test object of the given `size`. There's no
49
50
// fixed definition of 'size', other than that smaller sizes will
50
51
// take less memory than larger ones
51
- fn sample ( & self , size : usize ) -> Self :: Item ;
52
+ fn sample ( & self , size : usize ) -> Box < Self :: Item > ;
52
53
}
53
54
54
55
/// Template for testing caching of `String`
@@ -62,8 +63,8 @@ impl Template<String> for String {
62
63
}
63
64
s
64
65
}
65
- fn sample ( & self , size : usize ) -> Self :: Item {
66
- self [ 0 ..size] . into ( )
66
+ fn sample ( & self , size : usize ) -> Box < Self :: Item > {
67
+ Box :: new ( self [ 0 ..size] . into ( ) )
67
68
}
68
69
}
69
70
@@ -74,8 +75,8 @@ impl Template<Vec<usize>> for Vec<usize> {
74
75
fn create ( size : usize ) -> Self {
75
76
Vec :: from_iter ( 0 ..size)
76
77
}
77
- fn sample ( & self , size : usize ) -> Self :: Item {
78
- self [ 0 ..size] . into ( )
78
+ fn sample ( & self , size : usize ) -> Box < Self :: Item > {
79
+ Box :: new ( self [ 0 ..size] . into ( ) )
79
80
}
80
81
}
81
82
@@ -91,12 +92,12 @@ impl Template<HashMap<String, String>> for HashMap<String, String> {
91
92
map
92
93
}
93
94
94
- fn sample ( & self , size : usize ) -> Self :: Item {
95
- HashMap :: from_iter (
95
+ fn sample ( & self , size : usize ) -> Box < Self :: Item > {
96
+ Box :: new ( HashMap :: from_iter (
96
97
self . iter ( )
97
98
. take ( size)
98
99
. map ( |( k, v) | ( k. to_owned ( ) , v. to_owned ( ) ) ) ,
99
- )
100
+ ) )
100
101
}
101
102
}
102
103
@@ -135,12 +136,12 @@ impl Template<ValueMap> for ValueMap {
135
136
map
136
137
}
137
138
138
- fn sample ( & self , size : usize ) -> Self :: Item {
139
- BTreeMap :: from_iter (
139
+ fn sample ( & self , size : usize ) -> Box < Self :: Item > {
140
+ Box :: new ( BTreeMap :: from_iter (
140
141
self . iter ( )
141
142
. take ( size)
142
143
. map ( |( k, v) | ( k. to_owned ( ) , v. to_owned ( ) ) ) ,
143
- )
144
+ ) )
144
145
}
145
146
}
146
147
@@ -158,7 +159,7 @@ impl<T: Template<T>> Cacheable<T> {
158
159
}
159
160
}
160
161
161
- fn sample ( & self , size : usize ) -> T :: Item {
162
+ fn sample ( & self , size : usize ) -> Box < T :: Item > {
162
163
self . template . sample ( size)
163
164
}
164
165
@@ -234,7 +235,7 @@ fn stress<T: Template<T, Item = T>>(opt: &Opt) {
234
235
ALLOCATED . load( SeqCst ) - before,
235
236
) ;
236
237
}
237
- cacheable. cache . insert ( key, cacheable. sample ( size) ) ;
238
+ cacheable. cache . insert ( key, * cacheable. sample ( size) ) ;
238
239
}
239
240
}
240
241
0 commit comments