Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Shardingsphere HintShadowAlgorithm SPI

From Leeroopedia


Knowledge Sources
Domains Shadow_Testing, SPI, SQL_Routing
Last Updated 2026-02-10 00:00 GMT

Overview

SPI interface for hint-based shadow routing algorithms.

Description

HintShadowAlgorithm<T> is a generic interface extending ShadowAlgorithm that defines the contract for shadow algorithms based on SQL hints rather than column values. Implementors determine shadow routing by examining hint annotations attached to SQL statements.

Usage

Implement this interface when creating shadow algorithms that use SQL hint annotations (e.g., /* shadow:true */ comments) rather than column values for routing decisions.

Code Reference

Source Location

Signature

public interface HintShadowAlgorithm<T> extends ShadowAlgorithm {

    boolean isShadow(Collection<String> shadowTableNames, PreciseHintShadowValue<T> shadowValue);
}

Import

import org.apache.shardingsphere.shadow.spi.hint.HintShadowAlgorithm;

I/O Contract

Inputs

Name Type Required Description
shadowTableNames Collection<String> Yes Names of configured shadow tables
shadowValue PreciseHintShadowValue<T> Yes Hint value context including table name, operation type, and hint value

Outputs

Name Type Description
isShadow() returns boolean True if the statement should route to shadow data source

Usage Examples

import org.apache.shardingsphere.shadow.spi.hint.HintShadowAlgorithm;
import org.apache.shardingsphere.shadow.spi.hint.PreciseHintShadowValue;

public final class SQLHintShadowAlgorithm implements HintShadowAlgorithm<String> {

    @Override
    public boolean isShadow(final Collection<String> shadowTableNames,
                            final PreciseHintShadowValue<String> shadowValue) {
        return "true".equalsIgnoreCase(shadowValue.getValue());
    }

    @Override
    public String getType() {
        return "SQL_HINT";
    }
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment