Skip to content

Commit 7d9b941

Browse files
authored
Merge pull request #224 from JuliaComputing/jb/0.7
WIP port to 0.7/1.0
2 parents 8bf3057 + 07935f7 commit 7d9b941

34 files changed

+272
-310
lines changed

.travis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
9+
- nightly
10+
matrix:
11+
allow_failures:
12+
- julia: nightly
813
notifications:
914
email: false
1015
# uncomment the following lines to override the default test script
11-
script:
12-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
13-
- julia -e 'Pkg.add("TextParse"); Pkg.add("IndexedTables"); Pkg.checkout("TextParse"); Pkg.checkout("IndexedTables"); Pkg.clone(pwd()); Pkg.build("JuliaDB"); Pkg.test("JuliaDB"; coverage=true)'
16+
#script:
17+
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
18+
# - julia -e 'Pkg.add("TextParse"); Pkg.add("IndexedTables"); Pkg.checkout("TextParse"); Pkg.checkout("IndexedTables"); Pkg.clone(pwd()); Pkg.build("JuliaDB"); Pkg.test("JuliaDB"; coverage=true)'
1419
after_success:
1520
# push coverage results to Coveralls
1621
- julia -e 'cd(Pkg.dir("JuliaDB")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

REQUIRE

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
julia 0.6 0.7-
2-
IndexedTables 0.7.3
3-
NamedTuples 4.0.0
4-
TextParse 0.3.0
5-
MemPool 0.0.6
6-
Dagger 0.5.2
7-
Glob 1.1.1
1+
julia 1.0
2+
IndexedTables 0.8.1
3+
TextParse 0.6.0
4+
MemPool 0.1.1
5+
Dagger 0.7.2
6+
Glob 1.2.0
87
OnlineStats 0.17.0
9-
PooledArrays 0.2.1
8+
OnlineStatsBase
9+
PooledArrays 0.4.1
1010
WeakRefStrings
1111
StatsBase
1212
DataValues
13+
Nullables
14+
RecipesBase

appveyor.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
environment:
22
matrix:
3-
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
4-
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
5-
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1.0
5+
6+
platform:
7+
- x86 # 32-bit
8+
- x64 # 64-bit
79

810
branches:
911
only:
@@ -17,18 +19,11 @@ notifications:
1719
on_build_status_changed: false
1820

1921
install:
20-
# Download most recent Julia Windows binary
21-
- ps: (new-object net.webclient).DownloadFile(
22-
$("http://s3.amazonaws.com/"+$env:JULIAVERSION),
23-
"C:\projects\julia-binary.exe")
24-
# Run installer silently, output to C:\projects\julia
25-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
22+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2623

