Kuzu Graph Database

repository·master·Indexed 26 days ago

https://github.com/kuzudb/kuzu

Kuzu is an embedded, serverless graph database optimized for complex analytical workloads. It features a Property Graph Data Model, Cypher query support, columnar disk-based storage, and native vector and full-text search capabilities. The system provides vectorized and factorized query processing with multi-core parallelism, serializable ACID transactions, and WebAssembly (Wasm) bindings for browser-based execution.

Tokens
14K
Snippets
32
Records
83
Agent score
86%

What's inside Kuzu

  1. Overview of yyjson features and limitations

    master

    yyjson is a high-performance JSON library written in ANSI C (C89) that complies with RFC 8259.

    Key Features

    • Fast: Capable of processing gigabytes of JSON per second.
    • Strict: Ensures strict number formats and UTF-8 validation.
    • Extendable: Supports custom memory allocators, comments, trailing commas, and NaN/Inf.
    • Manipulation: Supports JSON Pointer, JSON Patch, and JSON Merge Patch.
    • Accuracy: Accurate handling of int64, uint64, and double.

    Limitations

    • Access Speed: Arrays and objects are stored in structures like linked lists, making index/key access slower than using an iterator.
    • Duplicate Keys: Allows duplicate keys in objects and preserves their order.
    • Immutability: The parsing result is immutable; you must create a mutable copy to modify the data.
  2. Overview of Kuzu Graph Database

    master

    Kuzu is an embedded, serverless graph database designed for high-speed analytical workloads on large datasets. It uses a Property Graph Data Model and supports the Cypher query language.

    Key features include:

    • Columnar disk-based storage and CSR adjacency list/join indices.
    • Native full-text search (FTS) and vector indices.
    • Vectorized and factorized query processing with multi-core parallelism.
    • Serializable ACID transactions.
    • WebAssembly (Wasm) bindings for browser-based execution.
  3. Overview of kuzu-wasm asynchronous JavaScript API

    master

    The kuzu-wasm package provides a WebAssembly build of the Kuzu in-process property graph database management system.

    This specific documentation refers to the asynchronous JavaScript API. In this version, all function calls to the WebAssembly module are dispatched to a Web Worker (in the browser) or a Node.js worker thread. This design prevents blocking the main thread, which is critical for maintaining responsiveness in web applications.

    Note: Because data must be serialized and deserialized to pass between the main thread and worker threads, this asynchronous version may incur a slight performance overhead compared to synchronous execution.

  4. Choose between Async and Sync versions

    master

    Within each variant, you can choose between an Async or Sync version of the module. You cannot mix objects created from different versions.

    • Async (Default): Each function call returns a Promise. It dispatches calls to a Web Worker or Node.js worker thread to prevent blocking the main thread. Located at the root of each variant.
    • Sync: Synchronous calls that do not require callbacks. Recommended for scripting, CLI, or prototyping. Not recommended for GUI applications or web servers as it may block the main thread. Located in the sync/ directory of each variant.
  5. Use the Kuzu Java API

    master
    The Kuzu Java API is a Gradle-based project that provides a Java interface for interacting with the Kuzu platform. The build process is configured to automatically build the JNI (Java Native Interface) bindings and bundle them directly into the final JAR file.
  6. Understand the eKnows.csv dataset structure

    master

    The eKnows.csv dataset is designed to test various graph traversal and property list reading scenarios (small vs. large lists) using a many-to-many relationship between 6,000 person nodes (p).

    Node Connectivity Patterns

    • Node p0: Has a large forward adjacency list (5,000 edges) and a small backward adjacency list (1 edge, including a self-loop).
    • Node p5000: Has a large backward adjacency list and a small forward adjacency list (1 edge).
    • Nodes p1 to p4999: Have both small forward and small backward adjacency lists.
    • Nodes p5001 to p6000: Are singletons with no incoming or outgoing edges.

    Edge and Property Details

    • Edge Storage: Since there are fewer than 65,536 nodes, knows edges use 2 bytes per edge (0 bytes for label and 2 bytes for offset).
    • Property int64Prop: Edges contain an INT64 property named int64Prop.
      • For edges where the source is p0, the value is typically the ID of the destination node (e.g., edge 0->5 has int64Prop: 5).
      • Exceptions: The edges 0->0, 0->1000, 0->2000, 0->3000, 0->4000, and 0->5000 have null values for int64Prop.
      • Other edges in the graph have null for this property.
    • Testing Purpose: This structure is specifically intended to test both small and large property list reading performance.
  7. Choose the correct Kuzu-Wasm variant

    master

    Kuzu-Wasm provides three variants depending on your environment and performance needs. You cannot mix objects (like Database) created from different variants.

    VariantLocationDescription
    DefaultRoot levelSmallest size, no multi-threading, uses Emscripten filesystem. Works in Node.js and browsers. Best compatibility.
    Multi-threadedmultithreaded/Supports multi-threading, uses Emscripten filesystem. Requires cross-origin isolation in browsers.
    Node.jsnodejs/Optimized for Node.js, uses Node.js filesystem (NODEFS), supports multi-threading. Distributed as CommonJS. Only works in Node.js.
  8. Implementation details of the Kuzu WebAssembly In-Browser Example

    master
    The example is implemented using vanilla JavaScript and interacts with the Kuzu WebAssembly module via an asynchronous JavaScript API. The core logic and HTML structure are located in public/index.html. The project relies exclusively on kuzu-wasm and does not use other external dependencies.
  9. Run the Kuzu WebAssembly Node.js example

    master

    To run the demonstration of using the Kuzu WebAssembly build within a Node.js environment, follow these steps to install dependencies and execute the example script. This example utilizes the asynchronous JavaScript API to interact with the WebAssembly module.

    npm i
    npm start
  10. Install Brotli using vcpkg

    master

    You can use the vcpkg dependency manager to download and install Brotli. Follow these steps to clone vcpkg, bootstrap it, and install the brotli port:

    git clone https://github.com/Microsoft/vcpkg.git
    cd vcpkg
    ./bootstrap-vcpkg.sh
    ./vcpkg integrate install
    ./vcpkg install brotli
  11. Host your own extension server

    master

    If you need to install extensions not bundled in your Kuzu version, you can run a local extension server using Docker. The server is based on NGINX and uses images from ghcr.io/kuzudb/extension-repo.

    1. Pull and run the extension server image:
    docker pull ghcr.io/kuzudb/extension-repo:latest
    docker run -d -p 8080:80 ghcr.io/kuzudb/extension-repo:latest
    1. Install the extension from your local server using the FROM clause in Cypher:
    INSTALL <EXTENSION_NAME> FROM 'http://localhost:8080/';
  12. Run the Kuzu WebAssembly In-Browser Example

    master

    To run the Kuzu WebAssembly in-browser demonstration, follow these steps to install dependencies, bootstrap the WebAssembly module, and start the local development server.

    1. Install dependencies: Run npm i to install the necessary Node.js packages.
    2. Bootstrap the module: Run npm run bootstrap to copy the required WebAssembly module into the project structure.
    3. Start the server: Run npm run serve to launch the web server.
    4. Access the example: Open your browser and navigate to http://localhost:3000.
    npm i
    npm run bootstrap
    npm run serve