diff --git a/Core/src/DataToolkitBase.jl b/Core/src/DataToolkitBase.jl index 582dbc998..33f07b8ff 100644 --- a/Core/src/DataToolkitBase.jl +++ b/Core/src/DataToolkitBase.jl @@ -10,7 +10,7 @@ export loadcollection!, dataset # For extension packages export AbstractDataTransformer, DataStorage, DataLoader, DataWriter, - DataSet, DataCollection, QualifiedType, Identifier, FilePath, SmallDict, + DataSet, DataCollection, QualifiedType, Identifier, FilePath, LintItem, LintReport export load, storage, getstorage, putstorage, save, getlayer, resolve, refine, parse_ident, supportedtypes, typeify, create, createpriority, lint @@ -34,7 +34,6 @@ include("model/utils.jl") include("model/advice.jl") include("model/errors.jl") -include("model/smalldict.jl") include("model/qualifiedtype.jl") include("model/identification.jl") include("model/parameters.jl") diff --git a/Core/src/interaction/externals.jl b/Core/src/interaction/externals.jl index 8663dc696..233644bfb 100644 --- a/Core/src/interaction/externals.jl +++ b/Core/src/interaction/externals.jl @@ -61,14 +61,13 @@ end Return the data set identified by `identstr`, optionally specifying the `collection` the data set should be found in and any `parameters` that apply. """ -dataset(identstr::AbstractString) = resolve(identstr; resolvetype=false)::DataSet -dataset(identstr::AbstractString, parameters::SmallDict{String, Any}) = - resolve(identstr, parameters; resolvetype=false)::DataSet -dataset(identstr::AbstractString, parameters::Dict{String, Any}) = - dataset(identstr, smallify(parameters)) +dataset(identstr::AbstractString)::DataSet = + resolve(identstr; resolvetype=false) +dataset(identstr::AbstractString, parameters::Dict{String, Any})::DataSet = + resolve(identstr, parameters; resolvetype=false) function dataset(identstr::AbstractString, kv::Pair{<:AbstractString, <:Any}, kvs::Pair{<:AbstractString, <:Any}...) - parameters = SmallDict{String, Any}() + parameters = newdict(String, Any, length(kvs) + 1) parameters[String(first(kv))] = last(kv) for (key, value) in kvs parameters[String(key)] = value diff --git a/Core/src/interaction/manipulation.jl b/Core/src/interaction/manipulation.jl index 7c023f1dc..5683a31a7 100644 --- a/Core/src/interaction/manipulation.jl +++ b/Core/src/interaction/manipulation.jl @@ -305,7 +305,7 @@ When no value is set, `nothing` is returned instead and if `quiet` is unset function config_get(collection::DataCollection, propertypath::Vector{String}; quiet::Bool=false) config = collection.parameters for segment in propertypath - config isa AbstractDict || (config = SmallDict{String, Nothing}();) + config isa AbstractDict || (config = newdict(String, Nothing, 0);) config = get(config, segment, nothing) if isnothing(config) quiet || printstyled(" unset\n", color=:light_black) @@ -339,11 +339,11 @@ function config_set(collection::DataCollection, propertypath::Vector{String}, va # however this way any plugin-processing of the configuration # will be symmetric (i.e. applied at load and write). snapshot = convert(Dict, collection) - config = get(snapshot, "config", SmallDict{String, Any}()) + config = get(snapshot, "config", newdict(String, Any, 0)) window = config for segment in propertypath[1:end-1] if !haskey(window, segment) - window[segment] = SmallDict{String, Any}() + window[segment] = newdict(String, Any, 0) end window = window[segment] end @@ -385,7 +385,7 @@ function config_unset(collection::DataCollection, propertypath::Vector{String}; # however this way any plugin-processing of the configuration # will be symmetric (i.e. applied at load and write). snapshot = convert(Dict, collection) - config = get(snapshot, "config", SmallDict{String, Any}()) + config = get(snapshot, "config", newdict(String, Any, 0)) window = config for segment in propertypath[1:end-1] if !haskey(window, segment) diff --git a/Core/src/model/errors.jl b/Core/src/model/errors.jl index d782e44f9..f1ac81b83 100644 --- a/Core/src/model/errors.jl +++ b/Core/src/model/errors.jl @@ -283,7 +283,7 @@ by the current version of $(@__MODULE__). # Example occurrence ```julia-repl -julia> fromspec(DataCollection, SmallDict{String, Any}("data_config_version" => -1)) +julia> fromspec(DataCollection, Dict{String, Any}("data_config_version" => -1)) ERROR: CollectionVersionMismatch: -1 (specified) ≠ $LATEST_DATA_CONFIG_VERSION (current) The data collection specification uses the v-1 data collection format, however the installed DataToolkitBase version expects the v$LATEST_DATA_CONFIG_VERSION version of the format. @@ -334,7 +334,7 @@ Modification of `collection` is not viable, as it is read-only. # Example Occurrence ```julia-repl -julia> lockedcollection = DataCollection(SmallDict{String, Any}("uuid" => Base.UUID(rand(UInt128)), "config" => SmallDict{String, Any}("locked" => true))) +julia> lockedcollection = DataCollection(Dict{String, Any}("uuid" => Base.UUID(rand(UInt128)), "config" => Dict{String, Any}("locked" => true))) julia> write(lockedcollection) ERROR: ReadonlyCollection: The data collection unnamed#298 is locked Stacktrace: [...] @@ -357,7 +357,7 @@ A catch-all for issues involving data transformers, with details given in `msg`. # Example occurrence ```julia-repl -julia> emptydata = DataSet(DataCollection(), "empty", SmallDict{String, Any}("uuid" => Base.UUID(rand(UInt128)))) +julia> emptydata = DataSet(DataCollection(), "empty", Dict{String, Any}("uuid" => Base.UUID(rand(UInt128)))) DataSet empty julia> read(emptydata) @@ -381,7 +381,7 @@ there is no transformer that satisfies this restriction. # Example occurrence ```julia-repl -julia> emptydata = DataSet(DataCollection(), "empty", SmallDict{String, Any}("uuid" => Base.UUID(rand(UInt128)))) +julia> emptydata = DataSet(DataCollection(), "empty", Dict{String, Any}("uuid" => Base.UUID(rand(UInt128)))) DataSet empty julia> read(emptydata, String) @@ -483,7 +483,7 @@ macro getparam(expr::Expr, default=nothing) typename = if type isa Symbol type elseif Meta.isexpr(type, :curly) first(type.args) else :Any end - default = if typename ∈ (:Vector, :Dict, :SmallDict) + default = if typename ∈ (:Vector, :Dict) :($type()) else :nothing end end diff --git a/Core/src/model/identification.jl b/Core/src/model/identification.jl index 460a2b2af..1decb1cfc 100644 --- a/Core/src/model/identification.jl +++ b/Core/src/model/identification.jl @@ -1,4 +1,4 @@ -Identifier(ident::Identifier, params::SmallDict{String, Any}; replace::Bool=false) = +Identifier(ident::Identifier, params::Dict{String, Any}; replace::Bool=false) = Identifier(ident.collection, ident.dataset, ident.type, if replace || isempty(ident.parameters); params @@ -8,7 +8,7 @@ Identifier(ident::Identifier, params::SmallDict{String, Any}; replace::Bool=fals Identifier(ident::Identifier, ::Nothing; replace::Bool=false) = if replace - Identifier(ident, SmallDict{String, Any}(); replace) + Identifier(ident, newdict(String, Any, 0); replace) else ident end @@ -50,7 +50,7 @@ end # Identifier(spec::AbstractString) = parse(Identifier, spec) -Identifier(spec::AbstractString, params::SmallDict{String, Any}) = +Identifier(spec::AbstractString, params::Dict{String, Any}) = Identifier(parse(Identifier, spec), params) Base.:(==)(a::Identifier, b::Identifier) = @@ -176,13 +176,13 @@ resolve(ident::Identifier; resolvetype::Bool=true, stack::Vector{DataCollection} end """ - resolve(identstr::AbstractString, parameters::Union{SmallDict{String, Any}, Nothing}=nothing; + resolve(identstr::AbstractString, parameters::Union{Dict{String, Any}, Nothing}=nothing; resolvetype::Bool=true, stack::Vector{DataCollection}=STACK) Attempt to resolve the identifier given by `identstr` and `parameters` against each layer of the data `stack` in turn. """ -function resolve(identstr::AbstractString, parameters::Union{SmallDict{String, Any}, Nothing}=nothing; +function resolve(identstr::AbstractString, parameters::Union{Dict{String, Any}, Nothing}=nothing; resolvetype::Bool=true, stack::Vector{DataCollection}=STACK) isempty(stack) && throw(EmptyStackError()) if (cname = parse(Identifier, identstr).collection) |> !isnothing diff --git a/Core/src/model/parameters.jl b/Core/src/model/parameters.jl index 676409ea3..e6d5a99ec 100644 --- a/Core/src/model/parameters.jl +++ b/Core/src/model/parameters.jl @@ -15,11 +15,12 @@ Obtain a form (depending on `action`) of `value`, a property within `source`. **`:encode`** Look for `Identifier`s in `value`, and turn them into DataSet references (the inverse of `:extract`). """ -function dataset_parameters(collection::DataCollection, action::Val, params::SmallDict{String,Any}) - SmallDict{String, Any}( - keys(params) |> collect, - [dataset_parameters(collection, action, value) - for value in values(params)]) +function dataset_parameters(collection::DataCollection, action::Val, params::Dict{String,Any}) + d = newdict(String, Any, length(params)) + for (key, value) in params + d[key] = dataset_parameters(collection, action, value) + end + d end function dataset_parameters(collection::DataCollection, action::Val, param::Vector) @@ -80,7 +81,7 @@ end add_dataset_refs!(acc::Vector{Identifier}, @nospecialize(adt::AbstractDataTransformer)) = add_dataset_refs!(acc, adt.parameters) -add_dataset_refs!(acc::Vector{Identifier}, props::SmallDict) = +add_dataset_refs!(acc::Vector{Identifier}, props::Dict) = for val in values(props) add_dataset_refs!(acc, val) end diff --git a/Core/src/model/parser.jl b/Core/src/model/parser.jl index cdfa438c0..d556bf1a1 100644 --- a/Core/src/model/parser.jl +++ b/Core/src/model/parser.jl @@ -88,7 +88,7 @@ function parse_ident(spec::AbstractString) parse(QualifiedType, spec[3:end]) end Identifier(collection, something(tryparse(UUID, dataset), dataset), - dtype, SmallDict{String,Any}()) + dtype, newdict(String, Any, 0)) end # --------------- @@ -108,10 +108,10 @@ In some cases, it makes sense for this to be explicitly defined for a particular transformer. """ function supportedtypes end # See `interaction/externals.jl` for method definitions. -supportedtypes(ADT::Type{<:AbstractDataTransformer}, spec::SmallDict{String, Any}, _::DataSet) = +supportedtypes(ADT::Type{<:AbstractDataTransformer}, spec::Dict{String, Any}, _::DataSet) = supportedtypes(ADT, spec) -supportedtypes(ADT::Type{<:AbstractDataTransformer}, _::SmallDict{String, Any}) = +supportedtypes(ADT::Type{<:AbstractDataTransformer}, _::Dict{String, Any}) = supportedtypes(ADT) (ADT::Type{<:AbstractDataTransformer})(dataset::DataSet, spec::Dict{String, Any}) = @@ -129,7 +129,7 @@ Create an `ADT` of `dataset` according to `spec`. from the `"driver"` key in `spec`. """ function fromspec(ADT::Type{<:AbstractDataTransformer}, dataset::DataSet, spec::Dict{String, Any}) - parameters = smallify(spec) + parameters = shrinkdict(spec) driver = if ADT isa DataType first(ADT.parameters) elseif haskey(parameters, "driver") @@ -171,7 +171,7 @@ end DataStorage{driver}(dataset::Union{DataSet, DataCollection}, type::Vector{<:QualifiedType}, priority::Int, - parameters::SmallDict{String, Any}) where {driver} = + parameters::Dict{String, Any}) where {driver} = DataStorage{driver, typeof(dataset)}(dataset, type, priority, parameters) # --------------- @@ -180,7 +180,7 @@ DataStorage{driver}(dataset::Union{DataSet, DataCollection}, DataCollection(name::Union{String, Nothing}=nothing; path::Union{String, Nothing}=nothing) = DataCollection(LATEST_DATA_CONFIG_VERSION, name, uuid4(), String[], - SmallDict{String, Any}(), DataSet[], path, + Dict{String, Any}(), DataSet[], path, AdviceAmalgamation(String[]), Main) function DataCollection(spec::Dict{String, Any}; path::Union{String, Nothing}=nothing, mod::Module=Base.Main) @@ -218,7 +218,7 @@ function fromspec(::Type{DataCollection}, spec::Dict{String, Any}; uuid4() end) plugins::Vector{String} = get(spec, "plugins", String[]) - parameters = get(spec, "config", Dict{String, Any}()) |> smallify + parameters = get(spec, "config", Dict{String, Any}()) |> shrinkdict unavailable_plugins = setdiff(plugins, getproperty.(PLUGINS, :name)) if length(unavailable_plugins) > 0 @warn string("The ", join(unavailable_plugins, ", ", ", and "), @@ -263,7 +263,7 @@ function fromspec(::Type{DataSet}, collection::DataCollection, name::String, spe @info "Data set '$name' had no UUID, one has been generated." uuid4() end) - parameters = smallify(spec) + parameters = shrinkdict(spec) for reservedname in DATA_CONFIG_RESERVED_ATTRIBUTES[:dataset] delete!(parameters, reservedname) end diff --git a/Core/src/model/smalldict.jl b/Core/src/model/smalldict.jl deleted file mode 100644 index 91c7bf596..000000000 --- a/Core/src/model/smalldict.jl +++ /dev/null @@ -1,92 +0,0 @@ -# SmallDict implementation - -SmallDict{K, V}() where {K, V} = - SmallDict{K, V}(Vector{K}(), Vector{V}()) -SmallDict() = SmallDict{Any, Any}() - -SmallDict{K, V}(kv::Vector{<:Pair}) where {K, V} = - SmallDict{K, V}(Vector{K}(first.(kv)), Vector{V}(last.(kv))) -SmallDict(kv::Vector{Pair{K, V}}) where {K, V} = - SmallDict{K, V}(first.(kv), last.(kv)) -SmallDict{K, V}(kv::Pair...) where {K, V} = - SmallDict{K, V}(Vector{K}(first.(kv) |> collect), - Vector{V}(last.(kv) |> collect)) -SmallDict(kv::Pair{K, V}...) where {K, V} = SmallDict{K, V}(kv...) -SmallDict(kv::Pair...) = SmallDict(collect(first.(kv)), collect(last.(kv))) - -Base.convert(::Type{SmallDict{K, V}}, dict::Dict) where {K, V} = - SmallDict{K, V}(Vector{K}(keys(dict) |> collect), - Vector{V}(values(dict) |> collect)) -Base.convert(::Type{SmallDict}, dict::Dict{K, V}) where {K, V} = - convert(SmallDict{K, V}, dict) - -""" - smallify(dict::Dict) - -Create a `SmallDict` version of `dict`, with all contained `Dict`s recursively -converted into `SmallDict`s. -""" -function smallify(dict::Dict{K, V}) where {K, V} - stype(v) = v - stype(::Type{Dict{Kv, Vv}}) where {Kv, Vv} = SmallDict{Kv, stype(Vv)} - if V <: Dict || Dict <: V - SmallDict{K, stype(V)}(Vector{K}(keys(dict) |> collect), - Vector{stype(V)}([ - if v isa Dict smallify(v) else v end - for v in values(dict)])) - else - convert(SmallDict{K, V}, dict) - end -end -smallify(dict::SmallDict) = dict - -Base.length(d::SmallDict) = length(d.keys) -Base.keys(d::SmallDict) = d.keys -Base.values(d::SmallDict) = d.values - -Base.iterate(d::SmallDict, index=1) = if index <= length(d) - (d.keys[index] => d.values[index], index+1) -end - -function Base.get(d::SmallDict{K}, key::K, default) where {K} - @inbounds for (i, k) in enumerate(d.keys) - k == key && return d.values[i] - end - default -end - -function Base.setindex!(d::SmallDict{K, V}, value::V, key::K) where {K, V} - @inbounds for (i, k) in enumerate(d.keys) - if k == key - d.values[i] = value - return d - end - end - push!(d.keys, key) - push!(d.values, value) - d -end - -function Base.delete!(d::SmallDict{K}, key::K) where {K} - @inbounds for (i, k) in enumerate(d.keys) - if k == key - deleteat!(d.keys, i) - deleteat!(d.values, i) - return d - end - end - d -end - -function Base.sizehint!(d::SmallDict, size::Integer) - sizehint!(d.keys, size) - sizehint!(d.values, size) -end - -Base.empty(::SmallDict{K, V}) where {K, V} = SmallDict{K, V}() - -function Base.empty!(d::SmallDict) - empty!(d.keys) - empty!(d.values) - d -end diff --git a/Core/src/model/types.jl b/Core/src/model/types.jl index e7d6749f1..c8b0a3377 100644 --- a/Core/src/model/types.jl +++ b/Core/src/model/types.jl @@ -49,23 +49,6 @@ struct QualifiedType parameters::Tuple end -""" - SmallDict{K, V} - -A little (ordered) dictionary type for a small number of keys. -Rather than doing anything clever with hashes, it just keeps -a list of keys, and a list of values. - -For a small number of items, this has time and particularly space advantages -over a standard dictionary — a Dict{String, Any}("a" => 1) is about 4x larger -than the equivalent SmallDict. Further testing indicates this provides a ~40% -reduction on the overall in-memory size of a `DataCollection`. -""" -struct SmallDict{K, V} <: AbstractDict{K, V} - keys::Vector{K} - values::Vector{V} -end - """ A description that can be used to uniquely identify a DataSet. @@ -81,7 +64,7 @@ Four fields are used to describe the target DataSet: Identifier(collection::Union{AbstractString, UUID, Nothing}, dataset::Union{AbstractString, UUID}, type::Union{QualifiedType, Nothing}, - parameters::SmallDict{String, Any}) + parameters::Dict{String, Any}) ``` # Parsing @@ -99,7 +82,7 @@ struct Identifier collection::Union{AbstractString, UUID, Nothing} dataset::Union{AbstractString, UUID} type::Union{<:QualifiedType, Nothing} - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} end """ @@ -124,7 +107,7 @@ In addition, each subtype has the following fields: - `type::Vector{<:QualifiedType}`, the Julia types the method supports - `priority::Int`, the priority with which this method should be used, compared to alternatives. Lower values have higher priority. -- `parameters::SmallDict{String, Any}`, any parameters applied to the method. +- `parameters::Dict{String, Any}`, any parameters applied to the method. """ abstract type AbstractDataTransformer{driver} end @@ -132,21 +115,21 @@ struct DataStorage{driver, T} <: AbstractDataTransformer{driver} dataset::T type::Vector{<:QualifiedType} priority::Int - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} end struct DataLoader{driver} <: AbstractDataTransformer{driver} dataset type::Vector{<:QualifiedType} priority::Int - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} end struct DataWriter{driver} <: AbstractDataTransformer{driver} dataset type::Vector{<:QualifiedType} priority::Int - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} end """ @@ -263,7 +246,7 @@ struct DataSet collection name::String uuid::UUID - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} storage::Vector{DataStorage} loaders::Vector{DataLoader} writers::Vector{DataWriter} @@ -299,7 +282,7 @@ struct DataCollection name::Union{String, Nothing} uuid::UUID plugins::Vector{String} - parameters::SmallDict{String, Any} + parameters::Dict{String, Any} datasets::Vector{DataSet} path::Union{String, Nothing} advise::AdviceAmalgamation diff --git a/Core/src/model/utils.jl b/Core/src/model/utils.jl index 795f886a9..4200c22ff 100644 --- a/Core/src/model/utils.jl +++ b/Core/src/model/utils.jl @@ -1,5 +1,60 @@ # Utility functions that don't belong to any particular file +""" + newdict(K::Type, V::Type, capacity::Int) -> Dict{K, V} + +Create a new `Dict{K, V}` sized to hold `capacity` elements, hopefully without +resizing. Depending on the particular value of `capacity` and the Julia version, +this can result in substantial memory savings for small dictionaries. +""" +function newdict end + +@static if VERSION >= v"1.11-alpha1" + function newdict(K::Type, V::Type, capacity::Int) + size = if capacity < 1; 0 + elseif capacity == 1; 2 + elseif capacity == 2; 3 + elseif 3 <= capacity <= 5; 8 + else cld(capacity * 3, 2) end + slots = Memory{UInt8}(undef, size) + fill!(slots, 0x00) + Dict{K, V}(slots, + Memory{K}(undef, size), + Memory{V}(undef, size), + 0, 0, zero(UInt), max(1, size), 0) + end +else + function newdict(K::Type, V::Type, capacity::Int) + size = if capacity < 1; 1 + elseif capacity == 1; 2 + elseif 2 <= capacity <= 4; 8 + else cld(capacity * 3, 2) end + slots = Vector{UInt8}(undef, size) + fill!(slots, 0x00) + Dict{K, V}(slots, + Vector{K}(undef, size), + Vector{V}(undef, size), + 0, 0, zero(UInt), size, 0) + end +end + +""" + shrinkdict(dict::Dict) -> Dict + +If `dict` looks like it may be smaller if reconstructed using `newdict`, do so. +""" +function shrinkdict(dict::Dict{K, V}) where {K, V} + if length(dict) <= 6 + dnew = newdict(K, V, length(dict)) + for (k, v) in dict + dnew[k] = v + end + dnew + else + dict + end +end + """ natkeygen(key::String) diff --git a/Core/test/runtests.jl b/Core/test/runtests.jl index 1923ff0ce..228b42b3b 100644 --- a/Core/test/runtests.jl +++ b/Core/test/runtests.jl @@ -151,58 +151,6 @@ end deleteat!(PLUGINS, length(PLUGINS)) # remove `plg` end -import DataToolkitBase: smallify - -@testset "SmallDict" begin - @testset "Construction" begin - @test SmallDict() == SmallDict{Any, Any}([], []) - @test SmallDict{Any, Any}() == SmallDict{Any, Any}([], []) - @test SmallDict(:a => 1) == SmallDict{Symbol, Int}([:a], [1]) - @test SmallDict([:a => 1]) == SmallDict{Symbol, Int}([:a], [1]) - @test SmallDict{Symbol, Int}(:a => 1) == SmallDict{Symbol, Int}([:a], [1]) - @test_throws MethodError SmallDict{String, Int}(:a => 1) - @test SmallDict(:a => 1, :b => 2) == SmallDict{Symbol, Int}([:a, :b], [1, 2]) - @test SmallDict(:a => 1, :b => '1') == SmallDict{Symbol, Any}([:a, :b], [1, '1']) - @test SmallDict(:a => 1, "b" => '1') == SmallDict{Any, Any}([:a, "b"], [1, '1']) - end - @testset "Conversion" begin - @test convert(SmallDict, Dict(:a => 1)) == SmallDict{Symbol, Int}([:a], [1]) - @test convert(SmallDict, Dict{Symbol, Any}(:a => 1)) == SmallDict{Symbol, Any}([:a], [1]) - @test convert(SmallDict, Dict(:a => 1, :b => '1')) == SmallDict{Symbol, Any}([:a, :b], [1, '1']) - @test smallify(Dict(:a => Dict(:b => Dict(:c => 3)))) == - SmallDict(:a => SmallDict(:b => SmallDict(:c => 3))) - end - @testset "AbstractDict interface" begin - d = SmallDict{Symbol, Int}() - @test length(d) == 0 - @test haskey(d, :a) == false - @test get(d, :a, nothing) === nothing - @test iterate(d) === nothing - @test (d[:a] = 1) == 1 - @test d[:a] == 1 - @test collect(d) == [:a => 1] - @test length(d) == 1 - @test haskey(d, :a) == true - @test get(d, :a, nothing) == 1 - @test iterate(d) == (:a => 1, 2) - @test iterate(d, 2) === nothing - @test (d[:b] = 2) == 2 - @test length(d) == 2 - @test keys(d) == [:a, :b] - @test values(d) == [1, 2] - @test iterate(d, 2) === (:b => 2, 3) - @test Dict(d) == Dict(:a => 1, :b => 2) - @test (d[:a] = 3) == 3 - @test d[:a] == 3 - @test values(d) == [3, 2] - @test_throws KeyError d[:c] - delete!(d, :a) - @test keys(d) == [:b] - delete!(d, :b) - @test d == empty(d) - end -end - @testset "QualifiedType" begin @testset "Construction" begin @test QualifiedType(:a, :b) == QualifiedType(:a, :b, ()) @@ -283,10 +231,10 @@ end end end @testset "Identifiers" begin - for (istr, ident) in [("a", Identifier(nothing, "a", nothing, SmallDict{String, Any}())), - ("a:b", Identifier("a", "b", nothing, SmallDict{String, Any}())), - ("a::Main.sometype", Identifier(nothing, "a", QualifiedType(:Main, :sometype), SmallDict{String, Any}())), - ("a:b::Bool", Identifier("a", "b", QualifiedType(:Core, :Bool), SmallDict{String, Any}()))] + for (istr, ident) in [("a", Identifier(nothing, "a", nothing, Dict{String, Any}())), + ("a:b", Identifier("a", "b", nothing, Dict{String, Any}())), + ("a::Main.sometype", Identifier(nothing, "a", QualifiedType(:Main, :sometype), Dict{String, Any}())), + ("a:b::Bool", Identifier("a", "b", QualifiedType(:Core, :Bool), Dict{String, Any}()))] @test parse_ident(istr) == ident @test istr == string(ident) end @@ -332,12 +280,12 @@ end function getstorage(storage::DataStorage{:raw}, T::Type) get(storage, "value", nothing)::Union{T, Nothing} end - supportedtypes(::Type{DataStorage{:raw}}, spec::SmallDict{String, Any}) = + supportedtypes(::Type{DataStorage{:raw}}, spec::Dict{String, Any}) = [QualifiedType(typeof(get(spec, "value", nothing)))] function load(::DataLoader{:passthrough}, from::T, ::Type{T}) where {T <: Any} from end - supportedtypes(::Type{DataLoader{:passthrough}}, _::SmallDict{String, Any}, dataset::DataSet) = + supportedtypes(::Type{DataLoader{:passthrough}}, _::Dict{String, Any}, dataset::DataSet) = reduce(vcat, getproperty.(dataset.storage, :type)) |> unique end fieldeqn_parent_stack = [] @@ -436,7 +384,7 @@ end @test collection.uuid == Base.UUID("84068d44-24db-4e28-b693-58d2e1f59d05") @test collection.name == "datatest" @test collection.parameters == - SmallDict{String, Any}("setting" => 123, "nested" => SmallDict{String, Any}("value" => 4)) + Dict{String, Any}("setting" => 123, "nested" => Dict{String, Any}("value" => 4)) @test collection.plugins == String[] @test collection.path === nothing @test collection.mod == Main @@ -452,16 +400,16 @@ end @test dataset("dataset") isa DataSet @test dataset("dataset").name == "dataset" @test dataset("dataset").uuid == Base.UUID("d9826666-5049-4051-8d2e-fe306c20802c") - @test dataset("dataset").parameters == SmallDict{String, Any}("property" => 456) + @test dataset("dataset").parameters == Dict{String, Any}("property" => 456) end @testset "Store/Load" begin @test length(dataset("dataset").storage) == 1 @test dataset("dataset").storage[1].dataset === dataset("dataset") - @test dataset("dataset").storage[1].parameters == SmallDict{String, Any}("value" => [1, 2, 3]) + @test dataset("dataset").storage[1].parameters == Dict{String, Any}("value" => [1, 2, 3]) @test dataset("dataset").storage[1].type == [QualifiedType(Vector{Int})] @test length(dataset("dataset").loaders) == 1 @test dataset("dataset").loaders[1].dataset === dataset("dataset") - @test dataset("dataset").loaders[1].parameters == SmallDict{String, Any}() + @test dataset("dataset").loaders[1].parameters == Dict{String, Any}() @test dataset("dataset").loaders[1].type == [QualifiedType(Vector{Int})] @test open(dataset("dataset"), Vector{Int}) == [1, 2, 3] @test read(dataset("dataset"), Vector{Int}) == [1, 2, 3] @@ -483,9 +431,9 @@ end ((:uuid, :name), (Base.UUID("84068d44-24db-4e28-b693-58d2e1f59d05"), "dataset")), ((:name, :uuid), ("datatest", Base.UUID("d9826666-5049-4051-8d2e-fe306c20802c")))] ident = Identifier(dataset("dataset"), iargs...) - @test ident == Identifier(col, ds, nothing, SmallDict{String, Any}("property" => 456)) + @test ident == Identifier(col, ds, nothing, Dict{String, Any}("property" => 456)) @test dataset("dataset") === resolve(ident) - @test parse(Identifier, string(ident)) == Identifier(col, ds, nothing, SmallDict{String, Any}()) + @test parse(Identifier, string(ident)) == Identifier(col, ds, nothing, Dict{String, Any}()) end @test_throws ArgumentError Identifier(dataset("dataset"), :err) @test dataset("dataset") == dataset("dataset", "property" => 456) @@ -508,7 +456,7 @@ end @test config_get(collection, ["nested", "value"]) == 4 @test config_get(collection, ["nested", "nope"]) ===nothing @test config_set(["some", "nested", "val"], 5).parameters["some"] == - SmallDict{String, Any}("nested" => SmallDict{String, Any}("val" => 5)) + Dict{String, Any}("nested" => Dict{String, Any}("val" => 5)) @test config_get(["some", "nested", "val"]) == 5 @test get(config_unset(collection, ["some"]), "some") === nothing end