Skip to content

Commit

Permalink
fix: loading rows for JDFFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodaigh committed Oct 6, 2024
1 parent 66b8412 commit e0ebd8e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JDF"
uuid = "babc3d20-cd49-4f60-a736-a8f9c08892d3"
authors = ["Dai ZJ <[email protected]>"]
version = "0.5.2"
version = "0.5.3"

[deps]
Blosc = "a74b3585-a348-5f62-a45c-50e91977d574"
Expand Down
2 changes: 1 addition & 1 deletion build-readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ upcheck()

using Weave

weave("../README.jmd", out_path="c:/git/JDF/", doctype="github")
weave("../README.jmd", out_path="./", doctype="github")

if false
# debug
Expand Down
20 changes: 9 additions & 11 deletions src/JDFFile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,15 @@ function Base.getindex(file::JDFFile, col::Symbol)
JDF.load(file; cols = [col])[col]
end

function Base.getindex(file::JDFFile, rows, col::String)
# TODO make it load from column loader for faster access
getfield(JDF.load(file; cols = [col]), Symbol(col))[rows, :]
end

function Base.getindex(file::JDFFile, rows, cols::AbstractVector{String})
JDF.load(file; cols = cols)[rows, :]
end

# function Base.getindex(file::JDFFile, rows, col::String)
# # TODO make it load from column loader for faster access
# getfield(JDF.load(file; cols = [col]), Symbol(col))[rows]
# end

# function Base.getindex(file::JDFFile, rows, cols::AbstractVector{String})
# JDF.load(file; cols = cols)[rows, :]
# end

# Base.view(file::JDFFile, rows, cols) = getindex(file, rows, cols)
Base.view(file::JDFFile, rows, cols) = getindex(file, rows, cols)

# getindex(file::JDFFile, rows, cols) = JDF.load(file)[rows, cols]
getindex(file::JDFFile, rows, cols) = JDF.load(file)[rows, cols]
9 changes: 9 additions & 0 deletions src/Tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ Tables.istable(t::Table) = true
function Base.getindex(t::Table, col::Symbol)
t.columns[col]
end

function Base.getindex(t::Table, rows, col::Symbol)
t.columns[col][rows]
end

function Base.getindex(t::Table, rows, ::Colon)
# TODO probably not efficient
NamedTuple{names(t.columns)}([nt[rows] for nt in t.columns])
end

2 comments on commit e0ebd8e

@xiaodaigh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/116676

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.3 -m "<description of version>" e0ebd8ed3b5cc3aabbbfaf1c45b794da04e9f8da
git push origin v0.5.3

Please sign in to comment.