Skip to content

Commit 0059141

Browse files
committed
make all data types u64 instead of usize
1 parent e183f02 commit 0059141

File tree

11 files changed

+27
-28
lines changed

11 files changed

+27
-28
lines changed

optd-cost-model/src/common/predicates/attr_ref_pred.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl AttributeRefPred {
3333
PredicateNode {
3434
typ: PredicateType::AttributeRef,
3535
children: vec![
36-
IdPred::new(table_id.0 as u64).into_pred_node(),
36+
IdPred::new(table_id.0).into_pred_node(),
3737
IdPred::new(attribute_idx).into_pred_node(),
3838
],
3939
data: None,
@@ -44,7 +44,7 @@ impl AttributeRefPred {
4444

4545
/// Gets the table id.
4646
pub fn table_id(&self) -> TableId {
47-
TableId(self.0.child(0).data.as_ref().unwrap().as_u64() as usize)
47+
TableId(self.0.child(0).data.as_ref().unwrap().as_u64())
4848
}
4949

5050
/// Gets the attribute index.

optd-cost-model/src/common/predicates/id_pred.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl IdPred {
2323
}
2424

2525
/// Gets the id stored in the predicate.
26-
pub fn id(&self) -> usize {
27-
self.0.data.clone().unwrap().as_u64() as usize
26+
pub fn id(&self) -> u64 {
27+
self.0.data.clone().unwrap().as_u64()
2828
}
2929
}
3030

optd-cost-model/src/common/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ use std::fmt::Display;
55
66
/// TODO: documentation
77
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
8-
pub struct GroupId(pub usize);
8+
pub struct GroupId(pub u64);
99

1010
/// TODO: documentation
1111
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
12-
pub struct ExprId(pub usize);
12+
pub struct ExprId(pub u64);
1313

1414
/// TODO: documentation
1515
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
16-
pub struct TableId(pub usize);
16+
pub struct TableId(pub u64);
1717

1818
/// TODO: documentation
1919
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
20-
pub struct AttrId(pub usize);
20+
pub struct AttrId(pub u64);
2121

2222
/// TODO: documentation
2323
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
24-
pub struct EpochId(pub usize);
24+
pub struct EpochId(pub u64);
2525

2626
impl Display for GroupId {
2727
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

optd-cost-model/src/cost/filter/comp_op.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ impl<S: CostModelStorageManager> CostModelImpl<S> {
183183
// **TODO**: What if this attribute is a derived attribute?
184184
let attribute_info = self
185185
.storage_manager
186-
.get_attribute_info(table_id, attr_ref_idx as i32)
186+
.get_attribute_info(table_id, attr_ref_idx)
187187
.await?
188-
.ok_or({
189-
SemanticError::AttributeNotFound(table_id, attr_ref_idx as i32)
190-
})?;
188+
.ok_or({ SemanticError::AttributeNotFound(table_id, attr_ref_idx) })?;
191189

192190
let invert_cast_data_type = &attribute_info.typ.into_data_type();
193191

optd-cost-model/src/cost_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub mod tests {
150150
pub fn create_cost_model_mock_storage(
151151
table_id: Vec<TableId>,
152152
per_attribute_stats: Vec<HashMap<u64, TestPerAttributeStats>>,
153-
row_counts: Vec<Option<usize>>,
153+
row_counts: Vec<Option<u64>>,
154154
per_table_attr_infos: BaseTableAttrInfo,
155155
) -> TestOptCostModelMock {
156156
let storage_manager = CostModelStorageMockManagerImpl::new(

optd-cost-model/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum SemanticError {
4141
// TODO: Add more error types
4242
UnknownStatisticType,
4343
VersionedStatisticNotFound,
44-
AttributeNotFound(TableId, i32), // (table_id, attribute_base_index)
44+
AttributeNotFound(TableId, u64), // (table_id, attribute_base_index)
4545
// FIXME: not sure if this should be put here
4646
InvalidPredicate(String),
4747
}

optd-cost-model/src/storage/mock.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ pub type AttrIndices = Vec<u64>;
1212
#[serde_with::serde_as]
1313
#[derive(Serialize, Deserialize, Debug)]
1414
pub struct TableStats {
15-
pub row_cnt: usize,
15+
pub row_cnt: u64,
1616
#[serde_as(as = "HashMap<serde_with::json::JsonString, _>")]
1717
pub column_comb_stats: HashMap<AttrIndices, AttributeCombValueStats>,
1818
}
1919

2020
impl TableStats {
2121
pub fn new(
22-
row_cnt: usize,
22+
row_cnt: u64,
2323
column_comb_stats: HashMap<AttrIndices, AttributeCombValueStats>,
2424
) -> Self {
2525
Self {
@@ -53,12 +53,12 @@ impl CostModelStorageManager for CostModelStorageMockManagerImpl {
5353
async fn get_attribute_info(
5454
&self,
5555
table_id: TableId,
56-
attr_base_index: i32,
56+
attr_base_index: u64,
5757
) -> CostModelResult<Option<Attribute>> {
5858
let table_attr_infos = self.per_table_attr_infos_map.get(&table_id);
5959
match table_attr_infos {
6060
None => Ok(None),
61-
Some(table_attr_infos) => match table_attr_infos.get(&(attr_base_index as u64)) {
61+
Some(table_attr_infos) => match table_attr_infos.get(&attr_base_index) {
6262
None => Ok(None),
6363
Some(attr) => Ok(Some(attr.clone())),
6464
},

optd-cost-model/src/storage/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait CostModelStorageManager {
2121
async fn get_attribute_info(
2222
&self,
2323
table_id: TableId,
24-
attr_base_index: i32,
24+
attr_base_index: u64,
2525
) -> CostModelResult<Option<Attribute>>;
2626

2727
async fn get_attributes_comb_statistics(

optd-cost-model/src/storage/persistent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ impl<S: CostModelStorageLayer + Send + Sync> CostModelStorageManager
3535
async fn get_attribute_info(
3636
&self,
3737
table_id: TableId,
38-
attr_base_index: i32,
38+
attr_base_index: u64,
3939
) -> CostModelResult<Option<Attribute>> {
4040
Ok(self
4141
.backend_manager
42-
.get_attribute(table_id.into(), attr_base_index)
42+
.get_attribute(table_id.into(), attr_base_index as i32)
4343
.await?
4444
.map(|attr| Attribute {
4545
name: attr.name,

optd-persistent/src/cost_model/interface.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub type AttrId = i32;
1717
pub type ExprId = i32;
1818
pub type EpochId = i32;
1919
pub type StatId = i32;
20+
pub type AttrIndex = i32;
2021

2122
/// TODO: documentation
2223
pub enum CatalogSource {
@@ -152,7 +153,7 @@ pub trait CostModelStorageLayer {
152153
async fn get_stats_for_attr_indices_based(
153154
&self,
154155
table_id: TableId,
155-
attr_base_indices: Vec<i32>,
156+
attr_base_indices: Vec<AttrIndex>,
156157
stat_type: StatType,
157158
epoch_id: Option<EpochId>,
158159
) -> StorageResult<Option<Json>>;
@@ -168,6 +169,6 @@ pub trait CostModelStorageLayer {
168169
async fn get_attribute(
169170
&self,
170171
table_id: TableId,
171-
attribute_base_index: i32,
172+
attribute_base_index: AttrIndex,
172173
) -> StorageResult<Option<Attr>>;
173174
}

0 commit comments

Comments
 (0)