Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ jobs:

build-java:
if: ${{ github.event_name == 'schedule' || github.event.inputs.skipJava != 'true' }}
needs: [build-precompiled-bin]
uses: ./.github/workflows/java-workflow.yml
with:
isNightly: ${{ github.event_name == 'schedule' || github.event.inputs.isNightly == 'true' }}
precompiledRunId: ${{ github.run_id }}
secrets: inherit

deploy-java:
Expand Down Expand Up @@ -264,7 +266,17 @@ jobs:
- name: Create Java JAR
working-directory: tools/java_api
run: |
./gradlew build
./gradlew build --stacktrace --info --warning-mode all --no-parallel --max-workers=1

- name: Upload Java test diagnostics
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: java-test-diagnostics
path: |
tools/java_api/build/test-results/test
tools/java_api/build/reports/tests/test
tools/java_api/build/hs_err_pid*.log

- name: Upload Java JAR
uses: actions/upload-artifact@v4
Expand Down
81 changes: 77 additions & 4 deletions .github/workflows/java-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
name: Build Java Lib
on:
workflow_dispatch:
inputs:
precompiledRunId:
description: "Run ID of the precompiled-bin job whose artifacts should be used"
required: true
type: string
workflow_call:
inputs:
isNightly:
type: boolean
required: true
default: false
precompiledRunId:
type: string
required: true
env:
PIP_BREAK_SYSTEM_PACKAGES: 1

jobs:
build-linux-java-x86_64:
runs-on: ubuntu-latest
env:
LBUG_LINUX_VARIANT: compat
LBUG_JAVA_PRECOMPILED_DIR: ${{ github.workspace }}/precompiled-liblbug
LBUG_JAVA_PRECOMPILED_LIB_PATH: ${{ github.workspace }}/precompiled-liblbug/liblbug.a
steps:
- uses: actions/checkout@v4

- name: Update submodules
run: git submodule update --init --recursive tools/java_api

- name: Download precompiled liblbug
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LBUG_LIB_KIND: static
LBUG_PRECOMPILED_RUN_ID: ${{ inputs.precompiledRunId }}
LBUG_TARGET_DIR: ${{ env.LBUG_JAVA_PRECOMPILED_DIR }}
run: |
rm -rf "$LBUG_TARGET_DIR"
./scripts/download-liblbug.sh

- name: Install uv
run: python3 -m pip install uv

Expand All @@ -32,6 +55,8 @@ jobs:
working-directory: scripts

- name: Build Java lib for Linux
env:
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_JAVA_PRECOMPILED_LIB_PATH }}
run: |
make GEN=Ninja java

Expand All @@ -41,13 +66,28 @@ jobs:
path: tools/java_api/build/liblbug_java_native*

build-linux-java-aarch64:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
env:
LBUG_LINUX_VARIANT: compat
LBUG_JAVA_PRECOMPILED_DIR: ${{ github.workspace }}/precompiled-liblbug
LBUG_JAVA_PRECOMPILED_LIB_PATH: ${{ github.workspace }}/precompiled-liblbug/liblbug.a
steps:
- uses: actions/checkout@v4

- name: Update submodules
run: git submodule update --init --recursive tools/java_api

- name: Download precompiled liblbug
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LBUG_LIB_KIND: static
LBUG_PRECOMPILED_RUN_ID: ${{ inputs.precompiledRunId }}
LBUG_TARGET_DIR: ${{ env.LBUG_JAVA_PRECOMPILED_DIR }}
run: |
rm -rf "$LBUG_TARGET_DIR"
./scripts/download-liblbug.sh

- name: Install uv
run: python3 -m pip install uv

Expand All @@ -61,6 +101,8 @@ jobs:
working-directory: scripts

- name: Build Java lib for Linux
env:
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_JAVA_PRECOMPILED_LIB_PATH }}
run: make GEN=Ninja java

- uses: actions/upload-artifact@v4
Expand All @@ -70,12 +112,26 @@ jobs:

build-mac-java-arm:
runs-on: macos-latest
env:
LBUG_JAVA_PRECOMPILED_DIR: ${{ github.workspace }}/precompiled-liblbug
LBUG_JAVA_PRECOMPILED_LIB_PATH: ${{ github.workspace }}/precompiled-liblbug/liblbug.a
steps:
- uses: actions/checkout@v4

- name: Update submodules
run: git submodule update --init --recursive tools/java_api

- name: Download precompiled liblbug
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LBUG_LIB_KIND: static
LBUG_PRECOMPILED_RUN_ID: ${{ inputs.precompiledRunId }}
LBUG_TARGET_DIR: ${{ env.LBUG_JAVA_PRECOMPILED_DIR }}
run: |
rm -rf "$LBUG_TARGET_DIR"
./scripts/download-liblbug.sh

- name: Install uv
run: pip3 install uv

Expand All @@ -89,11 +145,12 @@ jobs:
working-directory: scripts

- name: Build Java lib for Apple Silicon
run: |
arch -arm64 env JAVA_HOME=$(/usr/libexec/java_home) make GEN=Ninja java
env:
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_JAVA_PRECOMPILED_LIB_PATH }}
MACOSX_DEPLOYMENT_TARGET: 13.3
ARCHFLAGS: "-arch arm64"
run: |
arch -arm64 env JAVA_HOME=$(/usr/libexec/java_home) make GEN=Ninja java

- uses: actions/upload-artifact@v4
with:
Expand All @@ -102,12 +159,26 @@ jobs:

build-windows-java:
runs-on: windows-latest
env:
LBUG_JAVA_PRECOMPILED_DIR: ${{ github.workspace }}/precompiled-liblbug
LBUG_JAVA_PRECOMPILED_LIB_PATH: ${{ github.workspace }}/precompiled-liblbug/lbug.lib
steps:
- uses: actions/checkout@v4

- name: Update submodules
run: git submodule update --init --recursive tools/java_api

- name: Download precompiled liblbug
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LBUG_LIB_KIND: static
LBUG_PRECOMPILED_RUN_ID: ${{ inputs.precompiledRunId }}
LBUG_TARGET_DIR: ${{ env.LBUG_JAVA_PRECOMPILED_DIR }}
run: |
rm -rf "$LBUG_TARGET_DIR"
./scripts/download-liblbug.sh

- name: Install uv
run: pip3 install uv

Expand All @@ -127,6 +198,8 @@ jobs:

- name: Build Java lib for Windows
shell: cmd
env:
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_JAVA_PRECOMPILED_LIB_PATH }}
run: |
powershell.exe -Command "Add-MpPreference -ExclusionPath '${{ github.workspace }}'"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
Expand All @@ -135,4 +208,4 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: java-lib-win-x86_64
path: tools/java_api/build/liblbug_java_native*
path: tools/java_api/build/liblbug_java_native*
4 changes: 2 additions & 2 deletions .github/workflows/nodejs-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
if: ${{ matrix.platform == 'win32' }}
shell: cmd
env:
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_NODEJS_USE_PRECOMPILED_LIB=TRUE -DLBUG_NODEJS_PRECOMPILED_LIB_PATH=${{ env.LBUG_NODEJS_PRECOMPILED_LIB_PATH }}
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_NODEJS_PRECOMPILED_LIB_PATH }}
run: |
powershell.exe -Command "Add-MpPreference -ExclusionPath '${{ github.workspace }}'"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
Expand All @@ -175,7 +175,7 @@ jobs:
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_NODEJS_USE_PRECOMPILED_LIB=TRUE -DLBUG_NODEJS_PRECOMPILED_LIB_PATH=${{ env.LBUG_NODEJS_PRECOMPILED_LIB_PATH }}
EXTRA_CMAKE_FLAGS: -DBUILD_LBUG=FALSE -DBUILD_SHELL=FALSE -DLBUG_API_USE_PRECOMPILED_LIB=TRUE -DLBUG_API_PRECOMPILED_LIB_PATH=${{ env.LBUG_NODEJS_PRECOMPILED_LIB_PATH }}
run: |
ccache -s
make GEN=Ninja nodejs
Expand Down
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,26 @@ option(BUILD_PYTHON "Build Python API." FALSE)
option(BUILD_SHELL "Build Interactive Shell" TRUE)
option(BUILD_SINGLE_FILE_HEADER "Build single file header. Requires Python >= 3.9." TRUE)
option(BUILD_LBUG "Build Lbug." TRUE)
option(LBUG_NODEJS_USE_PRECOMPILED_LIB "Link the Node.js addon against a precompiled static liblbug archive." FALSE)
set(LBUG_NODEJS_PRECOMPILED_LIB_PATH "" CACHE FILEPATH "Path to the precompiled static liblbug archive used by the Node.js addon.")
option(LBUG_API_USE_PRECOMPILED_LIB "Link language bindings against a precompiled static liblbug archive." FALSE)
set(LBUG_API_PRECOMPILED_LIB_PATH "" CACHE FILEPATH "Path to the precompiled static liblbug archive used by language bindings.")
option(LBUG_NODEJS_USE_PRECOMPILED_LIB "Deprecated alias for LBUG_API_USE_PRECOMPILED_LIB." FALSE)
set(LBUG_NODEJS_PRECOMPILED_LIB_PATH "" CACHE FILEPATH "Deprecated alias for LBUG_API_PRECOMPILED_LIB_PATH.")
option(ENABLE_BACKTRACES "Enable backtrace printing for exceptions and segfaults" FALSE)
option(PREFER_SYSTEM_DEPS "Only download certain deps if not found on the system" TRUE)

