Skip to content

pg_morlet

Transactional waveform storage and exact Morlet-feature similarity search

pg_morlet · Transactional waveform storage and exact Morlet-feature similarity search

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102281pg_morletpg_morlet0.3.20TIMEApache-2.0Rust

PostgreSQL · 17, 18, 19

Usage

Sources:

pg_morlet 0.3.20 stores waveforms and compares compatible windows with versioned Morlet features. The exact v0.4.0-beta.9 source tag contains this control/SQL version. PostgreSQL 17 is the reference platform; 18 and final 19.0 have functional CI coverage. This remains an experimental extension using pgrx 0.19.3.

CREATE EXTENSION pg_morlet;
SELECT morlet_create_stream_collection('public', 'signals');
SELECT morlet_enable_acquisitions('signals'::regclass);
SELECT morlet_create_acquisition('signals'::regclass, 'run-001', 'motor-1');

Acquisitions align channels on an integer nanosecond timeline with declared offsets, clock source and uncertainty. morlet_build_acquisition_segments, morlet_read_acquisition and morlet_compare_acquisition expose the new aligned workflow. The versioned SQL script defines the acquisition setup and signatures; comparisons additionally require populated recordings and built context segments. It does not resample channels or estimate their clock offsets.

Consistency and access

Ingestion and feature publication remain transactional. Caller privileges and row-security policies apply to collection tables; direct edits can break cross-table invariants. Searches compare only compatible rates, channels, units, windows and extractor versions. Similarity scores are investigation signals, not calibrated probabilities.

Continuous recordings and maintenance

The current workflow uses morlet_start_recording, morlet_append_chunk / morlet_append_chunks, morlet_read_interval and morlet_search_interval. Interval reads reconstruct chunks under caller privileges; incompatible or partly hidden intervals fail explicitly. Optional envelope probes require vector; ordinary storage and exact search do not.

The supplied SQL chain advances 0.3.12 through 0.3.20. It adds time anchors, stream-specific latest reads and match explanations, and fixes time mapping and time-anchor deletion after dump/restore. Install matching library and SQL files before updating:

ALTER EXTENSION pg_morlet UPDATE TO '0.3.20';

The current tag supplies a versioned upgrade chain. Upstream tests cover older alpha upgrades on PostgreSQL 17; 18/19 use fresh installations. Some README paragraphs still describe an obsolete 0.1.0 scaffold with no upgrade path; use the actual control, SQL chain and compatibility document for this revision. Preserve recordings and backups; do not drop a populated extension to follow the old walkthrough.

Interpretation and Calibration

SQL 0.3.17 adds opt-in interpretation history. morlet_enable_interpretation enables a collection’s history; morlet_correct_interpretation changes the recorded unit or metadata.calibration atomically without rewriting samples. morlet_interpretation_review identifies labels needing review. Once enabled, direct edits of those fields require a matching revision.

Experimental calibration sets keep drafts and approved immutable revisions separately. Approval requires a separate role, and writes require REPEATABLE READ or SERIALIZABLE. As-of selection and derived feature profiles are not implemented. Existing collections retain their prior behavior until explicitly enabled.

The export and copy tools refuse selections containing corrected recordings, or history the caller cannot read: they cannot yet carry interpretation history. Preserve the database and its backups instead of assuming an ordinary sample export preserves corrections.

SQL 0.3.18 binds calibration evidence to the original recording, not a reusable ID. Deleting a recording permanently cuts its reference; a later recording with the same ID cannot reveal its old evidence under row security. After the upgrade, grant writers INSERT and readers SELECT on each <collection>_calibration_refs table. Interpretation revisions are omitted or reported unknown when the caller cannot read the complete history; missing evidence does not mean the interpretation stayed unchanged. Sample-to-time mapping now reads adjacent anchors by index without rebuilding a recording’s entire time axis.

Spectral Analysis

SQL 0.3.19 adds morlet_spectrum, morlet_spectrogram, morlet_interval_indicators and morlet_envelope_spectrum. These compute from raw interval reads and inherit their caller privileges, row security, coverage and interpretation checks. They do not silently use derived similarity features as raw samples.

A spectrum accepts at most 4,194,304 samples per interval and 67,108,864 transformed samples per call. A spectrogram allows 268,435,456 transformed samples overall, still at most 67,108,864 per column; each column spans at most 4,194,304 input samples. Adjust segmentation and output limits explicitly instead of assuming arbitrary-size FFT work. Envelope spectra additionally require valid frequency-band choices. The 0.3.18-to-0.3.19 upgrade only adds functions; it does not rewrite stored sample chunks.

Beta Operating Limits

The 0.4.0-beta.9 distribution uses SQL version 0.3.20 and keeps the sample chunk format unchanged. morlet_latest still returns a row for each matching recording; morlet_latest_per_stream selects the newest recording per declared stream. The earlier sustained-ingest trial failed steady-operation and search goals. Subsequent scheduling and latest-read fixes do not constitute a successful confirmation trial. Monitor envelope/verification backlog and validate recovery and query latency on the intended workload.

SQL 0.3.20 Boundary Fixes

This upgrade replaces three functions without rewriting sample chunks or tables. Synchronous append rejects arrays whose lower bound is not 1; timestamp arithmetic widens intermediate values to avoid overflow; spectrogram PSD reduction normalizes by the bin factor and rejects invalid intervals. Quote a named SQL window argument with double quotes. Existing spectral-size, privilege and beta-validation limits remain.

Table reader