Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting flags #24

Open
mcmahanp opened this issue Mar 18, 2020 · 3 comments
Open

Setting flags #24

mcmahanp opened this issue Mar 18, 2020 · 3 comments

Comments

@mcmahanp
Copy link

mcmahanp commented Mar 18, 2020

I am trying to set the read-only flag on an environment, but the following code

env = create()
setindex!(env,0x20000,:Flags)

throws

ERROR: UndefVarError: warn not defined
Stacktrace:
 [1] setindex!(::Environment, ::UInt32, ::Symbol) at .julia/packages/LMDB/MBmCS/src/env.jl:123
 [2] top-level scope at REPL[131]:1

The other approach I tried was set!(env,0x20000), which throws

ERROR: Code[22]: Invalid argument
Stacktrace:
 [1] set!(::Environment, ::UInt32) at .julia/packages/LMDB/MBmCS/src/env.jl:87
 [2] top-level scope at REPL[144]:1

I'm brand new to Julia, so I'm not sure how to go about debugging this.

(using julia version 1.3.1)

@wildart
Copy link
Owner

wildart commented Mar 19, 2020

Error message throws error. 💩. Thanks for reporting.

You cannot use :Flags symbol for setting up properties of the environment.
Only :Readers , :MapSize & :DB properties are available.

LMDB.jl/src/env.jl

Lines 114 to 127 in 637a483

function setindex!(env::Environment, val::Cuint, option::Symbol)
ret = zero(Cint)
if option == :Readers
ret = ccall( (:mdb_env_set_maxreaders, liblmdb), Cint, (Ptr{Nothing}, Cuint), env.handle, val)
elseif option == :MapSize
ret = ccall( (:mdb_env_set_mapsize, liblmdb), Cint, (Ptr{Nothing}, Cuint), env.handle, val)
elseif option == :DBs
ret = ccall( (:mdb_env_set_maxdbs, liblmdb), Cint, (Ptr{Nothing}, Cuint), env.handle, val)
else
warn("Cannot set $(string(option)) value")
end
(ret != 0) && throw(LMDBError(ret))
return ret
end

@mcmahanp
Copy link
Author

mcmahanp commented Mar 19, 2020

Thanks for the reply. I was working off of the doc string, which I think suggests you can use :Flags:

LMDB.jl/src/env.jl

Lines 103 to 112 in 637a483

`setindex!` accepts folowing parameters:
* `env` db environment object
* `option` symbol which indicates parameter. Currently supported parameters:
* Flags
* Readers
* MapSize
* DBs
* `value` parameter value
**Note:** Consult LMDB documentation for particual values of environment parameters and flags.

Is there any way to set the LMDB flags for an environment? I need both the RDONLY flag and the NORDAHEAD flag for my project.

@mcmahanp
Copy link
Author

Quick followup:

I was able to set the environment flags by passing a flags argument to open() rather than setting them directly on the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants