in_mem_accounts_index filters by range (#19779)
This commit is contained in:
committed by
GitHub
parent
0263ffb2ed
commit
b992c02708
@ -6461,7 +6461,9 @@ impl AccountsDb {
|
|||||||
roots.sort();
|
roots.sort();
|
||||||
info!("{}: accounts_index roots: {:?}", label, roots,);
|
info!("{}: accounts_index roots: {:?}", label, roots,);
|
||||||
self.accounts_index.account_maps.iter().for_each(|map| {
|
self.accounts_index.account_maps.iter().for_each(|map| {
|
||||||
for (pubkey, account_entry) in map.read().unwrap().items() {
|
for (pubkey, account_entry) in
|
||||||
|
map.read().unwrap().items(&None::<&std::ops::Range<Pubkey>>)
|
||||||
|
{
|
||||||
info!(" key: {} ref_count: {}", pubkey, account_entry.ref_count(),);
|
info!(" key: {} ref_count: {}", pubkey, account_entry.ref_count(),);
|
||||||
info!(
|
info!(
|
||||||
" slots: {:?}",
|
" slots: {:?}",
|
||||||
|
@ -559,14 +559,9 @@ impl<'a, T: IsCached> AccountsIndexIterator<'a, T> {
|
|||||||
collect_all_unsorted: bool,
|
collect_all_unsorted: bool,
|
||||||
) -> Vec<(Pubkey, AccountMapEntry<T>)>
|
) -> Vec<(Pubkey, AccountMapEntry<T>)>
|
||||||
where
|
where
|
||||||
R: RangeBounds<Pubkey>,
|
R: RangeBounds<Pubkey> + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
let mut result = Vec::with_capacity(map.len());
|
let mut result = map.items(&Some(&range));
|
||||||
for (k, v) in map.items() {
|
|
||||||
if range.contains(&k) {
|
|
||||||
result.push((k, v));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !collect_all_unsorted {
|
if !collect_all_unsorted {
|
||||||
result.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
result.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::ops::RangeBounds;
|
||||||
type K = Pubkey;
|
type K = Pubkey;
|
||||||
|
|
||||||
// one instance of this represents one bin of the accounts index.
|
// one instance of this represents one bin of the accounts index.
|
||||||
@ -51,9 +51,18 @@ impl<T: IsCached> InMemAccountsIndex<T> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items(&self) -> Vec<(K, AccountMapEntry<T>)> {
|
pub fn items<R>(&self, range: &Option<&R>) -> Vec<(K, AccountMapEntry<T>)>
|
||||||
|
where
|
||||||
|
R: RangeBounds<Pubkey> + std::fmt::Debug,
|
||||||
|
{
|
||||||
Self::update_stat(&self.stats().items, 1);
|
Self::update_stat(&self.stats().items, 1);
|
||||||
self.map.iter().map(|(k, v)| (*k, v.clone())).collect()
|
let mut result = Vec::with_capacity(self.map.len());
|
||||||
|
self.map.iter().for_each(|(k, v)| {
|
||||||
|
if range.map(|range| range.contains(k)).unwrap_or(true) {
|
||||||
|
result.push((*k, v.clone()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn keys(&self) -> Keys<K, AccountMapEntry<T>> {
|
pub fn keys(&self) -> Keys<K, AccountMapEntry<T>> {
|
||||||
|
Reference in New Issue
Block a user