Skip to content

Commit

Permalink
Merge branch 'main' of github.com:voluntas/duckdb-wasm-parquet
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Sep 9, 2024
2 parents 82ddcc6 + c582011 commit 37ebc10
Show file tree
Hide file tree
Showing 13 changed files with 946 additions and 29 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,22 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 22
- run: pnpm --version
- run: pnpm install
- run: pnpm test
- run: pnpm fmt
- run: pnpm lint
- run: pnpm run build
# ローカルでは通るが GitHub Actions では失敗するので一旦コメントアウト
# test-playwright:
# needs: ci
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 22
# - run: pnpm --version
# - run: pnpm install
# - run: pnpm exec playwright install chromium --with-deps
# - run: pnpm test:playwright
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy sora-devtools to Pages

on:
push:
branches: ["main"]

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm run build
- uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ dist/
/playwright-report/
/blob-report/
/playwright/.cache/

# macOS
.DS_Store
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

- [ADD] Parquet ファイルを S3-compatible object storage から読み込む仕組みを追加
- [ADD] 読み込んだ Parquet ファイルをテーブルにする仕組みを追加
- [ADD] 読み込んだ Parquet ファイルを表示する仕組みを追加
- [ADD] 読み込んだ Parquet ファイルの 10% を表示する仕組みを追加
- [ADD] 読み込んだ Parquet ファイルを利用して集計する仕組みを追加
- [ADD] テーブルをクリアにする仕組みを追加
- [ADD] DuckDB WASM を `next` で追加
- 通常だと古いバージョンがインストールされるので最新を利用するようにする
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ pnpm run dev
```

- ブラウザで `http://localhost:5173/` にアクセスして、`Scan Parquet` ボタンをクリックしてください
- `Load Table (LIMIT 100)` ボタンをクリックして、データを表示してみてください
- `Samples (1%)` ボタンをクリックして、サンプリングした 1% のデータを表示してみてください
- `Aggregation` ボタンをクリックして、集計した結果を表示してみてください

## 動作例

[![Image from Gyazo](https://i.gyazo.com/1e7db788572184e8b1a939eb237807ea.gif)](https://gyazo.com/1e7db788572184e8b1a939eb237807ea)
[![Image from Gyazo](https://i.gyazo.com/5dadf7e6bc002cb77d7d194e46fa5e3d.gif)](https://gyazo.com/5dadf7e6bc002cb77d7d194e46fa5e3d)

## Parquet ファイルについて

以下の URL でお試し用の [Parquet](https://parquet.apache.org/) ファイルを取得することができます。
<https://duckdb-wasm.shiguredo.jp/ES6VB3580N3R7EGKGT0R9NKWPR.parquet>

この Parquet ファイルは[時雨堂](https://shiguredo.jp/)[WebRTC SFU Sora](https://sora.shiguredo.jp/) が出力する
クライアントの [WebRTC 統計情報](https://www.w3.org/TR/webrtc-stats/)
クライアントから送られてくる [WebRTC 統計情報](https://www.w3.org/TR/webrtc-stats/)
[Fluent Bit](https://fluentbit.io/) 経由で [S3 互換オブジェクトストレージ](https://www.linode.com/products/object-storage/) へ保存し、
ログを DuckDB で集約しテーブルを作成後、 Parquet ファイルとして出力したものです。元々のログは [JSONL](https://jsonlines.org/) 形式で gzip 圧縮です。
DuckDB で集約し Parquet ファイルとして出力したものです。
元々のログは [JSONL](https://jsonlines.org/) 形式で gzip 圧縮です。

- この Parquet ファイルは [zstd](https://github.com/facebook/zstd) で圧縮されています
- この Parquet ファイルは [Cloudflare R2](https://www.cloudflare.com/developer-platform/r2/) に保存されており、パブリックで誰でもアクセスすることができます
Expand All @@ -47,7 +48,7 @@ pnpm run dev
### DuckDB でアクセスしてみる

```sql
D select * FROM parquet_scan('https://duckdb-wasm.shiguredo.jp/ES6VB3580N3R7EGKGT0R9NKWPR.parquet');
D SELECT * FROM parquet_scan('https://duckdb-wasm.shiguredo.jp/ES6VB3580N3R7EGKGT0R9NKWPR.parquet');
┌──────────────────────┬──────────────────────┬─────────────────┬───┬───────────────────┬─────────────────────┐
│ connection_id │ id │ label │ … │ rtc_timestamp │ rtc_type │
varcharvarcharvarchar │ │ double │ varchar
Expand Down
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ <h1>DuckDB-Wasm + Parquet + S3-compatible object storage</h1>
<h2 id="scanned">Scanned: false</h2>
<h2 id="counted">Counted: 0</h2>
<button id="scan-parquet">Scan Parquet</button>
<button id="load-table">Load Table (LIMIT 100)</button>
<button id="aggregation-example">Aggregation</button>
<button id="samples">Samples (1%)</button>
<button id="aggregation">Aggregation</button>
<button id="clear">Clear</button>
<div id="result"></div>
</div>

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
"private": true,
"scripts": {
"dev": "vite",
"test:vitest": "vitest run",
"test:playwright": "playwright test",
"build": "vite build",
"lint": "biome lint src/",
"fmt": "pnpm biome format --write src/ test/",
"test": "vitest run",
"fmt": "pnpm biome format --write src/ tests/",
"check": "tsc --noEmit"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@playwright/test": "1.47.0",
"playwright": "1.47.0",
"typescript": "5.5.4",
"vite": "5.4.3",
"vitest": "2.0.5"
Expand Down
32 changes: 32 additions & 0 deletions playwright.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineConfig, devices } from '@playwright/test'

// pnpm exec playwright test --ui

export default defineConfig({
testDir: 'tests/playwright',
// fullyParallel: true,
reporter: 'html',
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
],
webServer: {
command: 'pnpm run dev --port 5173',
url: 'http://localhost:5173/',
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
},
})
Loading

0 comments on commit 37ebc10

Please sign in to comment.