if(LBUG_NODEJS_USE_PRECOMPILED_LIB)
set(LBUG_API_USE_PRECOMPILED_LIB TRUE)
endif()
if(LBUG_NODEJS_PRECOMPILED_LIB_PATH AND NOT LBUG_API_PRECOMPILED_LIB_PATH)
set(LBUG_API_PRECOMPILED_LIB_PATH "${LBUG_NODEJS_PRECOMPILED_LIB_PATH}")
endif()
if(LBUG_API_USE_PRECOMPILED_LIB)
set(LBUG_NODEJS_USE_PRECOMPILED_LIB TRUE CACHE BOOL "Deprecated alias for LBUG_API_USE_PRECOMPILED_LIB." FORCE)
set(BUILD_LBUG FALSE CACHE BOOL "Build Lbug." FORCE)
endif()
if(LBUG_API_PRECOMPILED_LIB_PATH)
set(LBUG_NODEJS_PRECOMPILED_LIB_PATH "${LBUG_API_PRECOMPILED_LIB_PATH}" CACHE FILEPATH "Deprecated alias for LBUG_API_PRECOMPILED_LIB_PATH." FORCE)
endif()

option(BUILD_LCOV "Build coverage report." FALSE)
if(${BUILD_LCOV})
Expand Down Expand Up @@ -405,7 +417,7 @@ function(add_lbug_api_test TEST_NAME)
endfunction()

# Windows doesn't support dynamic lookup, so we have to link extensions against lbug.
if (MSVC AND (NOT BUILD_EXTENSIONS EQUAL "") AND NOT LBUG_NODEJS_USE_PRECOMPILED_LIB)
if (MSVC AND (NOT BUILD_EXTENSIONS EQUAL "") AND NOT LBUG_API_USE_PRECOMPILED_LIB)
set(BUILD_LBUG TRUE)
endif ()

