Skip to content
swampusPublic

About

Experimental quantum database in Java and Qiskit: Grover search, reversible predicate oracles, circuit optimization, and interactive Aer simulation.

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Latest commit

ย 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PlankDB

Release Awesome

Experimental quantum-assisted key-value store and reversible oracle compiler โ€” Java, Spring Boot, Python, and Qiskit.

PlankDB combines a classical in-memory key-value API with Grover-based quantum search experiments. v0.2.0 adds an independent Quantum Oracle Index extension that compiles Boolean predicates directly into reversible phase-oracle circuits for local Qiskit Aer simulation, without first enumerating matching states. The existing Java, REST, and legacy LOCAL/IBM interfaces are preserved.

v0.2.0 Release ยท Run the Oracle Lab ยท Research documentation ยท Source and benchmarks

Quantum Oracle Index (v0.2.0)

The new execution path is Predicate AST โ†’ algebraic simplification โ†’ reversible phase oracle โ†’ Grover / Aer โ†’ classical verification. It supports EQUALS, BITMASK_EQUALS, AND, and OR over a bounded virtual integer register (2โ€“8 search qubits, up to 16 total qubits).

The compiler performs cost-guided circuit synthesis: it simplifies Boolean constraints, uses direct phase marking where appropriate, shares subexpressions in a reversible DAG, and rejects transformations estimated to increase CX-gate cost. Compound predicates use compute/phase/uncompute to restore work qubits. Reusable QPY circuit templates are cached with versioned identities, integrity checks, locking, and bounded resources.

Reproducible circuit optimization

For the reference predicate (x & 15) == 9 on 4 search qubits, 3 Grover iterations, 1,024 shots and seed 42 (Qiskit 1.1.1 / Aer 0.14.2, transpilation to u,cx, optimization level 1):

Transpiled metric Original compiler Cost-guided compiler Reduction
Oracle CX gates 72 14 80.6%
Full Grover CX gates 258 84 67.4%
Full Grover circuit depth 455 158 65.3%
Total / work qubits 5 / 1 4 / 0 1 fewer work qubit

The audit includes 906 Aer pipeline samples and 600 cache samples with recorded negative results and resource limits. These improvements are relative to PlankDB's own original compiler, not a comparison with state-of-the-art external oracle compilers. The ideal Grover success probability is unchanged. No robust end-to-end latency improvement or database speedup has been demonstrated.

Scope: Quantum Oracle Index operates on a virtual bit-vector domain, not stored database records or QRAM. The new extension runs on a local CPU simulator; real quantum hardware was not used to validate these results. General OR requires manually selected Grover iterations. The legacy RANGE correctness defect remains documented and unchanged.

Research & Technical Documentation

The implementation, mathematical assumptions, verification methodology, and reproducible measurements are documented separately:

Document What it contains
Mathematics and reversible compilation Phase-oracle equations, Boolean simplification, ancilla cleanup, cost-guided synthesis, and Grover iteration selection.
Optimization results Original vs optimized circuits, CX/depth measurements, timing breakdowns, and negative results.
Independent implementation audit Adversarial statevector checks, Boolean predicate equivalence, cache integrity, and remaining limitations. This is a software audit, not external peer review.
Architecture and API New execution path, domain/application/infrastructure/web boundaries, DSL, resource limits, and REST endpoints.
Reproducibility guide Docker, dependencies, test commands, seeds, and benchmark reproduction.
Original experiment record Historical pre-optimization baseline and initial local Aer results.
Raw benchmark evidence Machine-readable experimental results; also see pipeline CSV and cache CSV.
Release validation Executed Java/Python tests, Docker and HTTP smoke checks, repository hygiene, and known limitations.

The project demonstrates a bounded, cost-aware compilation strategy; it does not claim a new quantum algorithm or establish novelty over prior oracle synthesis research.

Try the Quantum Oracle Lab

