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
15 changes: 15 additions & 0 deletions .github/workflows/ci_parquetindex_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: parquetindex-demo
on:
workflow_dispatch:
push:
branches: ["master"]
pull_request:
paths:
- 'parquetindex/**'
- '.github/workflows/_common_jobs.yml'
- '.github/workflows/ci_parquetindex_demo.yml'
jobs:
ci:
uses: ./.github/workflows/_common_jobs.yml
with:
workspace: parquetindex
19 changes: 19 additions & 0 deletions parquetindex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package-lock.json
node_modules
dist

# Logs
logs
*.log
npm-debug.log*

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
7 changes: 7 additions & 0 deletions parquetindex/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions parquetindex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Hyparquet demo

This is an example project showing how to use [hyparquet](https://github.com/hyparam/hyparquet).

## Build

```bash
npm i
npm run build
```

The build artifacts will be stored in the `dist/` directory and can be served using any static server, eg. `http-server`:

```bash
npm i -g http-server
http-server dist/
```
82 changes: 82 additions & 0 deletions parquetindex/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import js from '@eslint/js'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist', 'coverage', 'node_modules'] },
{
extends: [
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked
],
// Set the react version
settings: { react: { version: '18.3' } },
files: ['src/**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,

'arrow-spacing': 'error',
camelcase: 'off',
'comma-spacing': 'error',
'comma-dangle': ['error', 'always-multiline'],
'eol-last': 'error',
eqeqeq: 'error',
'func-style': ['error', 'declaration'],
indent: ['error', 2],
'key-spacing': 'error',
'no-constant-condition': 'off',
'no-extra-parens': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'no-trailing-spaces': 'error',
'no-unused-vars': 'off',
'no-useless-concat': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'warn',
'prefer-destructuring': ['warn', {
object: true,
array: false,
}],
'prefer-promise-reject-errors': 'error',
quotes: ['error', 'single'],
'require-await': 'warn',
semi: ['error', 'never'],
'sort-imports': ['error', {
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
'space-infix-ops': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
},
},
)
28 changes: 28 additions & 0 deletions parquetindex/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>parquetindex full text search demo</title>
<link rel="icon" href="favicon.svg" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Mulish:wght@400;600&display=swap"/>
<meta name="description" content="Online demo of parquetindex: a library for building full text search indexes against parquet files stored in cloud object storage.">
<meta name="author" content="Hyperparam">
<meta name="keywords" content="parquetindex, hyparquet, parquet, parquet file, parquet parser, parquet reader, parquet search, parquet data, apache parquet">
<meta name="theme-color" content="#4433aa">
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<nav class="sidebar">
<div>
<a class="brand" href='https://hyparam.github.io/demos/parquetindex/'>
parquetindex
</a>
</div>
</nav>
<main id="content">
<div id="app"></div>
</main>

<script type="module" src="/src/main.tsx"></script>
</body>
</html>
40 changes: 40 additions & 0 deletions parquetindex/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "hyparquet-demo",
"private": true,
"version": "0.1.0",
"license": "MIT",
"type": "module",
"scripts": {
"coverage": "vitest run --coverage --coverage.include=src",
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest run --dir test",
"typecheck": "tsc"
},
"dependencies": {
"hightable": "0.26.4",
"hyparquet": "1.25.6",
"hyparquet-compressors": "1.1.1",
"hyperparam": "0.4.14",
"parquetindex": "0.1.0",
"react": "19.2.5",
"react-dom": "19.2.5"
},
"devDependencies": {
"@types/react": "19.2.14",
"@types/react-dom": "19.2.3",
"@vitejs/plugin-react": "6.0.1",
"@vitest/coverage-v8": "4.1.5",
"eslint": "9.39.4",
"eslint-plugin-react": "7.37.5",
"eslint-plugin-react-hooks": "7.1.1",
"eslint-plugin-react-refresh": "0.5.2",
"globals": "17.6.0",
"typescript": "6.0.3",
"typescript-eslint": "8.59.1",
"vite": "8.0.10",
"vitest": "4.1.5"
}
}
6 changes: 6 additions & 0 deletions parquetindex/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions parquetindex/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ReactNode } from 'react'
import Page, { PageProps } from './Page.js'
import Welcome from './Welcome.js'

import { sortableDataFrame } from 'hightable'
import { byteLengthFromUrl, parquetMetadataAsync } from 'hyparquet'
import { AsyncBufferFrom, asyncBufferFrom, parquetDataFrame } from 'hyperparam'
import { useCallback, useEffect, useState } from 'react'
import Layout from './Layout.js'

export default function App(): ReactNode {
const params = new URLSearchParams(location.search)
const url = params.get('key') ?? undefined

const [error, setError] = useState<Error>()
const [pageProps, setPageProps] = useState<PageProps>()

const setUnknownError = useCallback((e: unknown) => {
setError(e instanceof Error ? e : new Error(String(e)))
}, [])

const setAsyncBuffer = useCallback(async function setAsyncBuffer(name: string, from: AsyncBufferFrom) {
const asyncBuffer = await asyncBufferFrom(from)
const metadata = await parquetMetadataAsync(asyncBuffer)
const df = sortableDataFrame(parquetDataFrame(from, metadata))
setPageProps({ metadata, df, name, byteLength: from.byteLength, setError: setUnknownError })
}, [setUnknownError])

const onUrlDrop = useCallback(
(url: string) => {
// Add key=url to query string
const params = new URLSearchParams(location.search)
params.set('key', url)
history.pushState({}, '', `${location.pathname}?${params}`)
byteLengthFromUrl(url).then(byteLength => setAsyncBuffer(url, { url, byteLength })).catch(setUnknownError)
},
[setUnknownError, setAsyncBuffer],
)

useEffect(() => {
if (!pageProps && url) {
onUrlDrop(url)
}
}, [url, pageProps, onUrlDrop])

return <Layout error={error}>
{pageProps ? <Page {...pageProps} /> : <Welcome />}
</Layout>
}
36 changes: 36 additions & 0 deletions parquetindex/src/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ErrorBar, cn } from 'hyperparam'
import type { ReactNode } from 'react'

interface LayoutProps {
children: ReactNode
className?: string
progress?: number
error?: Error
}

/**
* Layout for shared UI.
* Content div style can be overridden by className prop.
*
* @param {Object} props
* @param {ReactNode} props.children - content to display inside the layout
* @param {string | undefined} props.className - additional class names to apply to the content container
* @param {number | undefined} props.progress - progress bar value
* @param {Error} props.error - error message to display
* @returns {ReactNode}
*/
export default function Layout({ children, className, progress, error }: LayoutProps): ReactNode {
return <>
<div className='content-container'>
<div className={cn('content', className)}>
{children}
</div>
<ErrorBar error={error} />
</div>
{progress !== undefined && progress < 1 &&
<div className={'progress-bar'} role='progressbar'>
<div style={{ width: `${100 * progress}%` }} />
</div>
}
</>
}
Loading