Skip to content

Commit

Permalink
Add AlgorithmMetaDataQueryResultRows
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 19, 2023
1 parent eaa1126 commit 4787ac0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

package org.apache.shardingsphere.distsql.handler.ral.query.algorithm;

import org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithm;
import org.apache.shardingsphere.infra.database.core.spi.DatabaseSupportedTypedSPI;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.annotation.SPIDescription;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;

import java.util.Collection;
import java.util.stream.Collectors;
Expand All @@ -42,14 +42,14 @@ public final class AlgorithmMetaDataQueryResultRow {

private final String description;

public AlgorithmMetaDataQueryResultRow(final TypedSPI typedSPI) {
containsDatabaseTypes = typedSPI instanceof DatabaseSupportedTypedSPI;
type = String.valueOf(typedSPI.getType());
typeAliases = typedSPI.getTypeAliases().stream().map(Object::toString).collect(Collectors.joining(","));
public AlgorithmMetaDataQueryResultRow(final ShardingSphereAlgorithm algorithm) {
containsDatabaseTypes = algorithm instanceof DatabaseSupportedTypedSPI;
type = String.valueOf(algorithm.getType());
typeAliases = algorithm.getTypeAliases().stream().map(Object::toString).collect(Collectors.joining(","));
supportedDatabaseTypes = containsDatabaseTypes
? getSupportedDatabaseTypes(((DatabaseSupportedTypedSPI) typedSPI).getSupportedDatabaseTypes()).stream().map(DatabaseType::getType).collect(Collectors.joining(","))
? getSupportedDatabaseTypes(((DatabaseSupportedTypedSPI) algorithm).getSupportedDatabaseTypes()).stream().map(DatabaseType::getType).collect(Collectors.joining(","))
: "";
SPIDescription description = typedSPI.getClass().getAnnotation(SPIDescription.class);
SPIDescription description = algorithm.getClass().getAnnotation(SPIDescription.class);
this.description = null == description ? "" : description.value();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.shardingsphere.distsql.handler.ral.query.algorithm;

import org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithm;
import org.apache.shardingsphere.infra.database.core.spi.DatabaseSupportedTypedSPI;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -35,9 +35,9 @@ public final class AlgorithmMetaDataQueryResultRows {

private final Collection<AlgorithmMetaDataQueryResultRow> rows;

public AlgorithmMetaDataQueryResultRows(final Class<? extends TypedSPI> typedSPIClass) {
containsDatabaseTypes = DatabaseSupportedTypedSPI.class.isAssignableFrom(typedSPIClass);
rows = ShardingSphereServiceLoader.getServiceInstances(typedSPIClass).stream().map(AlgorithmMetaDataQueryResultRow::new).collect(Collectors.toList());
public AlgorithmMetaDataQueryResultRows(final Class<? extends ShardingSphereAlgorithm> algorithmClass) {
containsDatabaseTypes = DatabaseSupportedTypedSPI.class.isAssignableFrom(algorithmClass);
rows = ShardingSphereServiceLoader.getServiceInstances(algorithmClass).stream().map(AlgorithmMetaDataQueryResultRow::new).collect(Collectors.toList());
}

/**
Expand Down

0 comments on commit 4787ac0

Please sign in to comment.