{"id":49283645,"url":"https://github.com/impossibleforge/pfc-py","last_synced_at":"2026-04-25T20:03:53.418Z","repository":{"id":349199287,"uuid":"1201382634","full_name":"ImpossibleForge/pfc-py","owner":"ImpossibleForge","description":"Python interface for PFC-JSONL","archived":false,"fork":false,"pushed_at":"2026-04-21T15:32:43.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-21T17:36:08.503Z","etag":null,"topics":["compression","duckdb","fluent-bit","jsonl","log-compression","pypi","python","structured-logs"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImpossibleForge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-04T15:51:40.000Z","updated_at":"2026-04-21T15:32:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ImpossibleForge/pfc-py","commit_stats":null,"previous_names":["impossibleforge/pfc-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ImpossibleForge/pfc-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImpossibleForge","download_url":"https://codeload.github.com/ImpossibleForge/pfc-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32274987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","duckdb","fluent-bit","jsonl","log-compression","pypi","python","structured-logs"],"created_at":"2026-04-25T20:03:50.446Z","updated_at":"2026-04-25T20:03:53.409Z","avatar_url":"https://github.com/ImpossibleForge.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pfc-jsonl · Python Package\n\nPython interface for **PFC-JSONL** — high-performance compression for structured log files (JSONL), with block-level timestamp filtering.\n\n```\npip install pfc-jsonl\n```\n\n\u003e **Requires the `pfc_jsonl` binary.** Install it separately — see [below](#install-the-binary).\n\n---\n\n## What is PFC-JSONL?\n\nPFC-JSONL compresses JSONL log files **25–37% smaller than gzip/zstd** on typical log data. It stores a timestamp index alongside each file, enabling fast time-range queries without full decompression.\n\n| Operation | Description |\n|-----------|-------------|\n| `compress` | JSONL → `.pfc` (with timestamp index) |\n| `decompress` | `.pfc` → JSONL |\n| `query` | Decompress only blocks matching a time range |\n| `seek_blocks` | Decompress specific blocks by index (DuckDB primitive) |\n\n---\n\n## Quick Start\n\n```python\nimport pfc\n\n# Compress\npfc.compress(\"logs/app.jsonl\", \"logs/app.pfc\")\n\n# Decompress\npfc.decompress(\"logs/app.pfc\", \"logs/app_restored.jsonl\")\n\n# Query by time range — only decompresses matching blocks\npfc.query(\"logs/app.pfc\",\n          from_ts=\"2026-01-15T08:00:00\",\n          to_ts=\"2026-01-15T09:00:00\",\n          output_path=\"logs/morning.jsonl\")\n```\n\n---\n\n## Install the Binary\n\nThe Python package is a thin wrapper — the compression engine is the `pfc_jsonl` binary.\n\n**Linux (x64):**\n```bash\ncurl -L https://github.com/ImpossibleForge/pfc-jsonl/releases/latest/download/pfc_jsonl-linux-x64 \\\n     -o pfc_jsonl \u0026\u0026 chmod +x pfc_jsonl \u0026\u0026 sudo mv pfc_jsonl /usr/local/bin/\n```\n\n**macOS (Apple Silicon M1/M2/M3/M4):**\n```bash\ncurl -L https://github.com/ImpossibleForge/pfc-jsonl/releases/latest/download/pfc_jsonl-macos-arm64 \\\n     -o pfc_jsonl \u0026\u0026 chmod +x pfc_jsonl \u0026\u0026 sudo mv pfc_jsonl /usr/local/bin/\n```\nmacOS Intel (x64): coming soon.\n\n**Windows:** No native binary available. Use WSL2 or a Linux machine.\n\n**Custom location:** Set the `PFC_BINARY` environment variable:\n```bash\nexport PFC_BINARY=/opt/tools/pfc_jsonl\n```\n\nVerify:\n```bash\npfc_jsonl --help\n```\n\n---\n\n## API Reference\n\n### `pfc.compress(input_path, output_path, *, level=\"default\", block_size_mb=None, workers=None, verbose=False)`\n\nCompress a JSONL file to PFC format.\n\n```python\npfc.compress(\"logs/app.jsonl\", \"logs/app.pfc\")\npfc.compress(\"big.jsonl\", \"big.pfc\", level=\"max\", workers=4)\n```\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `level` | `\"default\"` | `\"fast\"`, `\"default\"`, or `\"max\"` (also accepts `1`-`5`) |\n| `block_size_mb` | auto | Block size in MiB (power of 2, e.g. 16, 32) |\n| `workers` | auto | Parallel compression workers |\n| `verbose` | `False` | Print progress from binary |\n\n---\n\n### `pfc.decompress(input_path, output_path=\"-\", *, verbose=False)`\n\nDecompress a PFC file back to JSONL.\n\n```python\npfc.decompress(\"logs/app.pfc\", \"logs/app_restored.jsonl\")\n```\n\n---\n\n### `pfc.query(pfc_path, from_ts, to_ts, output_path=\"-\")`\n\nDecompress only the blocks matching a timestamp range.\n\n```python\npfc.query(\"logs/app.pfc\",\n          from_ts=\"2026-01-15T08:00:00\",\n          to_ts=\"2026-01-15T09:00:00\",\n          output_path=\"logs/morning.jsonl\")\n```\n\nTimestamps can be ISO 8601 strings or Unix epoch integers (as strings).\n\n---\n\n### `pfc.seek_blocks(pfc_path, blocks, output_path=\"-\", *, verbose=False)`\n\nDecompress specific blocks by index. Used internally by the DuckDB extension.\n\n```python\npfc.seek_blocks(\"logs/app.pfc\", [0, 3, 7], \"logs/selected.jsonl\")\n```\n\n---\n\n---\n\n### `pfc.get_binary() -\u003e str`\n\nReturn the path to the `pfc_jsonl` binary being used.\n\n```python\nprint(pfc.get_binary())  # /usr/local/bin/pfc_jsonl\n```\n\n---\n\n---\n\n## Error Handling\n\n```python\nimport pfc\nfrom pfc import PFCError\n\ntry:\n    pfc.compress(\"missing.jsonl\", \"out.pfc\")\nexcept FileNotFoundError as e:\n    print(f\"Binary not found: {e}\")\nexcept PFCError as e:\n    print(f\"Compression failed (exit {e.returncode}): {e.stderr}\")\n```\n\n---\n\n## Integration with Fluent Bit\n\nUse [pfc-fluentbit](https://github.com/ImpossibleForge/pfc-fluentbit) to receive logs from Fluent Bit and compress them automatically.\n\n## Integration with DuckDB\n\nUse the [pfc DuckDB extension](https://github.com/ImpossibleForge/pfc-duckdb) to query `.pfc` files directly with SQL:\n\n```sql\nINSTALL pfc FROM community;\nLOAD pfc;\nLOAD json;\nSELECT line-\u003e\u003e'$.level' AS level, line-\u003e\u003e'$.message' AS msg\nFROM read_pfc_jsonl('logs/app.pfc')\nWHERE line-\u003e\u003e'$.level' = 'ERROR';\n```\n\n---\n\n\n## Related repos\n\n- [pfc-jsonl](https://github.com/ImpossibleForge/pfc-jsonl) — core binary (compress/decompress/query)\n- [pfc-gateway](https://github.com/ImpossibleForge/pfc-gateway) — HTTP REST gateway — ingest + query, no DuckDB\n- [pfc-fluentbit](https://github.com/ImpossibleForge/pfc-fluentbit) — live Fluent Bit → PFC pipeline\n- [pfc-vector](https://github.com/ImpossibleForge/pfc-vector) — high-performance Rust ingest daemon for Vector.dev and Telegraf\n- [pfc-migrate](https://github.com/ImpossibleForge/pfc-migrate) — one-shot export and archive conversion\n- [pfc-duckdb](https://github.com/ImpossibleForge/pfc-duckdb) — DuckDB extension for SQL queries on PFC files\n- [pfc-otel-collector](https://github.com/ImpossibleForge/pfc-otel-collector) — OpenTelemetry OTLP/HTTP log exporter\n- [pfc-kafka-consumer](https://github.com/ImpossibleForge/pfc-kafka-consumer) — Kafka / Redpanda consumer → PFC\n- [pfc-telegraf](https://github.com/ImpossibleForge/pfc-telegraf) — Telegraf HTTP output plugin → PFC\n- [pfc-grafana](https://github.com/ImpossibleForge/pfc-grafana) — Grafana data source plugin for PFC archives\n\n---\n\n## License\n\npfc-py (this repository) is released under the MIT License — see [LICENSE](LICENSE).\n\nThe PFC-JSONL binary (`pfc_jsonl`) is proprietary software — free for personal and open-source use. Commercial use requires a license: [info@impossibleforge.com](mailto:info@impossibleforge.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpossibleforge%2Fpfc-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimpossibleforge%2Fpfc-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpossibleforge%2Fpfc-py/lists"}