Run the v0.2.0 demonstration with Docker (no IBM account, token, GPU, or paid quantum service required):

git clone https://github.com/swampus/plank-db.git
cd plank-db
cp .env.example .env
docker compose up --build -d

On PowerShell, use Copy-Item .env.example .env instead of cp. Do not overwrite an existing private .env or commit it. The supplied credential-free .env.example enables QUANTUM_ORACLE_ENABLED=true for the local demo.

Example query for 4 bits, mask 15, target 9:

curl -sS -X POST http://localhost:8085/api/rest/v1/oracle/search \
  -H 'Content-Type: application/json' \
  -d '{"width":4,"predicate":{"type":"BITMASK_EQUALS","mask":15,"value":9},"iterations":3,"shots":1024,"seed":42}'

Try iterations 0, 3, and 6 in the lab to see Grover amplitude amplification and overshooting. Simulation is probabilistic; the classical verifier independently checks measured states. The local Oracle feature is optional and disabled unless enabled in configuration. See the published v0.2.0 release and changelog for details.

Table of Contents


1. Introduction

PlankDB is an experimental quantum key-value database (search-oriented) implemented in Java, featuring a REST API for user interaction.

The main highlight of PlankDB is the integration of Java code with quantum search. When a search request is performed, PlankDB may invoke the Grover algorithm on a quantum emulator or on real quantum hardware (via IBM Qiskit Runtime).

PlankDB stores collections in a classical in-memory repository. Its legacy search ports can invoke Grover on encoded key sets; the Quantum Oracle Index provides a separate virtual bit-vector execution path. The project demonstrates these integrations without claiming to replace classical storage or its indexing costs.

๐Ÿ“Š Search Complexity Comparison

๐Ÿง  Search Method โฑ๏ธ Average Complexity
HashMap (key-based) O(1)
Classical linear search O(n)
Quantum search (Grover) O(โˆšn)

Thus, PlankDB demonstrates the properties and limitations of applying Grover's quantum search algorithm to unstructured data.

The quantum entry in this table describes idealized oracle-query complexity. It excludes oracle construction, data encoding/loading, classical simulation and process/transport overhead; it is not a measured database runtime comparison.

Additionally, PlankDB showcases how classical programming environments (such as Java) may interact with quantum computing systems. In the near future, we may expect a variety of integration scenarios:

  • Invoking quantum workloads through REST APIs in the cloud (as in this project);
  • Direct connections to on-premises quantum hardware;
  • Embedding provider-specific SDKs into mainstream languages (including JVM-based languages);
  • Transparent switching to quantum mode triggered by data scale or query complexity.

PlankDB represents a prototype for what practical quantum search integration could look like, and it provides a starting point for the broader discussion about future standards of interoperability between classical and quantum computing platforms.

2. Project Overview

Docker is the recommended local deployment. Java and Python tests have also been executed on the host; exact environments and executed checks are recorded in the reproduction and release-validation documents.

๐Ÿ”ง Quick Start with Docker

git clone https://github.com/swampus/plank-db.git
cd plank-db

cp .env.example .env
docker compose build
docker compose up

This will launch the service and expose the API on port 8085.

๐Ÿ” Alternatively, you can also use classic Docker CLI:

cp .env.example .env
docker build -t plankdb .
docker run --env-file .env -p 8085:8085 plankdb

๐Ÿ—‚๏ธ Repository Structure

  • web/ โ€“ Spring Boot REST API layer
  • application/ โ€“ business logic layer
  • domain/ โ€“ core interfaces and models
  • infrastructure/ โ€“ integration services and runners
  • python/ โ€“ Python scripts for both local simulation and IBM Quantum execution
    • grover.py, grover_range.py โ€“ for local backend
    • grover_ibm.py, grover_range_ibm.py โ€“ for IBM Quantum

๐Ÿ’ก Local Usage (not officially tested)

To run PlankDB locally:

  • Ensure you have Java 17+ and Python 3.10+ installed
  • Install Qiskit in a virtual environment
  • Run backend scripts from scripts/ folder manually if needed
  • Edit application.yml for local configuration
  • Launch via mvn spring-boot:run

Note: Quantum integration is triggered through subprocess-based execution of Qiskit scripts, and may require additional setup.

๐ŸŒ Cloud Execution (IBM Qiskit Runtime)

PlankDB supports execution on IBM's real quantum devices via IBM Quantum Runtime. To use this mode:

  1. Register at: https://quantum.ibm.com
  2. Generate your API token in your account settings
  3. Enable billing with a credit card (for real-device access)
  4. Set the following environment variables (or use the provided .env file):
export QUANTUM_EXECUTION_MODE=IBM
export QUANTUM_IBM_TOKEN=your_ibm_token

These variables allow switching between local simulation and IBM Quantum cloud execution. The values will be used automatically if placed in a .env file in the project root.

๐Ÿ”— REST API and Swagger UI

PlankDB exposes a RESTful HTTP API available on port 8085. For full interactive documentation and testing, use the Swagger UI:

โžก๏ธ http://localhost:8085/swagger-ui.html

Key endpoints include:

  • POST /collections/{collection}/put โ€” insert a key-value pair
  • GET /collections/{collection}/search/{key} โ€” perform Grover-based quantum search

Each endpoint is documented in the Swagger UI, including:

  • request/response examples
  • quantum-specific result fields like confidence_score or execution_time_ms
  • descriptions of fallback behavior if quantum execution is unavailable

This API is suitable for both classical usage and quantum-enabled applications.

3. Project Run

๐Ÿ›  Requirements

To build and run PlankDB locally, you need the following installed:

  • Java 17
  • Apache Maven โ€“ used for project compilation
  • (Optional) make โ€“ used as a shortcut for build commands

Note: make build wraps mvn clean package -DskipTests; use mvn clean test to execute tests. The legacy Makefile has IBM-oriented environment defaults; use the LOCAL Docker setup above for the Oracle Lab.


๐Ÿณ Recommended: Run via Docker Compose

PlankDB is designed to run smoothly with Docker Desktop and docker compose.

To get started:

docker compose up --build

The project targets Java 17, which Docker builds and runs. Host tests were also executed with Java 21 using release=17; this is not a compatibility claim for every newer JDK.

Once running, the API will be available at:
๐Ÿ‘‰ http://localhost:8085/swagger-ui/index.html

For consistent behavior across platforms, we highly recommend using Docker Desktop โ€” it's free for personal and small business use.

๐Ÿ” Note: On the first attempt, docker compose up --build may fail due to Qiskit or network dependency issues.
Simply rerunning the command usually resolves it.


๐Ÿ’ก Local Usage (Not Officially Supported)

Local setup is possible but not officially supported or guaranteed to work reliably, due to differences in operating systems, Python environments, and quantum library configurations.

However, for users who wish to run PlankDB outside of Docker, here are the recommended steps:

๐Ÿ”ง Step-by-step instructions:

  1. Install Java 17

    • Recommended via Adoptium
    • Verify with: java -version
  2. Install Apache Maven

  3. Clone the repository

    git clone https://github.com/swampus/plank-db.git
    cd plank-db
  4. Build the project using Maven

    mvn clean package
  5. Run the application

    java -jar web/target/plank-db.jar

๐Ÿงช Quantum Execution Requirements (Optional but needed for full features)

To enable Grover-based quantum search locally:

  1. Install Python 3.10+ and create a virtual environment

    python -m venv .venv
    source .venv/bin/activate  # or .venv\Scripts\activate on Windows
  2. Install Qiskit and dependencies

    pip install -r requirements.txt
  3. Set environment variables

    • Export variables into the host process environment; Spring does not automatically load the Docker .env file for a host-launched JAR:
      QUANTUM_EXECUTION_MODE=LOCAL
  4. Configure application settings

    • Host execution needs the interpreter/script paths described in reproducibility. Configuration is in web/src/main/resources/application.yml.

