Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
ctx = tiledb.Ctx()
# Create dimensions
d1 = tiledb.Dim(ctx, "d1", domain=(1, 4), tile=2, dtype="uint64")
d2 = tiledb.Dim(ctx, "d2", domain=(1, 4), tile=2, dtype="uint64")
# Create domain
domain = tiledb.Domain(ctx, d1, d2)
# Create attributes
a1 = tiledb.Attr(ctx, "a1", compressor=('blosc-lz', -1), dtype="int32")
a2 = tiledb.Attr(ctx, "a2", compressor=("gzip", -1), dtype="S4")
a3 = tiledb.Attr(ctx, "a3", compressor=('zstd', -1), dtype='float32,float32')
# Create dense array
tiledb.DenseArray(ctx, "my_dense_array",
domain=domain,
attrs=(a1, a2, a3),
cell_order='row-major',
tile_order='row-major')
def create_array():
# The array will be 4x4 with dimensions "rows" and "cols", with domain [1,4].
dom = tiledb.Domain(tiledb.Dim(name="rows", domain=(1, 4), tile=2, dtype=np.int32),
tiledb.Dim(name="cols", domain=(1, 4), tile=2, dtype=np.int32))
# The array will be dense with a single attribute "a" so each (i,j) cell can store an integer.
schema = tiledb.ArraySchema(domain=dom, sparse=False,
attrs=[tiledb.Attr(name="a", dtype=np.int32)])
# Create the (empty) array on disk.
tiledb.DenseArray.create(array_name, schema)
def main():
ctx = tiledb.Ctx()
# Create dimensions
d1 = tiledb.Dim(ctx, "d1", domain=(1, 4), tile=2, dtype="uint64")
d2 = tiledb.Dim(ctx, "d2", domain=(1, 4), tile=2, dtype="uint64")
# Create domain
domain = tiledb.Domain(ctx, d1, d2)
# Create attributes
a1 = tiledb.Attr(ctx, "a1", compressor=('blosc-lz', -1), dtype="int32")
a2 = tiledb.Attr(ctx, "a2", compressor=("gzip", -1), dtype="S4")
a3 = tiledb.Attr(ctx, "a3", compressor=('zstd', -1), dtype='float32,float32')
# Create dense array
tiledb.DenseArray(ctx, "my_dense_array",
domain=domain,
attrs=(a1, a2, a3),
cell_order='row-major',
tile_order='row-major')
def create_array():
# The array will be 4x4 with dimensions "rows" and "cols", with domain [1,4] and space tiles 2x2.
dom = tiledb.Domain(tiledb.Dim(name="rows", domain=(1, 4), tile=2, dtype=np.int32),
tiledb.Dim(name="cols", domain=(1, 4), tile=2, dtype=np.int32))
# The array will be dense with a single attribute "a" so each (i,j) cell can store an integer.
schema = tiledb.ArraySchema(domain=dom, sparse=False,
attrs=[tiledb.Attr(name="a", dtype=np.int32)])
# Create the (empty) array on disk.
tiledb.DenseArray.create(array_name, schema)
def main():
# Create TileDB context
ctx = tiledb.Ctx()
# KV objects are limited to storing string keys/values for the time being
a1 = tiledb.Attr(ctx, "value", compressor=("gzip", -1), dtype=bytes)
kv = tiledb.KV(ctx, "my_kv", attrs=(a1,))
# Dump the KV schema
kv.dump()
# Update the KV with some key-value pairs
vals = {"key1": "a", "key2": "bb", "key3": "dddd"}
print("Updating KV with values: {!r}\n".format(vals))
kv.update(vals)
# Get kv item
print("KV value for 'key3': {}\n".format(kv['key3']))
try:
kv["don't exist"]
except KeyError:
def create_array():
# The array will be 4x4 with dimensions "rows" and "cols", with domain [1,4].
dom = tiledb.Domain(tiledb.Dim(name="rows", domain=(1, 4), tile=2, dtype=np.int32),
tiledb.Dim(name="cols", domain=(1, 4), tile=2, dtype=np.int32))
# The array will be sparse with a single attribute "a" so each (i,j) cell can store an integer.
schema = tiledb.ArraySchema(domain=dom, sparse=True,
attrs=[tiledb.Attr(name="a", dtype=np.int32)])
# Create the (empty) array on disk.
tiledb.SparseArray.create(array_name, schema)
def create_array():
# The KV array will have a single attribute "a" storing a string.
schema = tiledb.KVSchema(attrs=[tiledb.Attr(name="a", dtype=bytes)])
# Create the (empty) array on disk.
tiledb.KV.create(kv_name, schema)
def create_array():
ctx = tiledb.Ctx()
dom = tiledb.Domain(tiledb.Dim(name="rows", domain=(1, 4), tile=4, dtype=np.int64),
tiledb.Dim(name="cols", domain=(1, 4), tile=4, dtype=np.int64),
ctx=ctx)
attrs = [
tiledb.Attr(name="a1", var=True, dtype='U', ctx=ctx),
tiledb.Attr(name="a2", var=True, dtype=np.int64, ctx=ctx)
]
schema = tiledb.ArraySchema(domain=dom, sparse=False,
attrs=attrs,
ctx=ctx)
tiledb.Array.create(array_name, schema, ctx=ctx)
return schema