If you’re starting your journey into the world of multi-dimensional arrays, start with this Quickstart guide.
How to run this tutorial
You can run this tutorial in two ways:
Locally on your machine.
On TileDB Cloud.
However, since TileDB Cloud has a free tier, we strongly recommend that you sign up and run everything there, as that requires no installations or deployment.
This section explains how to get started quickly on your local machine or TileDB Cloud. It also covers two basic examples, one on dense arrays and one on sparse arrays. Do not worry at all if some concepts feel foreign to you. You will uncover all the array secrets and make you a power user as you go through the Foundation and Tutorials sections.
Getting started
Local installation
You can choose your preferred API to install from the tabs below. Although these tutorials are in multiple languages, Python is the most common one and the easiest to start with. You can always visit the API Reference section for the detailed usage of all supported language APIs.
Use the TileDB.CSharp NuGet package to create a .NET console application with the .NET CLI. The TileDB NuGet package is currently compatible with .NET 5 and later.
# Create a new .NET solutiondotnet new sln -o TileDB-Projectcd TileDB-Project# Create a new console project using .NET CLIdotnet new console -o ConsoleAppdotnet sln add ConsoleApp/ConsoleApp.csproj# Add TileDB.CSharp NuGet package to the projectdotnet add ConsoleApp/ConsoleApp.csproj package TileDB.CSharp
After running the commands above, TileDB-Project/ConsoleApp/ConsoleApp.csproj will have the following configuration, providing access to the TileDB-CSharp API in the project:
Warning
You must declare a runtime identifier (RID). Otherwise, the native TileDB Embedded binaries will not be imported, and the app might fail at runtime.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings><!-- The following RID corresponds to a 64-bit Windows installation: --> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <PackageReference Include="TileDB.CSharp" Version="5.8.0" /> </ItemGroup></Project>
To test your project, edit TileDB-Project/ConsoleApp/Program.cs and obtain the version of TileDB core currently in use by TileDB.CSharp. For more examples using the C# API, see the TileDB-Inc/TileDB-CSharp repository on GitHub.
using System;using TileDB.CSharp;namespace TileDB_Project{class Program{staticvoidMain(string[] args){var version = CoreUtil.GetCoreLibVersion(); Console.WriteLine($"TileDB Core version: {version}");// TileDB Core version: 2.17.0}}}
# Go Getgo get -v github.com/TileDB-Inc/TileDB-Go@v0.23.3# Go modulesgo mod init github.com/<github_username>/<repository_name>
Here is a sample go.mod file:
module github.com/<github_username>/<repository_name>
go 1.25.1
require (
github.com/TileDB-Inc/TileDB-Go v0.23.3
)
docker pull tiledb/tiledbdocker run -it tiledb/tiledb
TileDB Cloud
Sign up to the free tier of TileDB Cloud and follow the instructions in the Get Started section, where you will learn how to set up your account.
Dense array quickstart
In this tutorial, you will learn how to create, write, and read a small dense array on your local disk.
# Create the two dimensionsd1 = tiledb.Dim(name="d1", domain=(1, 4), tile=2, dtype=np.int32)d2 = tiledb.Dim(name="d2", domain=(1, 4), tile=2, dtype=np.int32)# Create a domain using the two dimensionsdom = tiledb.Domain(d1, d2)# Create an integer attributea = tiledb.Attr(name="a", dtype=np.int32)# Create the array schema, setting `sparse=False` to indicate a dense arrayschema = tiledb.ArraySchema(domain=dom, sparse=False, attrs=[a])# Create the array on disk (it will initially be empty)tiledb.Array.create(dense_array, schema)
# Create the two dimensionsd1 <-tiledb_dim("d1", c(1L, 4L), 2L, "INT32")d2 <-tiledb_dim("d2", c(1L, 4L), 2L, "INT32")# Create a domain using the two dimensionsdom <-tiledb_domain(dims =c(d1, d2))# Create an attributea <-tiledb_attr("a", type ="INT32")# Create the array schema, setting `sparse = FALSE` to indicate a dense arraysch <-tiledb_array_schema(dom, a, sparse =FALSE)# Create the array on disk (it will initially be empty)arr <-tiledb_array_create(dense_array, sch)
This creates an array folder on your local storage, at the path you specified in dense_array above. The array does not contain any data yet.
# Prepare some data in a numpy arraydata = np.array( [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], dtype=np.int32)# Open the array in write mode and write to the whole array domainwith tiledb.open(dense_array, "w") as A: A[:] = data
# Prepare some data in an arraydata <-t(array(1:16, dim =c(4, 4)))# Open the array for writing and write data to the arrayarr <-tiledb_array(uri = dense_array, query_type ="WRITE", return_as ="data.frame")arr[] <- data# Close the arrayarr <-tiledb_array_close(arr)
# Create the two dimensionsd1 = tiledb.Dim(name="d1", domain=(0, 3), tile=2, dtype=np.int32)d2 = tiledb.Dim(name="d2", domain=(0, 3), tile=2, dtype=np.int32)# Create a domain using the two dimensionsdom = tiledb.Domain(d1, d2)# Create an integer attributea = tiledb.Attr(name="a", dtype=np.int32)# Create the array schema, setting `sparse=True` to indicate a sparse arrayschema = tiledb.ArraySchema(domain=dom, sparse=True, attrs=[a])# Create the array on disk (it will initially be empty)tiledb.Array.create(sparse_array, schema)
# Create the two dimensionsd1 <-tiledb_dim("d1", c(0L, 3L), 2L, "INT32")d2 <-tiledb_dim("d2", c(0L, 3L), 2L, "INT32")# Create a domain using the two dimensionsdom <-tiledb_domain(dims =c(d1, d2))# Create an attributea <-tiledb_attr("a", type ="INT32")# Create the array schema with `sparse = TRUE`sch <-tiledb_array_schema(dom, a, sparse =TRUE)# Create the array on disk (it will initially be empty)arr <-tiledb_array_create(sparse_array, sch)
This creates an array folder on your local storage, at the path you specified in sparse_array above. The array does not contain any data yet.
# Prepare some data in numpy arrays, simulating the COO formatd1_data = np.array([2, 0, 3, 2, 0, 1], dtype=np.int32)d2_data = np.array([0, 1, 1, 2, 3, 3], dtype=np.int32)a_data = np.array([4, 1, 6, 5, 2, 3], dtype=np.int32)# Open the array in write mode and write the datawith tiledb.open(sparse_array, "w") as A: A[d1_data, d2_data] = a_data
# Prepare some data in an arrayd1_data <-c(2L, 0L, 3L, 2L, 0L, 1L)d2_data <-c(0L, 1L, 1L, 2L, 3L, 3L)a_data <-c(4L, 1L, 6L, 5L, 2L, 3L)# Open the array for writing and write data to the arrayarr <-tiledb_array(uri = sparse_array, query_type ="WRITE", return_as ="data.frame")arr[d1_data, d2_data] <- a_data# Close the arrayinvisible(tiledb_array_close(arr))