Expand Down
7 changes: 7 additions & 0 deletions src/c_api/connection.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "c_api/helpers.h"
#include "c_api/lbug.h"
#include "common/exception/exception.h"
#include "main/lbug.h"
Expand Down Expand Up @@ -66,6 +67,7 @@ lbug_state lbug_connection_query(lbug_connection* connection, const char* query,
return LbugError;
}
try {
clearLastCAPIErrorMessage();
auto query_result =
static_cast<Connection*>(connection->_connection)->query(query).release();
if (query_result == nullptr) {
Expand All @@ -78,6 +80,7 @@ lbug_state lbug_connection_query(lbug_connection* connection, const char* query,
}
return LbugSuccess;
} catch (Exception& e) {
setLastCAPIErrorMessage(e.what());
return LbugError;
}
}
Expand All @@ -88,6 +91,7 @@ lbug_state lbug_connection_prepare(lbug_connection* connection, const char* quer
return LbugError;
}
try {
clearLastCAPIErrorMessage();
auto prepared_statement =
static_cast<Connection*>(connection->_connection)->prepare(query).release();
if (prepared_statement == nullptr) {
Expand All @@ -98,6 +102,7 @@ lbug_state lbug_connection_prepare(lbug_connection* connection, const char* quer
new std::unordered_map<std::string, std::unique_ptr<Value>>;
return LbugSuccess;
} catch (Exception& e) {
setLastCAPIErrorMessage(e.what());
return LbugError;
}
return LbugSuccess;
Expand All @@ -111,6 +116,7 @@ lbug_state lbug_connection_execute(lbug_connection* connection,
return LbugError;
}
try {
clearLastCAPIErrorMessage();
auto prepared_statement_ptr =
static_cast<PreparedStatement*>(prepared_statement->_prepared_statement);
auto bound_values = static_cast<std::unordered_map<std::string, std::unique_ptr<Value>>*>(
Expand All @@ -137,6 +143,7 @@ lbug_state lbug_connection_execute(lbug_connection* connection,
}
return LbugSuccess;
} catch (Exception& e) {
setLastCAPIErrorMessage(e.what());
return LbugError;
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/c_api/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ lbug_data_type_id lbug_data_type_get_id(lbug_logical_type* data_type) {
return static_cast<lbug_data_type_id>(data_type_id_u8);
}

lbug_state lbug_data_type_get_child_type(lbug_logical_type* data_type,
lbug_logical_type* out_result) {
auto* parent_type = static_cast<LogicalType*>(data_type->_data_type);
try {
switch (parent_type->getLogicalTypeID()) {
case LogicalTypeID::ARRAY:
out_result->_data_type = new LogicalType(ArrayType::getChildType(*parent_type).copy());
return LbugSuccess;
case LogicalTypeID::LIST:
out_result->_data_type = new LogicalType(ListType::getChildType(*parent_type).copy());
return LbugSuccess;
default:
return LbugError;
}
} catch (Exception& e) {
return LbugError;
}
}

lbug_state lbug_data_type_get_num_elements_in_array(lbug_logical_type* data_type,
uint64_t* out_result) {
auto parent_type = static_cast<LogicalType*>(data_type->_data_type);
Expand Down
8 changes: 7 additions & 1 deletion src/c_api/database.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "c_api/helpers.h"
#include "c_api/lbug.h"
#include "common/exception/exception.h"
#include "main/lbug.h"
Expand All @@ -7,17 +8,20 @@ using namespace lbug::common;
lbug_state lbug_database_init(const char* database_path, lbug_system_config config,
lbug_database* out_database) {
try {
clearLastCAPIErrorMessage();
std::string database_path_str = database_path;
auto systemConfig = SystemConfig(config.buffer_pool_size, config.max_num_threads,
config.enable_compression, config.read_only, config.max_db_size, config.auto_checkpoint,
config.checkpoint_threshold);
config.checkpoint_threshold, true, config.throw_on_wal_replay_failure,
config.enable_checksums);

#if defined(__APPLE__)
systemConfig.threadQos = config.thread_qos;
#endif
out_database->_database = new Database(database_path_str, systemConfig);
} catch (Exception& e) {
out_database->_database = nullptr;
setLastCAPIErrorMessage(e.what());
return LbugError;
}
return LbugSuccess;
Expand All @@ -42,6 +46,8 @@ lbug_system_config lbug_default_system_config() {
cSystemConfig.max_db_size = config.maxDBSize;
cSystemConfig.auto_checkpoint = config.autoCheckpoint;
cSystemConfig.checkpoint_threshold = config.checkpointThreshold;
cSystemConfig.throw_on_wal_replay_failure = config.throwOnWalReplayFailure;
cSystemConfig.enable_checksums = config.enableChecksums;
#if defined(__APPLE__)
cSystemConfig.thread_qos = config.threadQos;
#endif
Expand Down
Loading
Loading