2724
build_script:
28-
# Need to convert from shallow to complete for Pkg.clone to work
29-
- IF EXIST .git\shallow (git fetch --unshallow)
30-
- C:\projects\julia\bin\julia -e "versioninfo();
31-
Pkg.clone(pwd(), \"JuliaDB\"); Pkg.build(\"JuliaDB\")"
25+
- echo "%JL_BUILD_SCRIPT%"
26+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3227

3328
test_script:
34-
- C:\projects\julia\bin\julia -e "Pkg.test(\"JuliaDB\")"
29+
- C:\julia\bin\julia -e "using Pkg; Pkg.test(\"JuliaDB\")"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Documenter, JuliaDB, IndexedTables, Dagger, TextParse, Glob
33
load_dir(x) = map(file -> joinpath("lib", x, file), readdir(joinpath(Base.source_dir(), "src", "lib", x)))
44

55
makedocs(
6-
modules = [JuliaDB, IndexedTables, NamedTuples],
6+
modules = [JuliaDB, IndexedTables],
77
clean = false,
88
format = [:html],#, :latex],
99
sitename = "JuliaDB",

src/JuliaDB.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
__precompile__()
22
module JuliaDB
33

4-
using IndexedTables, Dagger, NamedTuples, OnlineStats
4+
using IndexedTables, Dagger, OnlineStats, Distributed, Serialization, Nullables, Printf, Statistics
55

6-
import Base: collect, select, join
6+
import Base: collect, join
77
import IndexedTables: NextTable, table, NDSparse, ndsparse, Tup, groupjoin
88
import TextParse: csvread
9-
import IndexedTables: Table
10-
import Dagger: compute, distribute, free!, gather, load, save
9+
import Dagger: compute, distribute, load, save
1110
using DataValues
1211

1312
# re-export
14-
export IndexedTable, AbstractNDSparse, NDSparse, NextTable, Columns, colnames,
13+
export AbstractNDSparse, NDSparse, NextTable, Columns, colnames,
1514
table, ndsparse, compute, groupby, summarize, groupreduce, groupjoin,
1615
ColDict, insertafter!, insertbefore!, @cols, setcol, pushcol,
1716
popcol, insertcol, insertcolafter, insertcolbefore,

src/dcolumns.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function DColumns(arrays::Tup)
1919

2020
i = findfirst(x->isa(x, ArrayOp), arrays)
2121
wrap = isa(arrays, Tuple) ? tuple :
22-
namedtuple(fieldnames(arrays)...)
22+
namedtuple(keys(arrays)...)tuple
2323
if i == 0
2424
error("""At least 1 array passed to
2525
DColumns must be a DArray""")
@@ -53,7 +53,7 @@ function DColumns(arrays::Tup)
5353
T = isa(arrays, Tuple) ? Tuple{map(eltype, arrays)...} :
5454
wrap{map(eltype, arrays)...}
5555

56-
DArray(T, domain(darrays[1]), domainchunks(darrays[1]), cs, (i, x...)->vcat(x...))
56+
DArray(T, domain(darrays[1]), domainchunks(darrays[1]), cs, dvcat)
5757
end
5858

5959
function itable(keycols::DColumns, valuecols::DColumns)
@@ -69,7 +69,7 @@ function extractarray(t::Union{DNDSparse,DColumns}, accessor)
6969
lengths = length.(domain.(cs))
7070
dmnchunks = DomainBlocks((1,), (cumsum(lengths),))
7171
T = promote_eltype_chunktypes(cs)
72-
DArray(T, ArrayDomain(1:sum(lengths)), dmnchunks, [cs...], (i, x...)->vcat(x...))
72+
DArray(T, ArrayDomain(1:sum(lengths)), dmnchunks, [cs...], dvcat)
7373
end
7474

7575
cs = map(delayed(accessor), t.chunks)
@@ -101,15 +101,15 @@ function columns(t::Union{DNDSparse, DColumns}, which::Tuple...)
101101
ls = length.(domain.(cs))
102102
d = ArrayDomain((1:sum(ls),))
103103
dchunks = DomainBlocks((1,), (cumsum(ls),))
104-
DArray(eltype(T), d, dchunks, cs, (i, x...) -> vcat(x...))
104+
DArray(eltype(T), d, dchunks, cs, dvcat)
105105
end
106106
end
107107

108108
function _columns_as(t, which)
109109
stripas(w) = isa(w, As) ? w.src : w
110110
which_ = ntuple(i->as(stripas(which[i]), i), length(which))
111111
cs = columns(t, which_)
112-
asvecs = find(isas, which)
112+
asvecs = findall(isas, which)
113113
outvecs = Any[cs...]
114114
outvecs[asvecs] = map((w,x) -> w.f(x), [which[asvecs]...], outvecs[asvecs])
115115
tup = IndexedTables._output_tuple(which)

src/flatten.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function mapslices(f, x::DNDSparse, dims; name=nothing)
99
# Note: the key doesn't need to be put in a tuple, this is
1010
# also bad for sortperm, but is required since DArrays aren't
1111
# parameterized by the container type Columns
12-
vals = isempty(dims) ? values(x) : (keys(x, (dims...)), values(x))
13-
tmp = ndsparse((keys(x, (iterdims...)),), vals,
12+
vals = isempty(dims) ? values(x) : (keys(x, (dims...,)), values(x))
13+
tmp = ndsparse((keys(x, (iterdims...,)),), vals,
1414
allowoverlap=false, closed=true)
1515

1616
cs = delayedmap(tmp.chunks) do c

src/indexing.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747

4848
# update a given domain to include a new key
4949
function update_domain(d::IndexSpace{<:NamedTuple}, key::Tuple)
50-
knt = namedtuple(fieldnames(first(d))...)(key...)
50+
knt = namedtuple(keys(first(d))...)(key)
5151
IndexSpace(Interval(min(first(d.interval), knt),
5252
max(last(d.interval), knt)),
5353
Interval(map(min, first(d.interval), knt),
@@ -75,10 +75,6 @@ function insert_row!(x::DNDSparse{K,T}, idxs::Tuple, val) where {K,T}
7575
ds[i] = update_domain(ds[i], idxs)
7676
tmp = cs[i]
7777
cs[i] = compute(get_context(), delayed(x->(x[idxs...] = val; x))(cs[i]))
78-
isa(cs[i].handle, DRef) && Dagger.addrefcount(cs[i].handle, 1)
79-
isa(tmp.handle, DRef) && Dagger.addrefcount(tmp.handle, -1)
80-
# TODO: tmp is not freed yet. Should ensure Dagger.free_chunks is called on it.
81-
8278
x.domains = ds
8379
x.chunks = cs
8480
end

src/interval.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Base.Test
2-
31
"""
42
An interval type tailored specifically to store intervals of
53
indices of an NDSparse object. Some of the operations on this
@@ -17,7 +15,7 @@ Base.last(int::Interval) = int.last
1715
Base.isempty(int::Interval) = first(int) > last(int)
1816
Base.isless(x::Interval, y::Interval) = x.last < y.first
1917
Base.in(x, int::Interval) = first(int) <= x <= last(int)
20-
Base.in(x::Range, int::Interval) = hasoverlap(Interval(first(x),last(x)), int)
18+
Base.in(x::AbstractRange, int::Interval) = hasoverlap(Interval(first(x),last(x)), int)
2119
Base.in(x::AbstractArray, int::Interval) = any(a in int for a in x)
2220
Base.in(x::Colon, int::Interval) = true
2321
Base.in(int::Interval, x::Union{AbstractArray, Colon}) = x in int

src/io.jl

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export loadfiles, ingest, ingest!, load, save, loadndsparse, loadtable
2-
import Base: serialize, deserialize
3-
import Dagger: refcount_chunks
2+
import Serialization: serialize, deserialize
43

54
const JULIADB_DIR = ".juliadb"
65
const JULIADB_FILECACHE = "csv_metadata"
@@ -22,13 +21,13 @@ end
2221

2322
function offset_index!(x, o)
2423
l = length(x)
25-
copy!(columns(x.index)[1], o:o+l-1)
24+
copyto!(columns(x.index)[1], o:o+l-1)
2625
x
2726
end
2827

2928
function offset_index!(x::DNDSparse, o=1)
3029
lengths = map(a->get(a.nrows), x.domains)
31-
offs = [0, cumsum(lengths[1:end-1]);] .+ 1
30+
offs = [0; cumsum(lengths[1:end-1])] .+ 1
3231
fromchunks(delayedmap(offset_index!, x.chunks, offs))
3332
end
3433

@@ -222,33 +221,25 @@ function _makerelative!(t, dir::AbstractString)
222221
end
223222
end
224223

225-
function serialize(io::AbstractSerializer, A::Union{DNextTable,DNDSparse})
226-
@async refcount_chunks(A)
227-
invoke(serialize, Tuple{AbstractSerializer,Any}, io, A)
228-
end
229-
230224
deserialize(io::AbstractSerializer, DT::Type{DNDSparse{K,V}}) where {K,V} = _deser(io, DT)
231225
deserialize(io::AbstractSerializer, DT::Type{DNextTable{T,K}}) where {T,K} = _deser(io, DT)
232226
function _deser(io::AbstractSerializer, t)
233-
nf = nfields(t)
227+
nf = fieldcount(t)
234228
x = ccall(:jl_new_struct_uninit, Any, (Any,), t)
235-
t.mutable && Base.Serializer.deserialize_cycle(io, x)
229+
t.mutable && Serialization.deserialize_cycle(io, x)
236230
for i in 1:nf
237231
tag = Int32(read(io.io, UInt8)::UInt8)
238-
if tag != Base.Serializer.UNDEFREF_TAG
239-
ccall(:jl_set_nth_field, Void, (Any, Csize_t, Any), x, i-1, Base.Serializer.handle_deserialize(io, tag))
232+
if tag != Serialization.UNDEFREF_TAG
233+
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), x, i-1, Serialization.handle_deserialize(io, tag))
240234
end
241235
end
242-
finalizer(x, free!)
243236
return x
244237
end
245238

246-
refcount_chunks(A::Union{DNextTable,DNDSparse}) = refcount_chunks(A.chunks)
247-
248239
using WeakRefStrings
249240

250241
function MemPool.mmwrite(io::AbstractSerializer, arr::StringArray)
251-
Base.serialize_type(io, MemPool.MMSer{StringArray})
242+
Serialization.serialize_type(io, MemPool.MMSer{StringArray})
252243
serialize(io, eltype(arr))
253244
MemPool.mmwrite(io, arr.buffer)
254245
MemPool.mmwrite(io, arr.offsets)

0 commit comments

Comments
 (0)