Skip to content

Commit

Permalink
Refactor/#63 refactor c layer (#64)
Browse files Browse the repository at this point in the history
* Refactoring of the C layer 
* Added more unit tests (pure C++) which run on windows/MacOsX/Ubuntu
* Added GH actions for builds only (For Windows+Mac).
* Added Developer Guide.

Fixes #63
  • Loading branch information
tomuben authored Aug 9, 2021
1 parent 2459204 commit 0b693a7
Show file tree
Hide file tree
Showing 95 changed files with 7,657 additions and 703 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/cpp_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI-cpp

on: [push, pull_request]

jobs:
check:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest }
- { os: macOS-latest }
- { os: ubuntu-latest }

steps:
- uses: actions/checkout@v2


- name: Setup Python 3.6 for integration-test-docker-environment
uses: actions/setup-python@v2
with:
python-version: 3.6
- uses: lukka/get-cmake@latest
- name: Run CMake
uses: lukka/run-cmake@main
id: runcmake
with:
cmakeGenerator: 'Ninja'
cmakeListsOrSettingsJson: 'CMakeListsTxtBasic'
cmakeListsTxtPath: '${{ github.workspace }}/tests/cpp/CMakeLists.txt'
useVcpkgToolchainFile: true
buildWithCMakeArgs: '-- -v'
buildDirectory: '${{ runner.workspace }}/b/'
- name: Run Cpp tests
run: 'python3 ${{ github.workspace }}/tests/cpp/python_server_tests.py'
working-directory: '${{ runner.workspace }}/b/'
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
strategy:
fail-fast: false
matrix:
memory_checker:
- no_check
- valgrind
- asan_no_leak
r-version: ${{fromJson(needs.prep-testbed.outputs.matrix)}}
runs-on: ubuntu-18.04

