Skip to content

Commit c4d397e

Browse files
committed
initial file renames, compiles, loads
1 parent ae11e27 commit c4d397e

36 files changed

+149
-121
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.12)
2-
set(TARGET_NAME sqlite_scanner)
2+
set(TARGET_NAME rocksdb_scanner)
33
project(${TARGET_NAME})
44
include_directories(sqlite)
55

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ BUILD_FLAGS=-DEXTENSION_STATIC_BUILD=1 -DBUILD_TPCH_EXTENSION=1 ${OSX_BUILD_UNIV
1515

1616
pull:
1717
git submodule init
18-
git submodule update --recursive --remote
18+
git submodule update --recursive --remote
1919

2020
clean:
2121
rm -rf build
2222

2323
debug: pull
2424
mkdir -p build/debug && \
2525
cd build/debug && \
26-
cmake $(GENERATOR) -DCMAKE_BUILD_TYPE=Debug ${BUILD_FLAGS} ../../duckdb/CMakeLists.txt -DEXTERNAL_EXTENSION_DIRECTORIES=../../sqlite_scanner -B. && \
26+
cmake $(GENERATOR) -DCMAKE_BUILD_TYPE=Debug ${BUILD_FLAGS} ../../duckdb/CMakeLists.txt -DEXTERNAL_EXTENSION_DIRECTORIES=../../rocksdb_scanner -B. && \
2727
cmake --build . --config Debug
2828

29-
release: pull
29+
release: pull
3030
mkdir -p build/release && \
3131
cd build/release && \
32-
cmake $(GENERATOR) -DCMAKE_BUILD_TYPE=RelWithDebInfo ${BUILD_FLAGS} ../../duckdb/CMakeLists.txt -DEXTERNAL_EXTENSION_DIRECTORIES=../../sqlite_scanner -B. && \
32+
cmake $(GENERATOR) -DCMAKE_BUILD_TYPE=RelWithDebInfo ${BUILD_FLAGS} ../../duckdb/CMakeLists.txt -DEXTERNAL_EXTENSION_DIRECTORIES=../../rocksdb_scanner -B. && \
3333
cmake --build . --config Release
3434

3535
test: release

README.md

+45-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# DuckDB rocksdbscanner extension
2+
3+
Attempt to create RocksDB scanner similar to Sqlite scanner.
4+
5+
* renamed the files from sqlite_xxx.yyy to rocksdb_xxx.yyy
6+
* left the sqlite code parts intact
7+
* compiled as release (debug does not load the extension!?)
8+
* loaded extension
9+
10+
hinxx@obzen ~/ess/duckdb/rocksdb_scanner $ ./build/release/duckdb -unsigned
11+
12+
D install 'build/release/extension/rocksdb_scanner/rocksdb_scanner.duckdb_extension';
13+
D load 'build/release/extension/rocksdb_scanner/rocksdb_scanner.duckdb_extension';
14+
D select * from duckdb_extensions();
15+
...
16+
│ rocksdb_scanner │ true │ true │ /home/hinxx/.duckdb/extensions/ab9736bed0/linux_amd… │ Adds support for reading RocksDB database files │ []
17+
...
18+
19+
D .maxrows 10000
20+
D select distinct on(function_name) function_name, function_type, return_type, parameters, parameter_types from duckdb_functions() order by function_name;
21+
...
22+
│ rocksdb_attach │ table │ │ [col0, overwrite][VARCHAR, BOOLEAN]
23+
│ rocksdb_scan │ table │ │ [col0, col1][VARCHAR, VARCHAR]
24+
...
25+
26+
27+
28+
129
# DuckDB sqlitescanner extension
230

331
The sqlitescanner extension allows DuckDB to directly read data from a SQLite database file. The data can be queried directly from the underlying SQLite tables, or read into DuckDB tables.
@@ -17,22 +45,22 @@ PRAGMA show_tables;
1745
Then you can query those views normally using SQL, e.g. using the example queries from sakila-examples.sql
1846

1947
```sql
20-
SELECT cat.name category_name,
21-
Sum(Ifnull(pay.amount, 0)) revenue
22-
FROM category cat
23-
LEFT JOIN film_category flm_cat
24-
ON cat.category_id = flm_cat.category_id
25-
LEFT JOIN film fil
26-
ON flm_cat.film_id = fil.film_id
27-
LEFT JOIN inventory inv
28-
ON fil.film_id = inv.film_id
29-
LEFT JOIN rental ren
30-
ON inv.inventory_id = ren.inventory_id
31-
LEFT JOIN payment pay
32-
ON ren.rental_id = pay.rental_id
33-
GROUP BY cat.name
34-
ORDER BY revenue DESC
35-
LIMIT 5;
48+
SELECT cat.name category_name,
49+
Sum(Ifnull(pay.amount, 0)) revenue
50+
FROM category cat
51+
LEFT JOIN film_category flm_cat
52+
ON cat.category_id = flm_cat.category_id
53+
LEFT JOIN film fil
54+
ON flm_cat.film_id = fil.film_id
55+
LEFT JOIN inventory inv
56+
ON fil.film_id = inv.film_id
57+
LEFT JOIN rental ren
58+
ON inv.inventory_id = ren.inventory_id
59+
LEFT JOIN payment pay
60+
ON ren.rental_id = pay.rental_id
61+
GROUP BY cat.name
62+
ORDER BY revenue DESC
63+
LIMIT 5;
3664
```
3765

3866

@@ -44,7 +72,7 @@ sqlite3 sakila.db < sakila-examples.sql
4472

4573
## Building & Loading the Extension
4674

47-
To build, type
75+
To build, type
4876
```
4977
make
5078
```

src/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ include_directories(include)
33
add_subdirectory(storage)
44

55
add_library(
6-
sqlite_ext_library OBJECT
7-
sqlite_db.cpp sqlite_extension.cpp sqlite_scanner.cpp sqlite_stmt.cpp
8-
sqlite_storage.cpp sqlite_utils.cpp)
6+
rocksdb_ext_library OBJECT
7+
rocksdb_db.cpp rocksdb_extension.cpp rocksdb_scanner.cpp rocksdb_stmt.cpp
8+
rocksdb_storage.cpp rocksdb_utils.cpp)
99
set(ALL_OBJECT_FILES
10-
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:sqlite_ext_library>
10+
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:rocksdb_ext_library>
1111
PARENT_SCOPE)

