From 8699c066e5236496ed8e261bd284d00e1b04d0a0 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Tue, 29 Oct 2019 09:10:27 +0100 Subject: [PATCH] Remove Table and VectorTable --- Cargo.toml | 2 -- src/database/mod.rs | 9 ++++----- src/database/space_db.rs | 22 ++++------------------ src/database/space_index.rs | 21 ++------------------- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 95e0634..930a315 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,6 @@ path = "src/main.rs" ironsea_index = "^0.1" ironsea_index_sfc_dbc = "^0.1" ironsea_index_hashmap = "^0.1" -ironsea_table = "^0.1" -ironsea_table_vector = "^0.1" memmap = "^0.7" lazy_static = "^1.3" diff --git a/src/database/mod.rs b/src/database/mod.rs index 91c4ddc..03fcc67 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -7,7 +7,6 @@ use std::collections::HashMap; use std::fs::File; use ironsea_index::Indexed; -use ironsea_table_vector::VectorTable; use memmap::Mmap; pub use db_core::Core; @@ -18,8 +17,8 @@ use space::Space; pub use space_index::SpaceSetObject; pub type ResultSet = Result, String>; -pub type ReferenceSpaceIndex = ironsea_index_hashmap::Index, Space, String>; -type CoreIndex = ironsea_index_hashmap::Index, Core, String>; +pub type ReferenceSpaceIndex = ironsea_index_hashmap::Index; +type CoreIndex = ironsea_index_hashmap::Index; #[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)] pub struct SpaceId(String); @@ -65,8 +64,8 @@ pub struct DataBase { impl DataBase { pub fn new(spaces: Vec, cores: Vec) -> Self { DataBase { - reference_spaces: ReferenceSpaceIndex::new(VectorTable::new(spaces)), - cores: CoreIndex::new(VectorTable::new(cores)), + reference_spaces: ReferenceSpaceIndex::new(spaces.into_iter()), + cores: CoreIndex::new(cores.into_iter()), } } diff --git a/src/database/space_db.rs b/src/database/space_db.rs index 19b73ed..c482f26 100644 --- a/src/database/space_db.rs +++ b/src/database/space_db.rs @@ -5,8 +5,6 @@ use std::collections::HashSet; use std::hash::Hash; use std::hash::Hasher; -use ironsea_table_vector::VectorTable; - use super::space::Coordinate; use super::space::Position; use super::space::Shape; @@ -101,11 +99,7 @@ impl SpaceDB { let shift = if count >= 31 { 31 } else { count }; count += 1; indices.push(( - SpaceSetIndex::new( - &VectorTable::new(space_objects.to_vec()), - DIMENSIONS, - CELL_BITS, - ), + SpaceSetIndex::new(space_objects.into_iter(), DIMENSIONS, CELL_BITS), vec![power.0, power.0, power.0], shift, )); @@ -124,11 +118,7 @@ impl SpaceDB { // Insert Full resolution index. indices.push(( - SpaceSetIndex::new( - &VectorTable::new(space_objects.clone()), - DIMENSIONS, - CELL_BITS, - ), + SpaceSetIndex::new(space_objects.into_iter(), DIMENSIONS, CELL_BITS), vec![count, count, count], 0, // Smallest value => highest resolution )); @@ -167,11 +157,7 @@ impl SpaceDB { } indices.push(( - SpaceSetIndex::new( - &VectorTable::new(space_objects.to_vec()), - DIMENSIONS, - CELL_BITS, - ), + SpaceSetIndex::new(space_objects.into_iter(), DIMENSIONS, CELL_BITS), vec![count, count, count], shift, )); @@ -186,7 +172,7 @@ impl SpaceDB { } else { // Generate only full-scale. indices.push(( - SpaceSetIndex::new(&VectorTable::new(space_objects), DIMENSIONS, CELL_BITS), + SpaceSetIndex::new(space_objects.into_iter(), DIMENSIONS, CELL_BITS), vec![0, 0, 0], 0, )); diff --git a/src/database/space_index.rs b/src/database/space_index.rs index 396559b..9a5d550 100644 --- a/src/database/space_index.rs +++ b/src/database/space_index.rs @@ -1,7 +1,6 @@ use std::cmp::Ord; -use ironsea_index::IndexedOwned; -use ironsea_table_vector::VectorTable; +use ironsea_index::IndexedDestructured; use super::space::Coordinate; use super::space::Position; @@ -82,23 +81,7 @@ impl ironsea_index::RecordFields for SpaceSetObject { } } -impl ironsea_index::RecordBuild for SpaceSetObject { - fn build(key: &Position, fields: &SpaceFields) -> SpaceSetObject { - SpaceSetObject { - space_id: fields.space_id.clone(), - position: key.clone(), - value: fields.value, - } - } -} - -pub type SpaceSetIndex = ironsea_index_sfc_dbc::IndexOwned< - VectorTable, - SpaceSetObject, - Position, - Coordinate, - SpaceFields, ->; +pub type SpaceSetIndex = ironsea_index_sfc_dbc::IndexOwned; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SpaceIndex {