Expand All @@ -42,7 +46,7 @@ jobs:
- name: Run all tests
run: |
./tests/scripts/pull_docker_image.sh ${{ matrix.r-version }}
./tests/scripts/execute_docker_test_env.sh ${{ matrix.r-version }}
./tests/scripts/execute_docker_test_env.sh ${{ matrix.r-version }} ${{ matrix.memory_checker }}
publish-main:
needs: [prep-testbed,integration_tests]
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/windows_macosx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI-BuildOnly

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'release' }
- { os: macOS-latest, r: 'release' }
environment: ci_build
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- name: Query dependencies
run: |
install.packages("testthat")
install.packages("devtools", dependencies = TRUE)
install.packages("remotes")
library(remotes);install_version("RODBC","1.3-16")
devtools::install_github("jimhester/covr")
devtools::install_github("jimhester/lintr")
devtools::install_github("marcelboldt/DBI")
devtools::install_github("marcelboldt/DBItest")
shell: Rscript {0}
env: # Set individual GH PAT
GITHUB_PAT: ${{ secrets.PAT_FOR_DEVTOOLS }}
- name: Build
run: |
devtools::install()
shell: Rscript {0}
env: # Set individual GH PAT
GITHUB_PAT: ${{ secrets.PAT_FOR_DEVTOOLS }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ src/*.dll
.DS_Store
.project
.cproject
config.log
config.status
/tests/cpp/cmake-build-debug/
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: exasol
Type: Package
Title: R Interface & SDK for the EXASOL Database
Version: 5.3.0
Version: 6.0.0
Date: 2016-01-01
Author: EXASOL AG & Community
Maintainer: Marcel Boldt <marcel.boldt@exasol.com>
Maintainer: Exasol <opensource@exasol.com>
Depends:
R (>= 3.3.0),
DBI (>= 0.3.1)
Expand All @@ -27,7 +27,9 @@ URL: https://github.com/EXASOL/r-exasol https://www.exasol.com/portal
LazyData: yes
Suggests:
testthat,
DBItest
DBItest,
xml2
LinkingTo: testthat
SystemRequirements: EXASOL DB v5 onwards
BugReports: https://github.com/EXASOL/r-exasol/issues
RoxygenNote: 7.1.1
Expand All @@ -37,4 +39,5 @@ Collate:
'exa.writeData.R'
'exa.readData.R'
'EXADBI.R'
'catch-routine-registration.R'
'exasol.R'
6 changes: 6 additions & 0 deletions R/catch-routine-registration.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This dummy function definition is included with the package to ensure that
# 'tools::package_native_routine_registration_skeleton()' generates the required
# registration info for the 'run_testthat_tests' symbol.
(function() {
.Call("run_testthat_tests", FALSE, PACKAGE = "exasol")
})
15 changes: 7 additions & 8 deletions R/exa.readData.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ exa.readData <- function(channel, query, encoding = 'UTF-8',
blank.lines.skip = FALSE, numerals="no.loss")
},
server = NA,...) {
slot <- 0
query <- as.character(query)

try(.Call(C_asyncRODBCQueryFinish, slot, 1))
try(.Call(C_asyncRODBCQueryFinish, 0))

if (is.na(server)) {
server <- odbcGetInfo(channel)[["Server_Name"]]
Expand All @@ -65,21 +64,21 @@ exa.readData <- function(channel, query, encoding = 'UTF-8',
serverHost <- as.character(serverAddress[[1]])
serverPort <- as.integer(serverAddress[[2]])

.Call(C_asyncRODBCIOStart, slot, serverHost, serverPort)
.Call(C_asyncRODBCIOStart,serverHost, serverPort)

proxyHost <- .Call(C_asyncRODBCProxyHost, slot)
proxyPort <- .Call(C_asyncRODBCProxyPort, slot)
proxyHost <- .Call(C_asyncRODBCProxyHost)
proxyPort <- .Call(C_asyncRODBCProxyPort)
query <- paste("EXPORT (", query, ") INTO CSV AT 'http://", proxyHost, ":",
proxyPort, "' FILE 'executeSQL.csv' ENCODING = '",encoding,"' BOOLEAN = 'TRUE/FALSE' WITH COLUMN NAMES",
sep = "")

on.exit(.Call(C_asyncRODBCQueryFinish, slot, 1))
on.exit(.Call(C_asyncRODBCQueryFinish, 0))

fd <- .Call(C_asyncRODBCQueryStart, slot,
fd <- .Call(C_asyncRODBCQueryStart,
attr(channel, "handle_ptr"), query, 0)

res <- reader(fd,...)
on.exit(NULL)
.Call(C_asyncRODBCQueryFinish, slot, 0)
.Call(C_asyncRODBCQueryFinish, 1)
res
}
15 changes: 7 additions & 8 deletions R/exa.writeData.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ exa.writeData <- function(channel, data, tableName, tableColumns = NA,
}
slot <- 0

try(.Call(C_asyncRODBCQueryFinish, slot, 1))
try(.Call(C_asyncRODBCQueryFinish, 0))

if (missing(server)) {
server <- odbcGetInfo(channel)[["Server_Name"]]
Expand All @@ -67,22 +67,21 @@ exa.writeData <- function(channel, data, tableName, tableColumns = NA,
serverHost <- as.character(serverAddress[[1]])
serverPort <- as.integer(serverAddress[[2]])

.Call(C_asyncRODBCIOStart, slot, serverHost, serverPort)
proxyHost <- .Call(C_asyncRODBCProxyHost, slot)
proxyPort <- .Call(C_asyncRODBCProxyPort, slot)
.Call(C_asyncRODBCIOStart, serverHost, serverPort)
proxyHost <- .Call(C_asyncRODBCProxyHost)
proxyPort <- .Call(C_asyncRODBCProxyPort)

query <- paste0("IMPORT INTO ", tableName,
if (is.na(tableColumns)) ""
else {paste("(",paste(tableColumns,collapse=", "),")")},
" FROM CSV AT 'http://", proxyHost, ":",
proxyPort, "' FILE 'importData.csv' ENCODING = '", encoding, "'")
on.exit(.Call(C_asyncRODBCQueryFinish, slot, 1))
on.exit(.Call(C_asyncRODBCQueryFinish, 0))

fd <- .Call(C_asyncRODBCQueryStart, slot,
attr(channel, "handle_ptr"), query, 1)
fd <- .Call(C_asyncRODBCQueryStart, attr(channel, "handle_ptr"), query, 1)

res <- writer(data, fd)
flush(fd)
.Call(C_asyncRODBCQueryFinish, slot, 0)
.Call(C_asyncRODBCQueryFinish, 1)
ifelse(is.null(res), return(TRUE), return(res))
}
9 changes: 0 additions & 9 deletions R/exasol.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,12 @@ ALLOWED_UDF_OUT_TYPES <- c(EMITS, RETURNS)
#' TODO comment
"C_asyncRODBCIOStart"

#' TODO comment
"C_asyncRODBCIsDone"

#' TODO comment
"C_asyncRODBCMax"

#' TODO comment
"C_asyncRODBCProxyHost"

#' TODO comment
"C_asyncRODBCProxyPort"

#' TODO comment
"C_asyncRODBCQueryCheck"

#' TODO comment
"C_asyncRODBCQueryFinish"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Code coverage of tests:
3. The R package **devtools** must be available as it contains the `install_github()` method
and the things needed to build the package.

4. Install the necessary dependencies, such as RODBC or the DBI packages. For the versions of these package, checkout the section [Status](#status). Have a look into the [Github Actions Dockerfile](https://github.com/exasol/r-exasol/blob/main/tests/Dockerfile), if you look for an example, how to install the necessary dependencies.
4. Install the necessary dependencies, such as RODBC or the DBI packages. For the versions of these package, checkout the section [Status](#status). Have a look into the [Github Actions Docker](https://github.com/exasol/r-exasol/blob/main/tests/Dockerfile), if you look for an example, how to install the necessary dependencies.


### Installation
Expand Down
Loading

0 comments on commit 0b693a7

Please sign in to comment.