โš ๏ธ Note: On some systems, Python subprocess handling or Qiskit versions may cause errors. This mode is best suited for development, debugging, or integration experimentation.

For most users, Docker remains the strongly preferred method for stability and reproducibility.

4. Quickstart: Explain Quantum Plan (REST)

The Explain Quantum Plan endpoint builds a Grover search plan (key or range) and, for the local backend (Aer), performs a simulator dry-run to return measurement probabilities. On IBM, it returns the plan only (no dry-run) to keep the response fast and deterministic.

Swagger UI: http://localhost:8085/swagger-ui.html A sample collection test is auto-created on startup with keys k1..k4.

Run the service

docker build -t plankdb:latest .
docker run --rm -p 8085:8085 --env-file .env plankdb:latest

Example requests

KEY (local, with dry-run)

curl -s -X POST http://localhost:8085/api/rest/v1/collections/test/explain   -H 'Content-Type: application/json'   -d '{
        "mode": "KEY",
        "key": "k2",
        "backend": "local",
        "strategy": "AUTO",
        "shots": 512,
        "seed": 42
      }' | jq .

RANGE (local, with dry-run)

curl -s -X POST http://localhost:8085/api/rest/v1/collections/test/explain   -H 'Content-Type: application/json'   -d '{
        "mode": "RANGE",
        "fromKey": "k2",
        "toKey": "k4",
        "backend": "local",
        "strategy": "AUTO"
      }' | jq .

IBM (plan only, no dry-run)

curl -s -X POST http://localhost:8085/api/rest/v1/collections/test/explain   -H 'Content-Type: application/json'   -d '{"mode":"KEY","key":"k3","backend":"ibm"}' | jq .

โš™๏ธ Configuration

PlankDB can be configured via environment variables (recommended) or JVM props. We ship a template: .env.example โ€” copy it to .env and tweak values:

cp .env.example .env

PlankDB reads its config from environment variables. Template: .env.example.

Variable Default Description
SERVER_PORT 8085 HTTP port
SPRING_PROFILES_ACTIVE default Spring profile (default, dev, prod)
LOG_LEVEL INFO Root logging level
QUANTUM_EXECUTION_MODE LOCAL LOCAL (Aer) or IBM / IBM_REAL_PC
QUANTUM_PYTHON_EXEC /opt/venv/bin/python Python interpreter for Qiskit scripts
QUANTUM_EXPLAIN_SHOTS 2048 Default shots for Explain dry-run
QUANTUM_EXPLAIN_SEED 42 Default simulator seed
IBM_QUANTUM_API_TOKEN โ€“ (IBM only) API token
IBM_QUANTUM_BACKEND โ€“ (IBM only) e.g. ibm_nairobi

.env.example (snippet):

SERVER_PORT=8085
SPRING_PROFILES_ACTIVE=default
LOG_LEVEL=INFO

QUANTUM_EXECUTION_MODE=LOCAL
QUANTUM_PYTHON_EXEC=/opt/venv/bin/python
QUANTUM_EXPLAIN_SHOTS=2048
QUANTUM_EXPLAIN_SEED=42

# IBM (optional)
# IBM_QUANTUM_API_TOKEN=
# IBM_QUANTUM_BACKEND=ibm_nairobi

5. API Reference

POST /api/rest/v1/collections/{collection}/explain

Builds an explainable Grover plan.

  • If backend=local, also runs a simulator dry-run (Aer) and returns probabilities.
  • If backend=ibm, returns plan only; dryRun is null.

Request (JSON)

{
  "mode": "KEY | RANGE",
  "key": "k2",
  "fromKey": "k2",
  "toKey": "k4",
  "backend": "local | ibm",
  "strategy": "AUTO | FIXED",
  "iterations": 2,
  "shots": 2048,
  "seed": 42
}