src/include/sqlite_db.hpp src/include/rocksdb_db.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// sqlite_db.hpp
4+
// rocksdb_db.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
1010

11-
#include "sqlite_utils.hpp"
11+
#include "rocksdb_utils.hpp"
1212

1313
namespace duckdb {
1414
class SQLiteStatement;

src/include/sqlite_scanner.hpp src/include/rocksdb_scanner.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// sqlite_scanner.hpp
4+
// rocksdb_scanner.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/sqlite_stmt.hpp src/include/rocksdb_stmt.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// sqlite_utils.hpp
4+
// rocksdb_utils.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
1010

11-
#include "sqlite_utils.hpp"
11+
#include "rocksdb_utils.hpp"
1212

1313
#include <cstddef>
1414

src/include/sqlite_storage.hpp src/include/rocksdb_storage.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// sqlite_storage.hpp
4+
// rocksdb_storage.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/sqlite_utils.hpp src/include/rocksdb_utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// sqlite_utils.hpp
4+
// rocksdb_utils.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_catalog.hpp src/include/storage/rocksdb_catalog.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_catalog.hpp
4+
// storage/rocksdb_catalog.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//
@@ -10,7 +10,7 @@
1010

1111
#include "duckdb/catalog/catalog.hpp"
1212
#include "duckdb/common/enums/access_mode.hpp"
13-
#include "sqlite_db.hpp"
13+
#include "rocksdb_db.hpp"
1414

1515
namespace duckdb {
1616
class SQLiteSchemaEntry;

src/include/storage/sqlite_delete.hpp src/include/storage/rocksdb_delete.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_delete.hpp
4+
// storage/rocksdb_delete.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_index.hpp src/include/storage/rocksdb_index.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_index.hpp
4+
// storage/rocksdb_index.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_index_entry.hpp src/include/storage/rocksdb_index_entry.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_index_entry.hpp
4+
// storage/rocksdb_index_entry.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_insert.hpp src/include/storage/rocksdb_insert.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_insert.hpp
4+
// storage/rocksdb_insert.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_schema_entry.hpp src/include/storage/rocksdb_schema_entry.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_schema_entry.hpp
4+
// storage/rocksdb_schema_entry.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_table_entry.hpp src/include/storage/rocksdb_table_entry.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_table_entry.hpp
4+
// storage/rocksdb_table_entry.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/include/storage/sqlite_transaction.hpp src/include/storage/rocksdb_transaction.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_transaction.hpp
4+
// storage/rocksdb_transaction.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//
@@ -10,7 +10,7 @@
1010

1111
#include "duckdb/transaction/transaction.hpp"
1212
#include "duckdb/common/case_insensitive_map.hpp"
13-
#include "sqlite_db.hpp"
13+
#include "rocksdb_db.hpp"
1414

1515
namespace duckdb {
1616
class SQLiteCatalog;

src/include/storage/sqlite_transaction_manager.hpp src/include/storage/rocksdb_transaction_manager.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_transaction_manager.hpp
4+
// storage/rocksdb_transaction_manager.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
1010

1111
#include "duckdb/transaction/transaction_manager.hpp"
12-
#include "storage/sqlite_catalog.hpp"
13-
#include "storage/sqlite_transaction.hpp"
12+
#include "storage/rocksdb_catalog.hpp"
13+
#include "storage/rocksdb_transaction.hpp"
1414

1515
namespace duckdb {
1616

src/include/storage/sqlite_update.hpp src/include/storage/rocksdb_update.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//===----------------------------------------------------------------------===//
22
// DuckDB
33
//
4-
// storage/sqlite_update.hpp
4+
// storage/rocksdb_update.hpp
55
//
66
//
77
//===----------------------------------------------------------------------===//

src/sqlite_db.cpp src/rocksdb_db.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "duckdb/parser/expression/constant_expression.hpp"
44
#include "duckdb/parser/column_list.hpp"
55
#include "duckdb/parser/parser.hpp"
6-
#include "sqlite_db.hpp"
7-
#include "sqlite_stmt.hpp"
6+
#include "rocksdb_db.hpp"
7+
#include "rocksdb_stmt.hpp"
88

99
namespace duckdb {
1010

src/sqlite_extension.cpp src/rocksdb_extension.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#endif
44
#include "duckdb.hpp"
55

6-
#include "sqlite_scanner.hpp"
7-
#include "sqlite_storage.hpp"
6+
#include "rocksdb_scanner.hpp"
7+
#include "rocksdb_storage.hpp"
88

99
#include "duckdb/catalog/catalog.hpp"
1010
#include "duckdb/parser/parsed_data/create_table_function_info.hpp"
@@ -13,7 +13,7 @@ using namespace duckdb;
1313

1414
extern "C" {
1515

16-
DUCKDB_EXTENSION_API void sqlite_scanner_init(duckdb::DatabaseInstance &db) {
16+
DUCKDB_EXTENSION_API void rocksdb_scanner_init(duckdb::DatabaseInstance &db) {
1717
Connection con(db);
1818
con.BeginTransaction();
1919
auto &context = *con.context;
@@ -29,18 +29,18 @@ DUCKDB_EXTENSION_API void sqlite_scanner_init(duckdb::DatabaseInstance &db) {
2929
catalog.CreateTableFunction(context, &attach_info);
3030

3131
auto &config = DBConfig::GetConfig(db);
32-
config.AddExtensionOption("sqlite_all_varchar", "Load all SQLite columns as VARCHAR columns", LogicalType::BOOLEAN);
32+
config.AddExtensionOption("rocksdb_all_varchar", "Load all RocksDB columns as VARCHAR columns", LogicalType::BOOLEAN);
3333

34-
config.storage_extensions["sqlite_scanner"] = make_unique<SQLiteStorageExtension>();
34+
config.storage_extensions["rocksdb_scanner"] = make_unique<SQLiteStorageExtension>();
3535

3636
con.Commit();
3737
}
3838

39-
DUCKDB_EXTENSION_API const char *sqlite_scanner_version() {
39+
DUCKDB_EXTENSION_API const char *rocksdb_scanner_version() {
4040
return DuckDB::LibraryVersion();
4141
}
4242

43-
DUCKDB_EXTENSION_API void sqlite_scanner_storage_init(DBConfig &config) {
44-
config.storage_extensions["sqlite_scanner"] = make_unique<SQLiteStorageExtension>();
43+
DUCKDB_EXTENSION_API void rocksdb_scanner_storage_init(DBConfig &config) {
44+
config.storage_extensions["rocksdb_scanner"] = make_unique<SQLiteStorageExtension>();
4545
}
4646
}

0 commit comments

Comments
 (0)