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

IDs of database tables should be contiguous and start at 0 #41

Open
pdigiglio opened this issue Dec 26, 2016 · 1 comment
Open

IDs of database tables should be contiguous and start at 0 #41

pdigiglio opened this issue Dec 26, 2016 · 1 comment

Comments

@pdigiglio
Copy link
Collaborator

The underlying data structure of the *Table classes is now a std::vector (instead of a std::map). This means that the IDs of the input database tables must be contiguous and should start at 0.

If the IDs don't start at 0, an artificial shift can be introduced between the database ID and the vector index, e.g. through the function idToVectorIndex:

class DBTable {
public:
    // ...
private:
    /// The vector of database rows.
    std::vector<T> Vector_;

    /// Helper function to convert database ID's to vector indices.
    virtual const size_type idToVectorIndex(const index_type& id) const;
};

So far the ID shift is hard-coded, so it would be much easier if all the table IDs started at 0.

@pdigiglio
Copy link
Collaborator Author

Actually it's better if the table IDs start at 1. This way we can use the ID 0 as an invalid ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant