Skip to content

Tortar/KeyedTables.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IdTables.jl

Build Status Coverage Aqua

IdTables.jl implements containers with stable identifiers storing data with a structure-of-vectors layout.

The main type exported by the library is IdTable, which is a type compatible with the Tables.jl interface. Additionally, also the struct vectors types SlotMapStructVector and SparseSetStructVector, which internally are used to store the data of an IdTable, are available.

Differently from other packages such as DataFrames.jl, TypedTables.jl, etc..., each row of an IdTable is assigned a stable identifier when it's added to the table which can then be used to index into the container. This allows to support O(1) access, addition and deletion of ID-backed rows without compromising the performance of operations on single homogeneous fields, unlike with a dictionary of structs.

Examples

julia> using IdTables

julia> table = IdTable(name = ["alice","bob"], age = [30, 40]);

julia> r = table[1] # retrieve row with id 1
(id = 1, name = "alice", age = 30)

julia> rv = @view(table[2])
IdRowView(id = 2, name = "bob", age = 40)

julia> rv.name
"bob"

julia> rv.age = 10
10

julia> push!(table, (name = "carol", age = 25));

julia> delete!(table, 2); # delete row with id 2

julia> table[2] # now 2 is no longer a valid id
ERROR: KeyError: key 2 not found
...

julia> sum(table.age) # this will use the stored age vector
55

Contributing

Contributions are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new features, feel free to open an issue or submit a pull request.

About

Tables with stable identifiers in Julia

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages