Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor duplicate IndexOutput struct #4586

Closed
leaf-potato opened this issue Aug 19, 2024 · 4 comments
Closed

Refactor duplicate IndexOutput struct #4586

leaf-potato opened this issue Aug 19, 2024 · 4 comments
Labels
C-enhancement Category Enhancements

Comments

@leaf-potato
Copy link
Contributor

leaf-potato commented Aug 19, 2024

What type of enhancement is this?

Refactor

What does the enhancement do?

When I read the relevant code of the Mito engine, I found that two identical structures are defined:

pub struct FulltextIndexOutput {
/// Size of the index.
pub index_size: ByteCount,
/// Number of rows in the index.
pub row_count: RowCount,
/// Available columns in the index.
pub columns: Vec<ColumnId>,
}

pub struct InvertedIndexOutput {
/// Size of the index.
pub index_size: ByteCount,
/// Number of rows in the index.
pub row_count: RowCount,
/// Available columns in the index.
pub columns: Vec<ColumnId>,
}

Perhaps defining a base structure is sufficient.

Implementation challenges

#[derive(Debug, Clone, Default)]
pub struct IndexBaseOutput {
    /// Size of the index.
    pub index_size: ByteCount,
    /// Number of rows in the index.
    pub row_count: RowCount,
    /// Available columns in the index.
    pub columns: Vec<ColumnId>,
}

pub type InvertedIndexOutput = IndexBaseOutput;
pub type FulltextIndexOutput = IndexBaseOutput;
  1. Define IndexBaseOutput struct.
  2. type IndexBaseOutput to InvertedIndexOutput and FulltextIndexOutput.

In the future, if InvertedIndexOutput or FulltextIndexOutput has non-public fields, it can be modified like this:

struct InvertedIndexOutput {
    base_output: IndexBaseOutput,
    .....
}
@leaf-potato leaf-potato added the C-enhancement Category Enhancements label Aug 19, 2024
@evenyag
Copy link
Contributor

evenyag commented Aug 20, 2024

@zhongzc What do you think?

@zhongzc
Copy link
Contributor

zhongzc commented Aug 20, 2024

I have no objection, you are free to change it this way. My original idea was that these two indexes have the opportunity to present different Output, and it would be more convenient to separate them in case fields are added later.

@leaf-potato
Copy link
Contributor Author

leaf-potato commented Aug 20, 2024

I have no objection, you are free to change it this way.

Thanks, I'll submit a PR later.

@evenyag
Copy link
Contributor

evenyag commented Aug 21, 2024

Closed by #4592

@evenyag evenyag closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements
Projects
None yet
Development

No branches or pull requests

3 participants