Fields

  • mode (required): KEY or RANGE.
  • key: required when mode=KEY.
  • fromKey, toKey: optional bounds when mode=RANGE (lexicographic).
  • backend: local (default) or ibm.
  • strategy: AUTO (default) computes floor(ฯ€/4 * sqrt(N/M)); FIXED uses iterations.
  • iterations: used only when strategy=FIXED (min 1).
  • shots, seed: optional simulator parameters for local dry-run.

Response (JSON)

{
  "plan": {
    "mode": "KEY",
    "targetLabel": "k2",
    "encodingMap": { "k1": "00", "k2": "01", "k3": "10", "k4": "11" },
    "markedStates": ["01"],
    "estimatedM": 1,
    "collectionSizeN": 4,
    "numQubits": 2,
    "optimalIterations": 1,
    "iterationsUsed": 1,
    "oracleExpression": "(x01)",
    "estimatedOracleDepth": 4,
    "estimatedGateCounts": { "h": 4, "x": 2, "mcx": 1 },
    "backend": {
      "name": "local/aer_simulator",
      "shots": 512,
      "seed": 42,
      "noiseModel": false
    },
    "notes": [
      "Grover ~โˆš(N/M); AUTO uses floor(ฯ€/4 * sqrt(N/M)).",
      "Diffusion amplifies the marked states after the oracle phase flip.",
      "Depth/gate counts are coarse estimates; actual values depend on oracle synthesis."
    ]
  },
  "dryRun": {
    "topMeasurement": "01",
    "probabilities": { "01": 0.86, "11": 0.14 },
    "confidenceScore": 0.86,
    "executionTimeMs": 12
  }
}

On IBM, dryRun is null.

Error responses

  • 400 โ€” invalid input (e.g., missing mode/key, malformed range)
  • 404 โ€” collection/key/range not found
  • 502 โ€” simulator/backend error during dry-run

Notes

  • Encoding is lexicographic over the current set of keys; changing keys changes the encodingMap.
  • optimalIterations depends on collection size N and number of marked states M.
  • Dry-run probabilities are stochastic; use seed for reproducibility.

6. Architecture and Code Structure

PlankDB follows the principles of Clean Architecture, promoting clear separation of concerns and independence between layers. This structure improves testability, modularity, and long-term maintainability โ€” essential qualities for both experimental and production-grade systems.

๐Ÿงฑ Package Structure Overview

The project is organized into the following core packages:

  • domain/
    Defines core domain interfaces and abstract models.
    It is independent of frameworks and contains no external dependencies.

  • application/
    Contains use cases that encapsulate the business logic of the system.
    These use cases coordinate domain interfaces and serve as the heart of the application logic.

  • infrastructure/
    Implements interaction with external systems such as Python quantum scripts, file runners, and environment configuration.
    This layer acts as the adapter between the core logic and the outside world.

  • web/
    Provides the REST API using Spring Boot.
    It exposes endpoints for interacting with collections, performing quantum and range queries, and integrates with the application layer via dependency injection.

  • python/
    Contains executable Python scripts that implement Groverโ€™s algorithm for both local and IBM Quantum backends.
    These scripts are invoked by the infrastructure layer and return quantum search results back to the application.

๐Ÿงฉ Why Clean Architecture?

This approach is chosen because it:

  • Enables isolated testing of logic without reliance on HTTP or Python dependencies
  • Makes it easy to swap or extend quantum execution backends (e.g., simulator vs. real hardware)
  • Encourages long-term separation of interface and implementation
  • Supports both demonstration and research-level experimentation

The modular layout ensures that PlankDB remains flexible and maintainable, even as quantum technologies evolve.

๐Ÿง  Dependency Inversion in Practice

PlankDB adheres to the Dependency Inversion Principle (DIP) โ€” a core part of Clean Architecture โ€” by organizing dependencies around abstractions:

  • The application/ and domain/ layers depend only on interfaces, never on concrete implementations.
  • Quantum execution interfaces are declared in the domain layer, while real implementations (e.g. Python script runners) reside in infrastructure/.
  • The REST API in web/ interacts only with the application layer, unaware of how quantum execution is actually performed.

This design makes it easy to:

  • Swap quantum backends (e.g., switch from local simulation to IBM hardware)
  • Test the application logic in isolation (using mocks or stubs)
  • Maintain long-term separation between business logic and technical concerns

By inverting dependencies and structuring around use cases, PlankDB remains flexible, extendable, and robust against changes in technology or platform.

7. Quantum Search Theory and Practice

๐Ÿ“˜ Expand subsections

7.1 Quantum Superposition: The Theoretical Basis

At the heart of quantum computing lies the concept of superposition โ€” a fundamental difference from classical computation.

In classical systems, a bit can be either 0 or 1.
In quantum systems, a qubit can be in a superposition of both |0โŸฉ and |1โŸฉ states simultaneously:

|ฯˆโŸฉ = ฮฑ|0โŸฉ + ฮฒ|1โŸฉ

Where:

  • ฮฑ and ฮฒ are complex amplitudes,
  • |ฮฑ|ยฒ + |ฮฒ|ยฒ = 1,
  • The square of the amplitude gives the probability of observing that state upon measurement.

When you measure the qubit, the superposition collapses into either 0 or 1 โ€” but until measurement, the system evolves as a combination of both.

In multi-qubit systems, superposition enables a system of n qubits to represent 2โฟ possible states simultaneously.
This exponential parallelism is what makes quantum algorithms โ€” like Groverโ€™s โ€” so powerful.

For example, with 5 qubits we can simultaneously explore 32 different states.

This is not parallel computing in the classical sense โ€” rather, itโ€™s a probabilistic amplitude evolution governed by linear algebra over Hilbert space.

In PlankDB, this principle is simulated by running Groverโ€™s algorithm over a space of binary-encoded keys.
Each possible key is mapped to a quantum state in superposition, and the oracle function is used to mark the correct state, increasing its measurement probability.


7.2 Grover's Algorithm Explained

Grover's algorithm allows searching an unsorted list of N items in approximately โˆšN steps โ€” a quadratic speedup over classical search.

Key steps:

  1. Initialization โ€” Create an equal superposition over all states
  2. Oracle โ€” Mark the correct state by inverting its amplitude
  3. Diffusion operator โ€” Reflect the state vector around the average
  4. Repeat โ€” Run this process โˆšN times

The amplitude of the marked state increases with each iteration.
After a few iterations, a measurement is likely to return the correct state.

This algorithm is implemented using Qiskit circuits โ€” either locally (Aer simulator) or remotely (IBM Quantum Runtime).


7.3 How PlankDB Uses Grover

In PlankDB, both search and range operations rely on Grover's algorithm:

  • A collection of keys is loaded into a Python script and encoded as binary
  • An oracle circuit is constructed based on the key or range condition
  • Grover's algorithm is run to amplify the matching state
  • The result is decoded and returned to the Java API

This is not efficient for production โ€” O(n) time to prepare the state โ€” but is ideal for demonstration purposes.


7.4 Probabilistic Nature of Quantum Results

Quantum search results are inherently probabilistic โ€” a correct answer is likely, but not guaranteed.

PlankDB returns a rich result object:

{
  "quantum_result": {
    "matched_key": "0101",
    "matched_value": "example",
    "matched_index": 5,
    "top_measurement": "0101",
    "oracle_expression": "key == 0101",
    "num_qubits": 4,
    "confidence_score": 0.91,
    "execution_time_ms": 84,
    "oracle_depth": 8,
    "iterations": 3
  },
  "scientific_notes": {
    "principle": "Grover amplification",
    "theory": "oracle-based selection in Hilbert space",
    "circuit_behavior": "amplitude modulation",
    "confidence_interpretation": "non-deterministic probability outcome",
    "qubit_commentary": "n qubits encode 2^n states",
    "encoding_map": {
      "0000": "a",
      "0001": "b"
    },
    "used_iterations": 3
  }
}

