This is an automated email from the ASF dual-hosted git repository.

amoghj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 831e93c  chore: Use HashMap instead of BTreeMap for storing fields by 
id in StuctType (#14)
831e93c is described below

commit 831e93cf347f816961319a573c5126e8abfd184c
Author: Amogh Jahagirdar <[email protected]>
AuthorDate: Sat Jul 29 21:07:28 2023 -0700

    chore: Use HashMap instead of BTreeMap for storing fields by id in 
StuctType (#14)
---
 src/spec/datatypes.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/spec/datatypes.rs b/src/spec/datatypes.rs
index 6825442..4d0b831 100644
--- a/src/spec/datatypes.rs
+++ b/src/spec/datatypes.rs
@@ -18,7 +18,7 @@
 /*!
  * Data Types
 */
-use std::{collections::BTreeMap, fmt, ops::Index};
+use std::{collections::HashMap, fmt, ops::Index};
 
 use serde::{
     de::{self, Error, IntoDeserializer, MapAccess, Visitor},
@@ -197,7 +197,7 @@ pub struct StructType {
     fields: Vec<StructField>,
     /// Lookup for index by field id
     #[serde(skip_serializing)]
-    id_lookup: BTreeMap<i32, usize>,
+    id_lookup: HashMap<i32, usize>,
 }
 
 impl<'de> Deserialize<'de> for StructType {
@@ -252,7 +252,7 @@ impl<'de> Deserialize<'de> for StructType {
 impl StructType {
     /// Creates a struct type with the given fields.
     pub fn new(fields: Vec<StructField>) -> Self {
-        let id_lookup = BTreeMap::from_iter(fields.iter().enumerate().map(|(i, 
x)| (x.id, i)));
+        let id_lookup = HashMap::from_iter(fields.iter().enumerate().map(|(i, 
x)| (x.id, i)));
         Self { fields, id_lookup }
     }
     /// Get structfield with certain id
@@ -402,7 +402,7 @@ mod tests {
                     initial_default: None,
                     write_default: None,
                 }],
-                id_lookup: BTreeMap::from([(1, 0)]),
+                id_lookup: HashMap::from([(1, 0)]),
             }),
         )
     }
@@ -435,7 +435,7 @@ mod tests {
                     initial_default: None,
                     write_default: None,
                 }],
-                id_lookup: BTreeMap::from([(1, 0)]),
+                id_lookup: HashMap::from([(1, 0)]),
             }),
         )
     }
@@ -486,7 +486,7 @@ mod tests {
                         write_default: None,
                     },
                 ],
-                id_lookup: BTreeMap::from([(1, 0), (2, 1)]),
+                id_lookup: HashMap::from([(1, 0), (2, 1)]),
             }),
         )
     }

Reply via email to