Skip to content

Commit

Permalink
Cleaned up some pub struct elements that needed to be private. Some o…
Browse files Browse the repository at this point in the history
…ther method moving around (#35)

Signed-off-by: David Pollak <[email protected]>
  • Loading branch information
dpp authored Feb 12, 2025
1 parent 0fcdf2d commit c974543
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/live_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use thousands::Separable;
pub async fn perform_merge(clusters: Vec<GoatRodeoCluster>) -> Result<GoatRodeoCluster> {
let clusters: Vec<GoatRodeoCluster> = clusters
.into_iter()
.filter(|c| c.cluster_file_hash != 0)
.filter(|c| c.get_cluster_file_hash() != 0)
.collect();
let start = Instant::now();
if clusters.is_empty() {
Expand Down Expand Up @@ -54,7 +54,7 @@ pub async fn perform_merge(clusters: Vec<GoatRodeoCluster>) -> Result<GoatRodeoC
// build submap
let mut submap = HashMap::new();
for b in &clusters {
submap.insert(b.cluster_file_hash, b.clone());
submap.insert(b.get_cluster_file_hash(), b.clone());
}

let mut new_index = Vec::with_capacity(max_size * 90usize / 100usize);
Expand Down Expand Up @@ -107,8 +107,8 @@ pub async fn perform_merge(clusters: Vec<GoatRodeoCluster>) -> Result<GoatRodeoC
let mut data_files = HashMap::new();
let mut index_files = HashMap::new();
for b in clusters.iter() {
data_files.extend(b.data_files.clone());
index_files.extend(b.index_files.clone());
data_files.extend(b.get_data_files().clone());
index_files.extend(b.get_index_files().clone());
}

let b0 = &clusters[0];
Expand Down Expand Up @@ -243,7 +243,7 @@ fn test_live_merge() {

pub async fn persist_synthetic(cluster: GoatRodeoCluster) -> Result<GoatRodeoCluster> {
// if it's not synthetic, just return it
if !cluster.synthetic {
if !cluster.is_synthetic() {
return Ok(cluster);
}

Expand Down
37 changes: 26 additions & 11 deletions src/rodeo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ impl std::fmt::Display for ClusterFileEnvelope {

#[derive(Debug, Clone)]
pub struct GoatRodeoCluster {
pub envelope: ClusterFileEnvelope,
pub cluster_file_hash: u64,
pub path: PathBuf,
pub cluster_path: PathBuf,
pub data_files: HashMap<u64, Arc<DataFile>>,
pub index_files: HashMap<u64, IndexFile>,
pub sub_clusters: HashMap<u64, GoatRodeoCluster>,
pub synthetic: bool,
envelope: ClusterFileEnvelope,
cluster_file_hash: u64,
path: PathBuf,
cluster_path: PathBuf,
data_files: HashMap<u64, Arc<DataFile>>,
index_files: HashMap<u64, IndexFile>,
sub_clusters: HashMap<u64, GoatRodeoCluster>,
synthetic: bool,
index: Arc<ArcSwap<Option<Arc<Vec<ItemOffset>>>>>,
building_index: Arc<Mutex<bool>>,
}
Expand All @@ -109,9 +109,24 @@ pub const IndexFileMagicNumber: u32 = 0x54154170; // Shishitō
pub const ClusterFileMagicNumber: u32 = 0xba4a4a; // Banana

impl GoatRodeoCluster {
// Reset the index. Should be done with extreme care
pub fn reset_index(&self) -> () {
self.index.store(Arc::new(None));
/// get the cluster file hash
pub fn get_cluster_file_hash(&self) -> u64 {
self.cluster_file_hash
}

/// is the cluster synthetic (built from lots of clusters)
pub fn is_synthetic(&self) -> bool {
self.synthetic
}

/// Get the data file mapping
pub fn get_data_files<'a>(&'a self) -> &'a HashMap<u64, Arc<DataFile>> {
&self.data_files
}

/// Get the index file mapping
pub fn get_index_files<'a>(&'a self) -> &'a HashMap<u64, IndexFile> {
&self.index_files
}

pub fn create_synthetic_with(
Expand Down
3 changes: 2 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ async fn do_north(
StreamBodyAs::json_array(TokioReceiverToStream { receiver: mrx })
}

fn build_route(state: Arc<ClusterHolder>) -> Router {
/// Build up the routes for the default Big Tent features
pub fn build_route(state: Arc<ClusterHolder>) -> Router {
let app: Router<()> = Router::new()
.route("/bulk", post(serve_bulk))
.route("/{*gitoid}", get(serve_gitoid))
Expand Down

0 comments on commit c974543

Please sign in to comment.