This DTO (QuantumResultDTO) includes both raw results and scientific context for interpretability.


7.5 When Will Quantum Search Matter?

Grover's algorithm provides meaningful advantage when:

  • The dataset is large (thousands to millions of records)
  • Search is performed repeatedly over static data
  • Quantum memory (QRAM) becomes practical

Today, these conditions are not met โ€” data loading is classical and overhead is high.

However, PlankDB provides a useful demonstration of how such systems could work โ€” and what real-world Javaโ€“quantum integration might eventually look like.


7.6 DTO Breakdown and References

๐Ÿ“˜ QuantumResultDTO: Structure Explanation

Field Description
matched_key The key found by quantum search (in binary or text form)
matched_value The value associated with that key
matched_index Index in the list of all inputs
top_measurement Most frequently observed measurement state
oracle_expression Oracle logic used in Grover (e.g., "key == 1010")
num_qubits Number of qubits used for the search
confidence_score Probability of correctness (0.0 โ€“ 1.0)
execution_time_ms Time spent in script execution
oracle_depth Logical circuit depth of the oracle
iterations Number of Grover iterations performed

And:

Field (scientific_notes) Description
principle Algorithmic principle (e.g., Grover amplification)
theory Scientific explanation (e.g., amplitude evolution)
circuit_behavior Summary of what the circuit does
confidence_interpretation Notes on how to interpret probabilistic output
qubit_commentary Explanation of how the number of qubits relates to space
encoding_map Mapping of binary strings to original keys
used_iterations How many iterations were used in this run

๐Ÿง  Visualizing the Grover Circuit

q_0: โ€”โ€”โ€”Hโ€”โ€”โ€”โ—โ€”โ€”โ€”โ€”Xโ€”โ€”โ€”Hโ€”โ€”โ€”M
             |        |
q_1: โ€”โ€”โ€”Hโ€”โ€”โ€”โ—โ€”โ€”โ€”โ€”Xโ€”โ€”โ€”Hโ€”โ€”โ€”M
        Oracle   Diffusion
  • H: Hadamard gate (superposition)
  • โ—: Controlled oracle marking
  • X + H: Inversion around average (diffusion)
  • M: Measurement

๐Ÿ“š References and Scientific Background

7.7 Explain Quantum Plan: Why and How

What the plan contains ๐Ÿ“ฆ
The Explain endpoint returns a deterministic description of a Grover search before (and optionally alongside) any execution:

  • Lexicographic encodingMap (key โ†’ fixed-width bitstring) ๐Ÿ—บ๏ธ
  • markedStates (bitstrings for the key/range) ๐ŸŽฏ
  • numQubits ๐Ÿ”ข and human-readable oracleExpression ๐Ÿงพ
  • optimalIterations k โ‰ˆ floor(ฯ€/4 ยท โˆš(N/M)) (AUTO) or user-provided FIXED value ๐Ÿงญ
  • Coarse gate/depth estimates (heuristics) ๐Ÿ“
  • Backend metadata (local Aer vs. IBM Runtime) ๐Ÿงฉ

Why itโ€™s useful ๐Ÿ’ก

  • Makes the algorithm transparent (what is encoded, what is marked, how many iterations) ๐Ÿ”ฆ
  • Ensures reproducibility (same inputs โ†’ same plan) ๐Ÿ”
  • Enables fast local validation via dry-run (Aer) to visualize probability amplification ๐Ÿ“Š

How to read the dry-run ๐Ÿงช

  • topMeasurement โ€” most probable bitstring; confidenceScore โ€” its probability โœ…
  • With multiple marked states (range), probability mass splits across them โ†”๏ธ
  • Under-rotation (too few iterations) โ†’ flatter histogram; over-rotation can shift mass away โ€” expected in Grover ๐Ÿ”„

Oracle notes ๐Ÿงฐ
Bitstrings are marked by a phase oracle (multi-controlled Z) synthesized as H โ€ข MCX โ€ข H on the last qubit, with X pre/post around zero-bits to match the pattern. Depth and gate counts depend on decomposition (device topology, transpiler), so estimates are intentionally coarse.

Limitations โš ๏ธ

  • Building the encodingMap is classical O(N) ๐Ÿข
  • Gate/depth metrics are heuristics; real circuits vary with synthesis ๐Ÿงฎ
  • Dry-run is local and noise-free; on IBM the endpoint returns plan only to avoid queue time and hardware noise ๐Ÿšซ๐Ÿ›ฐ๏ธ

8. Limitations and Practical Considerations

While PlankDB demonstrates the principles of quantum search in a practical Java-based application, it is subject to several real-world limitations that must be considered.

๐Ÿšง Not Production-Ready

  • PlankDB is a prototype โ€” designed for learning, demonstration, and experimentation
  • The system is not optimized for performance or concurrency
  • It does not persist data beyond runtime (in-memory only)
  • No authentication, rate limiting, or production deployment support is included

๐ŸŒ Classical Bottlenecks

Although Groverโ€™s algorithm runs in O(โˆšn) time, preparing the data for quantum execution still requires:

  • O(n) time to load the collection into memory
  • Binary encoding and serialization of keys to pass to the Python script
  • Subprocess overhead for spawning Python (especially on Windows) These factors negate the quantum speedup for small or medium-sized datasets.

๐Ÿง  Quantum Hardware Constraints

  • IBM Quantum has limited availability, even with billing
  • Circuit depth, qubit decoherence, and queue time significantly affect results
  • Noise can corrupt outputs unless error mitigation is applied For these reasons, PlankDB primarily runs on local simulation (Qiskit Aer) during development.

๐Ÿ”ฌ Probabilistic Output and Confidence

Quantum results are non-deterministic:

  • A query may return the wrong key with small probability
  • The legacy confidence_score reports a measurement-derived score, not a calibrated probability that the returned answer is correct
  • Repeated runs improve reliability but increase cost on real quantum hardware

๐Ÿ“Š Search Suitability Criteria

An ideal Grover oracle-query advantage depends on efficient oracle access; it is not an observed PlankDB database speedup:

Factor Classical Search Quantum Grover
Large unstructured spaces with efficient oracle access Classical cost depends on the chosen index and data layout Ideal Grover uses O(โˆšN) oracle queries, excluding preparation and execution overhead
Small collections Usually very fast Simulator and circuit overhead generally dominate
Repeated queries on static data Classical indexes can be reused Reusing compiled oracle templates saves compilation work, not quantum execution cost
Fast, deterministic responses Usually preferable Sampling and external execution add latency and uncertainty

๐Ÿงญ Future Outlook

As quantum hardware matures and QRAM becomes available, systems like PlankDB could:

  • Eliminate the O(n) classical loading bottleneck
  • Perform batch queries and filtering entirely in quantum space
  • Integrate deeper with Java or Kotlin through native quantum SDKs

Until then, PlankDB remains a valuable educational and architectural prototype for quantum-enhanced search systems.

9. License

This project is licensed under the MIT License โ€” a permissive open-source license.

You are free to use, modify, and distribute the code for both commercial and non-commercial purposes, provided that the original copyright notice is included.

๐Ÿ“˜ Full license text is available at:
โžก๏ธ LICENSE

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

If youโ€™d like to help improve PlankDB:

  1. Fork the repository
  2. Create a new branch
    git checkout -b feature/your-feature

About

Experimental quantum database in Java and Qiskit: Grover search, reversible predicate oracles, circuit optimization, and interactive Aer simulation.

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages