Skip to content

Commit fefbc93

Browse files
committed
Remove TimerOutputs
1 parent 3efcf71 commit fefbc93

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a"
1313
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1414
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1515
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
16-
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
1716

1817
[compat]
1918
DataFrames = "1.3.2"

src/TSFrames.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TSFrames
22

3-
using DataFrames, Dates, ShiftedArrays, RecipesBase, RollingFunctions, Tables, TimerOutputs
3+
using DataFrames, Dates, ShiftedArrays, RecipesBase, RollingFunctions, Tables
44

55
import Base.convert
66
import Base.diff

src/join.jl

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function fast_join(left::TSFrame, right::TSFrame; method = :outer)
395395

396396
to = Main.to
397397

398-
merged_idx, merged_idx_left, merged_idx_right = @timeit to "sort_merge_idx" sort_merge_idx(index(left), index(right), Val(true), Val(true))
398+
merged_idx, merged_idx_left, merged_idx_right = sort_merge_idx(index(left), index(right), Val(true), Val(true))
399399

400400
merged_length = length(merged_idx)
401401

@@ -404,43 +404,45 @@ function fast_join(left::TSFrame, right::TSFrame; method = :outer)
404404
# and we can go down a faster path of simple concatenation.
405405
# add_missings = !(length(merged_idx) == length(left) == length(right))
406406

407-
@timeit to "column disambiguation" begin
408-
409-
left_colnames = setdiff(Tables.columnnames(left.coredata), (:Index,))
410-
right_colnames = setdiff(Tables.columnnames(right.coredata), (:Index,))
411-
left_colidxs = Tables.columnindex.((left.coredata,), left_colnames)
412-
right_colidxs = Tables.columnindex.((right.coredata,), right_colnames)
413-
disambiguated_right_colnames = deepcopy(right_colnames)
414-
415-
# disambiguate col names
416-
for (ind, colname) in enumerate(right_colnames)
417-
leftind = findfirst(==(colname), left_colnames)
418-
isnothing(leftind) || (disambiguated_right_colnames[ind] = Symbol(string(colname)*"_1"))
419-
end
420-
407+
# this machinery disambiguates column names
408+
# It doesn't take too much time, but it would be cleaner to somehow use
409+
# DataFrames' machinery here.
410+
left_colnames = setdiff(Tables.columnnames(left.coredata), (:Index,))
411+
right_colnames = setdiff(Tables.columnnames(right.coredata), (:Index,))
412+
left_colidxs = Tables.columnindex.((left.coredata,), left_colnames)
413+
right_colidxs = Tables.columnindex.((right.coredata,), right_colnames)
414+
disambiguated_right_colnames = deepcopy(right_colnames)
415+
416+
# disambiguate col names
417+
for (ind, colname) in enumerate(right_colnames)
418+
leftind = findfirst(==(colname), left_colnames)
419+
isnothing(leftind) || (disambiguated_right_colnames[ind] = Symbol(string(colname)*"_1"))
421420
end
422421

423-
@timeit to "DataFrame construction" begin
424-
result = DataFrame(:Index => merged_idx; makeunique = false, copycols = false)
425-
left_coredata = left.coredata
426-
right_coredata = right.coredata
427-
end
428422

429-
@timeit to "column building" for idx in 1:length(left_colnames)
423+
# Construct the DataFrame
424+
result = DataFrame(:Index => merged_idx; makeunique = false, copycols = false)
425+
left_coredata = left.coredata
426+
right_coredata = right.coredata
427+
428+
# Store the data from the left table in the result
429+
for idx in 1:length(left_colnames)
430430
col_idx = left_colidxs[idx]
431-
contents = @timeit to "column allocation" DataFrames.similar_missing(left.coredata[!, col_idx], merged_length)
432-
@timeit to "column population" (@inbounds contents[merged_idx_left] = left_coredata[!, col_idx])
433-
@timeit to "column transfer" (result[!, left_colnames[idx]] = contents)
431+
contents = DataFrames.similar_missing(left.coredata[!, col_idx], merged_length)
432+
@inbounds contents[merged_idx_left] = left_coredata[!, col_idx]
433+
result[!, left_colnames[idx]] = contents
434434
end
435435

436-
@timeit to "column building" for idx in 1:length(right_colnames)
436+
# Store the data from the right table in the result
437+
for idx in 1:length(right_colnames)
437438
col_idx = right_colidxs[idx]
438-
contents = @timeit to "column allocation" DataFrames.similar_missing(right.coredata[!, col_idx], merged_length)
439-
@timeit to "column population" (@inbounds contents[merged_idx_right] = right_coredata[!, col_idx])
440-
@timeit to "column transfer" result[!, disambiguated_right_colnames[idx]] = contents
439+
contents = DataFrames.similar_missing(right.coredata[!, col_idx], merged_length)
440+
@inbounds contents[merged_idx_right] = right_coredata[!, col_idx]
441+
# note that column names have to be disambiguated
442+
result[!, disambiguated_right_colnames[idx]] = contents
441443
end
442444

443-
return @timeit to "TSFrame construction" TSFrame(result, :Index; issorted = true, copycols = false)
445+
return TSFrame(result, :Index; issorted = true, copycols = false)
444446

445447
end
446448

0 commit comments

Comments
 (0)