Skip to content

Improve GenericRow usage experience #186

@leekeiabstraction

Description

@leekeiabstraction

Search before asking

  • I searched in the issues and found nothing similar.

Description

Currently for Kv delete, we have to fill the non-primary key field.

We can introduce a method such as GenericRow::new(field_count: usize) just like java side. The default is null, but user can set the field.
Then, for delete, users just need to do the following

let mut row = GenericRow::new(3);
row.set_field(0, 2)

However we need to be mindful of changing current GenericRow behaviour. We currently use insert for set_field. This results in field count mismatch if the GenericRow was created with the right number of fields to start with. This issue should include refactoring in places that maybe affected by new() and set_field() behaviour change

impl<'a> Default for GenericRow<'a> {
    fn default() -> Self {
        Self::new()
    }
}

impl<'a> GenericRow<'a> {
...
    pub fn new() -> GenericRow<'a> {
        GenericRow { values: vec![] }
    }

...

    pub fn set_field(&mut self, pos: usize, value: impl Into<Datum<'a>>) {
        self.values.insert(pos, value.into());
    }
}

See origin of conversation: #181 (comment)

Willingness to contribute

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions