#parquet #local-storage #datafusion #database-table #apache-arrow #tsdb

bin+lib tsdb_timon

Efficient local storage and Amazon S3-compatible data synchronization for time-series data, leveraging Parquet for storage and DataFusion for querying, all wrapped in a simple and intuitive API

1 stable release

1.0.7 Oct 10, 2024
1.0.0 Oct 5, 2024

#1497 in Database interfaces

Download history 75/week @ 2024-10-03 552/week @ 2024-10-10 5/week @ 2024-10-17

111 downloads per month

Apache-2.0

80KB
1.5K SLoC

Timon File & S3-Compatible Storage API

This API provides a set of functions for managing databases and tables in both local file storage and S3-compatible storage. It supports creating databases and tables, inserting data, querying using SQL, and more.

Table of Contents

  1. File Storage Functions
  2. S3-Compatible Storage Functions
  3. Function Descriptions

File Storage Functions

These functions manage databases and tables stored locally on the file system. Data can be inserted, queried, and organized using SQL-like operations.

// Initialize Timon with a local storage path
external fun initTimon(storagePath: String): String

// Create a new database
external fun createDatabase(dbName: String): String

// Create a new table within a specific database
external fun createTable(dbName: String, tableName: String): String

// List all available databases
external fun listDatabases(): String

// List all tables within a specific database
external fun listTables(dbName: String): String

// Delete a specific database
external fun deleteDatabase(dbName: String): String

// Delete a specific table within a database
external fun deleteTable(dbName: String, tableName: String): String

// Insert data into a table in JSON format
external fun insert(dbName: String, tableName: String, jsonData: String): String

// Query a database with a date range and SQL query
external fun query(dbName: String, dateRange: Map<String, String>, sqlQuery: String): String

S3-Compatible Storage Functions

These functions manage data stored in an S3-compatible bucket, allowing for querying and saving monthly data as Parquet files.

// Initialize S3-compatible storage with endpoint and credentials
external fun initBucket(bucket_endpoint: String, bucket_name: String, access_key_id: String, secret_access_key: String): String

// Query the bucket with a date range and SQL query
external fun queryBucket(dateRange: Map<String, String>, sqlQuery: String): String

// Sink monthly data to Parquet format in the bucket
external fun sinkMonthlyParquet(dbName: String, tableName: String): String

Function Descriptions

  • initTimon(storagePath: String) Initializes the local file storage at the specified path.

  • createDatabase(dbName: String) Creates a new database with the specified name.

  • createTable(dbName: String, tableName: String) Creates a new table in the specified database.

  • listDatabases() Lists all databases in the local storage.

  • listTables(dbName: String) Lists all tables in the specified database.

  • deleteDatabase(dbName: String) Deletes the specified database.

  • deleteTable(dbName: String, tableName: String) Deletes the specified table from the given database.

  • insert(dbName: String, tableName: String, jsonData: String) Inserts JSON-formatted data into the specified table.

  • query(dbName: String, dateRange: Map<String, String>, sqlQuery: String) Executes an SQL query on the specified database within the given date range.

  • initBucket(bucket_endpoint: String, bucket_name: String, access_key_id: String, secret_access_key: String) Initializes an S3-compatible bucket for data storage.

  • queryBucket(dateRange: Map<String, String>, sqlQuery: String) Queries data in the S3 bucket based on the given date range and SQL query.

  • sinkMonthlyParquet(dbName: String, tableName: String) Upload data from the specified database and table as Parquet files, organized by month into S3-compatible bucket.

Dependencies

~68MB
~1.5M SLoC