You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/02/03 15:19:27 UTC
[shardingsphere] branch master updated: Remove @beta usage (#23983)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 75968f636b2 Remove @beta usage (#23983)
75968f636b2 is described below
commit 75968f636b2418156cf63641b07515203c659bf9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Feb 3 23:19:17 2023 +0800
Remove @beta usage (#23983)
---
.../sharding/range/BoundaryBasedRangeShardingAlgorithm.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
index 3d3409c6e26..ab3d287a66c 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.base.Splitter;
import com.google.common.collect.Range;
-import com.google.common.primitives.Longs;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
@@ -40,8 +39,8 @@ public final class BoundaryBasedRangeShardingAlgorithm extends AbstractRangeShar
@Override
public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final Properties props) {
ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding ranges cannot be null."));
- List<Long> partitionRanges = Splitter.on(",").trimResults().splitToList(props.getProperty(SHARDING_RANGES_KEY))
- .stream().map(Longs::tryParse).filter(Objects::nonNull).sorted().collect(Collectors.toList());
+ List<Long> partitionRanges = Splitter.on(",").trimResults().splitToList(props.getProperty(SHARDING_RANGES_KEY)).stream()
+ .map(this::parseLong).filter(Objects::nonNull).sorted().collect(Collectors.toList());
ShardingSpherePreconditions.checkState(!partitionRanges.isEmpty(), () -> new ShardingAlgorithmInitializationException(getType(), "Sharding ranges can not be empty."));
Map<Integer, Range<Comparable<?>>> result = new HashMap<>(partitionRanges.size() + 1, 1);
for (int i = 0; i < partitionRanges.size(); i++) {
@@ -59,6 +58,14 @@ public final class BoundaryBasedRangeShardingAlgorithm extends AbstractRangeShar
return result;
}
+ private Long parseLong(final String value) {
+ try {
+ return Long.parseLong(value);
+ } catch (final NumberFormatException ex) {
+ return null;
+ }
+ }
+
@Override
public String getType() {
return "BOUNDARY_RANGE";