MCPcopy Index your code
hub / github.com/arcesium/swiftlake

github.com/arcesium/swiftlake @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
2,955 symbols 15,386 edges 193 files 904 documented · 31%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SwiftLake

Build Status Maven Central JavaDoc License

Overview

SwiftLake is a Java library that bridges the gap between traditional SQL databases and cloud-native data lakes. By combining Apache Iceberg and DuckDB, it provides a lightweight, single-node solution that delivers SQL familiarity with cloud storage benefits, without the complexity of distributed systems.

Key Features and Benefits

  • Query and Manage Cloud Storage: SwiftLake brings familiar SQL queries and data management capabilities to object storage-based data lakes, providing a comfortable transition path for teams with RDBMS experience.

  • Efficient Data Operations: Leveraging DuckDB's columnar processing and Iceberg's transaction management, SwiftLake delivers fast data operations for ingestion, querying, and complex transformations.

  • Flexible Deployment: SwiftLake operates as a single-process application that connects DuckDB's lightweight engine with cloud storage, eliminating the need for distributed infrastructure for moderate workloads.

  • Core Data Lake Capabilities: SwiftLake provides CRUD operations, SCD support, schema evolution, and time travel functionality on cloud storage.

  • Cloud Economics: By using object storage for data and running compute only when needed, SwiftLake offers significant cost advantages over traditional database scaling approaches.

When to Use SwiftLake

SwiftLake is ideal for: - Organizations wanting SQL database familiarity with cloud storage economics - Teams needing schema evolution, time travel, or SCD merge capabilities - Scenarios where distributed processing frameworks would be overkill

By providing a middle ground between traditional databases and complex distributed systems, SwiftLake enables teams to modernize their data architecture with minimal disruption and maximal flexibility.

SwiftLake Capabilities and Constraints

Core Functionalities

  • Comprehensive Data Management:
  • Execute queries
  • Perform write operations: insert, delete, update
  • Implement Slowly Changing Dimensions (SCD):

    • Type 1 merge
    • Type 2 merge
  • Dynamic Schema Evolution:

  • Add, drop, rename, and reorder columns
  • Widen column types

  • Advanced Partitioning Strategies:

  • Enhance query performance through intelligent data grouping
  • Support for multiple partition transforms:
    • Identity, bucket, truncate
    • Time-based: year, month, day, hour
  • Hidden partitioning capability
  • Partition evolution without data rewrite

Performance Optimizations

  • Efficient Caching: Optimize data access and query performance
  • MyBatis Integration: Seamless interaction with MyBatis framework

Current System Boundaries

  • File Format Compatibility: Currently supports only Parquet format
  • Table Management Mode:
  • Implements Copy-On-Write mode exclusively
  • Merge-On-Read not supported
  • Metadata Handling:
  • Querying metadata tables not supported within SwiftLake
  • Snapshot and metadata management requires external engines (e.g., Spark)
  • Partitioning Limitation: Cannot partition on columns from nested structs

Note: For operations like data compaction, expiring snapshots, and deleting orphan files, use compatible external engines such as Apache Spark.

Getting Started

Including SwiftLake Dependency

To use SwiftLake in your project, add the following dependency to your build file:

Maven

Add this to your pom.xml:

<dependency>
    <groupId>com.arcesium.swiftlake</groupId>
    <artifactId>swiftlake-core</artifactId>
    <version>0.2.0</version>
</dependency>

Gradle

Add this to your build.gradle:

implementation 'com.arcesium.swiftlake:swiftlake-core:0.2.0'

Setup

  1. Configure and create a Catalog:
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.CatalogUtil;
import org.apache.iceberg.catalog.Catalog;

Map<String, String> properties = new HashMap<>();
properties.put("warehouse", "warehouse");
properties.put("type", "hadoop");
properties.put("io-impl", "com.arcesium.swiftlake.io.SwiftLakeHadoopFileIO");
Catalog catalog = CatalogUtil.buildIcebergCatalog("local", properties, new Configuration());
  1. Build SwiftLakeEngine:
import com.arcesium.swiftlake.SwiftLakeEngine;

SwiftLakeEngine swiftLakeEngine = SwiftLakeEngine.builderFor("demo").catalog(catalog).build();

Creating a Table

  1. Define the schema:
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
import org.apache.iceberg.types.Types;

Schema schema = new Schema(
    Types.NestedField.required(1, "id", Types.LongType.get()),
    Types.NestedField.required(2, "data", Types.StringType.get()),
    Types.NestedField.required(3, "category", Types.StringType.get()),
    Types.NestedField.required(4, "date", Types.DateType.get())
);
PartitionSpec spec = PartitionSpec.builderFor(schema)
    .identity("date")
    .identity("category")
    .build();
  1. Create the table:
import org.apache.iceberg.Table;
import org.apache.iceberg.catalog.TableIdentifier;

TableIdentifier name = TableIdentifier.of("db", "table");
Table table = catalog.createTable(name, schema, spec);

Inserting Data

Use SQL to insert data:

swiftLakeEngine.insertInto(table)
   .sql("SELECT * FROM (VALUES (1, 'a', 'category1', DATE'2025-01-01'), (2, 'b', 'category2', DATE'2025-01-01'), (3, 'c', 'category3', DATE'2025-03-01')) source(id, data, category, date)")
   .execute();

Querying Data

Execute SQL queries using a JDBC-like interface:

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

DataSource dataSource = swiftLakeEngine.createDataSource();
String selectSql = "SELECT * FROM db.table WHERE id = 2";
try (Connection connection = dataSource.getConnection();
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(selectSql)) {
   // Process the resultSet
}

You can also perform aggregations:

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

DataSource dataSource = swiftLakeEngine.createDataSource();
String aggregateSql = "SELECT count(1) as count, data FROM db.table WHERE id > 0 GROUP BY data;";
try (Connection connection = dataSource.getConnection();
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(aggregateSql)) {
   // Process the resultSet
}

AWS Integration

S3 Integration

To use SwiftLake with Amazon S3, you need to configure the S3 file system:

  1. Add the below dependency:
Maven
<dependency>
    <groupId>com.arcesium.swiftlake</groupId>
    <artifactId>swiftlake-aws</artifactId>
    <version>0.2.0</version>
</dependency>
Gradle
implementation 'com.arcesium.swiftlake:swiftlake-aws:0.2.0'
  1. Configure S3 in your SwiftLake setup:
Map<String, String> properties = new HashMap<>();
properties.put("warehouse", "s3://your-bucket-name/warehouse");
properties.put("io-impl", "com.arcesium.swiftlake.aws.SwiftLakeS3FileIO");
properties.put("client.region", "your-aws-region");
properties.put("s3.access-key-id", "YOUR_ACCESS_KEY");
properties.put("s3.secret-access-key", "YOUR_SECRET_KEY");

AWS Glue Catalog Integration

To use SwiftLake with AWS Glue Catalog:

Configure Glue Catalog in your SwiftLake setup:

Map<String, String> properties = new HashMap<>();
properties.put("warehouse", "s3://your-bucket-name/warehouse");
properties.put("io-impl", "com.arcesium.swiftlake.aws.SwiftLakeS3FileIO");
properties.put("client.region", "your-aws-region");
properties.put("s3.access-key-id", "YOUR_ACCESS_KEY");
properties.put("s3.secret-access-key", "YOUR_SECRET_KEY");
properties.put("type", "glue");

Catalog catalog = CatalogUtil.buildIcebergCatalog("glue", properties, new Configuration());
SwiftLakeEngine swiftLakeEngine = SwiftLakeEngine.builderFor("demo").catalog(catalog).build();

// Create table, insert data, and query 

Configuration

SwiftLakeEngine Configuration

Name Default Description
localDir A unique directory under the system's temporary directory Local storage where to write temp files.
memoryLimitInMiB 90% of memory available outside the JVM heap, expressed in MiB Maximum memory of the DuckDB instance
memoryLimitFraction - Fraction of total memory used for DuckDB instance.
threads Number of available processor cores The number of total threads used by the DuckDB instance
tempStorageLimitInMiB - Maximum amount of disk space DuckDB can use for temporary storage
maxPartitionWriterThreads Same as threads The number of total (Java) threads used in writing data to multiple partitions.
totalFileSizePerScanLimitInMiB - Maximum total file size (in MiB) of matched files allowed per table scan. Prevents excessive data processing after the scan.
maxActiveConnections - Maximum number of active connections allowed
connectionCreationTimeoutInSeconds - Timeout (in seconds) for creating new connections, applicable only when maxActiveConnections is set. Ensures that connection attempts don't hang indefinitely when connection limits are enforced.
queryTimeoutInSeconds - Timeout (in seconds) for queries. Prevents long-running queries from impacting system performance.
processTablesDefaultValue true Sets the default value for processing tables used in the queries.
allowFullTableScan false Enables or disables full table scans.
configureDuckDBExtensions - Configures DuckDB extensions with the below options
    allowUnsignedExtensions false Allows the use of unsigned extensions
    allowCommunityExtensions false Allows the use of community provided extensions
    autoInstallKnownExtensions false Automatically installs and loads known extensions
lockDuckDBConfiguration true Locks DuckDB configuration to prevent modifications. Ensures configuration integrity and security.
cachingCatalog - Whether to cache Iceberg catalog entries (tables). This needs to be used carefully. Tables do not get refreshed until they are evicted from cache. It leads to reading stale data if there are commits after it is cached. Use this when reading stale data is acceptable for certain amount of time.
    namespaces - List of namespaces/databases that are considered for caching.
    fullyQualifiedTableNames - List of fully qualified table names that are considered for caching.
    expirationIntervalInSeconds - How long table entries are locally cached, in seconds.
metricCollector - An implementation of the MetricCollector interface, responsible for collecting and posting metrics during operations.
mybatisConfigPath - Classpath resource pointing to MyBatis XML configuration file. It is needed for the MyBatis integration.
enableDebugFileUpload false Enables or disables uploading intermediate files generated using write operations. Useful for troubleshooting and debugging purposes
    uploadPath

Extension points exported contracts — how you extend this code

DataFileWriter (Interface)
Interface for writing data files in SwiftLake. Implementations of this interface are responsible for writing data to fil [6 …
core/src/main/java/com/arcesium/swiftlake/writer/DataFileWriter.java
S3TransferManagerProvider (Interface)
Provides an interface for obtaining an S3TransferManager instance. [5 implementers]
aws/src/main/java/com/arcesium/swiftlake/aws/S3TransferManagerProvider.java
InputFile (Interface)
The InputFile interface represents a file input for processing. It provides methods to retrieve information about the fi [6 …
core/src/main/java/com/arcesium/swiftlake/common/InputFile.java
InputFiles (Interface)
The InputFiles interface represents a collection of InputFile objects. It extends AutoCloseable to ensure proper resourc [7 …
core/src/main/java/com/arcesium/swiftlake/common/InputFiles.java
MetricCollectorProvider (Interface)
An interface for providing metric collectors. [5 implementers]
core/src/main/java/com/arcesium/swiftlake/metrics/MetricCollectorProvider.java
Expression (Interface)
Marker interface for all expression types in the SwiftLake system. [5 implementers]
core/src/main/java/com/arcesium/swiftlake/expressions/Expression.java

Core symbols most depended-on inside this repo

of
called by 2482
core/src/main/java/com/arcesium/swiftlake/common/DataColumnAccessor.java
get
called by 1408
core/src/main/java/com/arcesium/swiftlake/io/ContentCache.java
add
called by 338
core/src/main/java/com/arcesium/swiftlake/writer/TableBatchTransaction.java
toString
called by 273
core/src/main/java/com/arcesium/swiftlake/common/DataFile.java
execute
called by 263
core/src/main/java/com/arcesium/swiftlake/commands/SCD2Merge.java
processSourceTables
called by 195
core/src/main/java/com/arcesium/swiftlake/commands/SCD2Merge.java
build
called by 176
core/src/main/java/com/arcesium/swiftlake/writer/Transaction.java
getTable
called by 169
core/src/main/java/com/arcesium/swiftlake/sql/TableFilter.java

Shape

Method 2,676
Class 235
Interface 42
Enum 2

Languages

Java100%

Modules by API surface

core/src/main/java/com/arcesium/swiftlake/commands/SCD2Merge.java122 symbols
core/src/test/java/com/arcesium/swiftlake/sql/SwiftLakePreparedStatementTest.java96 symbols
core/src/main/java/com/arcesium/swiftlake/commands/SCD1Merge.java92 symbols
core/src/main/java/com/arcesium/swiftlake/sql/SwiftLakePreparedStatement.java79 symbols
core/src/main/java/com/arcesium/swiftlake/commands/SCD2MergeProperties.java71 symbols
core/src/main/java/com/arcesium/swiftlake/SwiftLakeEngine.java71 symbols
core/src/main/java/com/arcesium/swiftlake/commands/SCD1MergeProperties.java59 symbols
core/src/main/java/com/arcesium/swiftlake/common/SwiftLakeConfiguration.java49 symbols
core/src/main/java/com/arcesium/swiftlake/sql/SwiftLakeConnection.java46 symbols
core/src/test/java/com/arcesium/swiftlake/commands/SCD1MergeBasicIntegrationTest.java41 symbols
core/src/main/java/com/arcesium/swiftlake/commands/Insert.java41 symbols
core/src/test/java/com/arcesium/swiftlake/sql/SchemaEvolutionTest.java40 symbols

For agents

$ claude mcp add swiftlake \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page