Code Monkey home page Code Monkey logo

Comments (4)

weidinger-c avatar weidinger-c commented on June 16, 2024 1

Adding the line tiledb.default_ctx({"sm.dedup_coords": "true"}) now results in:

tiledb.cc.TileDBError: Global context already initialized!

Just read, that this function needs be called before any other tiledb function calls, although I was only deleting the old array with:

if tiledb.object_type(tiledb_array_name) == "array":
        tiledb.remove(tiledb_array_name)

from tiledb-py.

ihnorton avatar ihnorton commented on June 16, 2024

Hi @weidinger-c,

  1. The coordinate uniqueness requirement for a given array is controlled at the schema level by the allows_duplicates parameter to ArraySchema. (note: only applicable to sparse arrays)
  2. The sm.dedup_coords setting is a runtime config option. Here's a demo for how to change it.
import tiledb, numpy as np, tempfile

tiledb.default_ctx({"sm.dedup_coords": "true"})

dims = []
dims.append(tiledb.Dim('X', (0, 1023), 1024, dtype=np.uint32))
attr = tiledb.Attr(name='', dtype=np.uint8)
schema = tiledb.ArraySchema(domain=tiledb.Domain(*dims), attrs=[attr], sparse=True)

uri = tempfile.mkdtemp()
tiledb.Array.create(uri, schema)

with tiledb.open(uri, "w") as A:
    A[np.array([1,2,1])] = np.array([1,2,3])

with tiledb.open(uri) as B:
    print(B[:])

Addiditionally I did not find any possibilty to get/print the current config that is used for a tiledb array.

Config options only control runtime behavior, and - there are defaults set for all calls unless you override. Configuration options are applied to a "Context", which can be controlled with:

  1. tiledb.default_ctx - can be called once at process start, before any other tiledb calls. Will apply to all calls in the process, except those within a scope_ctx block.
  2. tiledb.scope_ctx - can be called (or nested) via a with block, and will apply the context to all calls inside the block. Here's a demo:
import tiledb, numpy as np, tempfile

dims = []
dims.append(tiledb.Dim('X', (0, 1023), 1024, dtype=np.uint32))
attr = tiledb.Attr(name='', dtype=np.uint8)
schema = tiledb.ArraySchema(domain=tiledb.Domain(*dims), attrs=[attr], sparse=True)

uri = tempfile.mkdtemp()
tiledb.Array.create(uri, schema)

# creates a new context with config applied
with tiledb.scope_ctx(tiledb.Ctx({"sm.dedup_coords": "true"})):
    with tiledb.open(uri, "w") as A:
        A[np.array([1,2,1])] = np.array([1,2,3])

with tiledb.open(uri) as B:
    print(B[:])

from tiledb-py.

weidinger-c avatar weidinger-c commented on June 16, 2024

Adding the line tiledb.default_ctx({"sm.dedup_coords": "true"}) now results in:

tiledb.cc.TileDBError: Global context already initialized!

from tiledb-py.

weidinger-c avatar weidinger-c commented on June 16, 2024

I was now able to write the points into the database, but unfortunately now when reading points, the process just exits. I will create a separate issue for this.

from tiledb-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.