remove duplicated export
parent
bad6390430
commit
4f72af430d
|
@ -5,7 +5,6 @@ export Action, Transaction,
|
|||
write, restore, replay,
|
||||
DataBase, DataBaseTable, Table,
|
||||
ArrayTable, MappedTable
|
||||
export Table
|
||||
|
||||
using MsgPack
|
||||
|
||||
|
|
|
@ -41,17 +41,17 @@ struct DataBase
|
|||
size
|
||||
end
|
||||
|
||||
DataBaseTable(table::Table, path) =
|
||||
DataBaseTable(table, Memory(table, path))
|
||||
DataBaseTable(table::Table, path; verbose = false) =
|
||||
DataBaseTable(table, Memory(table, path, verbose = verbose))
|
||||
|
||||
const defaultSchema = Table("schema", MappedTable,
|
||||
# Key, Value (File), Value (Memory)
|
||||
[Symbol, Table], UInt32)
|
||||
|
||||
function DataBase(dir; S = UInt32)
|
||||
function DataBase(dir; S = UInt32, verbose = false)
|
||||
dir = ispath(dir) ? realpath(dir) : mkpath(dir)
|
||||
isfile(dir) && throw(ArgumentError("path ($dir) is a file"))
|
||||
tables = DataBaseTable(defaultSchema, dir)
|
||||
tables = DataBaseTable(defaultSchema, dir, verbose = verbose)
|
||||
tbldata = Dict{Table,DataBaseTable}()
|
||||
for (idx,tbl) in tables.memory.data
|
||||
tbldata[tbl] = DataBaseTable(tbl, dir)
|
||||
|
@ -85,8 +85,8 @@ function Base.getindex(db::DataBase, name::Symbol)
|
|||
db.memory[db.schema.memory.data[name]]
|
||||
end
|
||||
|
||||
function Base.setindex!(db::DataBase, table::Table, name::Symbol)
|
||||
dbtable = DataBaseTable(table, Memory(table, db.path))
|
||||
function Base.setindex!(db::DataBase, table::Table, name::Symbol; verbose = false)
|
||||
dbtable = DataBaseTable(table, Memory(table, db.path, verbose = verbose))
|
||||
# File
|
||||
action = haskey(db.schema.memory.data, name) ? modify : create
|
||||
write(db.schema.memory.io, Action(action, (name,table)), S = db.size)
|
||||
|
@ -207,7 +207,7 @@ function replay(actions::Vector{Action{T}}) where T
|
|||
state
|
||||
end
|
||||
|
||||
function Memory(table::Table, path)::Memory
|
||||
function Memory(table::Table, path; verbose = false)::Memory
|
||||
vname(version) = joinpath(path, string(table.name, version, DBExt))
|
||||
rx = Regex("$(table.name)([0-9]+)$(DBExt)")
|
||||
files = filter!(!isnothing, map(x -> match(rx, x), readdir(path)))
|
||||
|
@ -215,7 +215,7 @@ function Memory(table::Table, path)::Memory
|
|||
exists = length(matches) > 0
|
||||
version = exists ? maximum(matches) : 0
|
||||
fname = vname(version)
|
||||
@info(exists ? "Loading table from $(fname)" :
|
||||
verbose && @info(exists ? "Loading table from $(fname)" :
|
||||
"Creating new table in $(fname)")
|
||||
if table.Type == ArrayTable
|
||||
data = if exists
|
||||
|
|
Loading…
Reference in New Issue