replace btreemap with vec

This is PR https://github.com/neondatabase/neon/pull/3496
This commit is contained in:
Christian Schwarz
2023-01-31 11:49:15 +01:00
parent f4039c65a9
commit e708c4e22c
2 changed files with 11 additions and 12 deletions

View File

@@ -1,5 +1,4 @@
use std::{
collections::BTreeSet,
fmt,
num::{NonZeroU64, NonZeroUsize},
ops::Range,
@@ -232,14 +231,14 @@ pub struct TimelineInfo {
pub state: TimelineState,
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize)]
pub struct LayerMapInfo {
pub in_memory_layers: BTreeSet<InMemoryLayerInfo>,
pub historic_layers: BTreeSet<HistoricLayerInfo>,
pub in_memory_layers: Vec<InMemoryLayerInfo>,
pub historic_layers: Vec<HistoricLayerInfo>,
}
#[derive(Debug, Clone, Serialize)]
#[serde_as]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Serialize, Deserialize)]
#[serde(tag = "kind")]
pub enum InMemoryLayerInfo {
Open {
@@ -254,8 +253,8 @@ pub enum InMemoryLayerInfo {
},
}
#[derive(Debug, Clone, Serialize)]
#[serde_as]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Serialize, Deserialize)]
#[serde(tag = "kind")]
pub enum HistoricLayerInfo {
Delta {

View File

@@ -17,7 +17,7 @@ use tokio_util::sync::CancellationToken;
use tracing::*;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeSet, HashMap};
use std::collections::HashMap;
use std::fs;
use std::ops::{Deref, Range};
use std::path::{Path, PathBuf};
@@ -821,18 +821,18 @@ impl Timeline {
}
pub fn layer_map_info(&self) -> LayerMapInfo {
let mut in_memory_layers = BTreeSet::new();
let mut in_memory_layers = Vec::new();
let layer_map = self.layers.read().unwrap();
if let Some(open_layer) = &layer_map.open_layer {
in_memory_layers.insert(open_layer.info());
in_memory_layers.push(open_layer.info());
}
for frozen_layer in &layer_map.frozen_layers {
in_memory_layers.insert(frozen_layer.info());
in_memory_layers.push(frozen_layer.info());
}
let mut historic_layers = BTreeSet::new();
let mut historic_layers = Vec::new();
for historic_layer in layer_map.iter_historic_layers() {
historic_layers.insert(historic_layer.info());
historic_layers.push(historic_layer.info());
}
LayerMapInfo {