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 ShadowAlgorithm SPI

From Leeroopedia


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

Overview

SPI marker interface for shadow algorithm implementations in the ShardingSphere shadow testing framework.

Description

ShadowAlgorithm is the root interface in the shadow algorithm SPI hierarchy. It extends ShardingSphereAlgorithm and serves as the base type that all shadow algorithm implementations must implement. Concrete sub-interfaces include ColumnShadowAlgorithm for column-value-based routing and HintShadowAlgorithm for SQL-hint-based routing.

Usage

Implement this interface (via its sub-interfaces) when creating custom shadow routing algorithms that determine whether SQL statements should be routed to shadow data sources during testing.

Code Reference

Source Location

Signature

public interface ShadowAlgorithm extends ShardingSphereAlgorithm {
}

Import

import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;

I/O Contract

Inputs

Name Type Required Description
(none) Marker interface with no direct inputs

Outputs

Name Type Description
(none) Marker interface; sub-interfaces define concrete contracts

Usage Examples

// Custom shadow algorithm implementation via sub-interface
public final class MyShadowAlgorithm implements ColumnShadowAlgorithm<String> {

    @Override
    public boolean isShadow(final Collection<String> shadowTableNames, final PreciseColumnShadowValue<String> shadowValue) {
        return "shadow".equals(shadowValue.getValue());
    }

    @Override
    public String getShadowColumn() {
        return "shadow_flag";
    }

    @Override
    public ShadowOperationType getShadowOperationType() {
        return ShadowOperationType.INSERT;
    }

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

Related Pages

Page Connections

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