AMashenkov commented on code in PR #1385:
URL: https://github.com/apache/ignite-3/pull/1385#discussion_r1037139038
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -495,32 +592,17 @@ static Map<String, String>
collectDataStorageNames(Set<String> dataStorages) {
return
dataStorages.stream().collect(toUnmodifiableMap(String::toUpperCase,
identity()));
}
- /**
- * Collects a mapping of the ID of the table option to a table option info.
- *
- * <p>Example for "replicas": {@code Map.of("REPLICAS",
TableOptionInfo@123)}.
- *
- * @param tableOptionInfos Table option information's.
- * @throws IllegalStateException If there is a duplicate ID.
- */
- static Map<String, TableOptionInfo<?>>
collectTableOptionInfos(TableOptionInfo<?>... tableOptionInfos) {
- return ArrayUtils.nullOrEmpty(tableOptionInfos) ? Map.of() :
Stream.of(tableOptionInfos).collect(toUnmodifiableMap(
- tableOptionInfo -> tableOptionInfo.name.toUpperCase(),
- identity()
- ));
- }
-
/**
* Checks that there are no ID duplicates.
*
- * @param tableOptionInfos0 Table options information.
- * @param tableOptionInfos1 Table options information.
+ * @param set0 Set of string identifiers.
+ * @param set1 Set of string identifiers.
* @throws IllegalStateException If there is a duplicate ID.
*/
- static void checkDuplicates(Map<String, TableOptionInfo<?>>
tableOptionInfos0, Map<String, TableOptionInfo<?>> tableOptionInfos1) {
- for (String id : tableOptionInfos1.keySet()) {
- if (tableOptionInfos0.containsKey(id)) {
- throw new IllegalStateException("Duplicate id:" + id);
+ static void checkDuplicates(Set<String> set0, Set<String> set1) {
+ for (String id : set1) {
+ if (set0.contains(id)) {
+ throw new IllegalStateException("Duplicate id: " + id);
}
}
Review Comment:
```suggestion
if (Collections.disjoint(set0, set1)) {
throw new IllegalStateException("Duplicate id: " + id);
}
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -495,32 +592,17 @@ static Map<String, String>
collectDataStorageNames(Set<String> dataStorages) {
return
dataStorages.stream().collect(toUnmodifiableMap(String::toUpperCase,
identity()));
}
- /**
- * Collects a mapping of the ID of the table option to a table option info.
- *
- * <p>Example for "replicas": {@code Map.of("REPLICAS",
TableOptionInfo@123)}.
- *
- * @param tableOptionInfos Table option information's.
- * @throws IllegalStateException If there is a duplicate ID.
- */
- static Map<String, TableOptionInfo<?>>
collectTableOptionInfos(TableOptionInfo<?>... tableOptionInfos) {
- return ArrayUtils.nullOrEmpty(tableOptionInfos) ? Map.of() :
Stream.of(tableOptionInfos).collect(toUnmodifiableMap(
- tableOptionInfo -> tableOptionInfo.name.toUpperCase(),
- identity()
- ));
- }
-
/**
* Checks that there are no ID duplicates.
*
- * @param tableOptionInfos0 Table options information.
- * @param tableOptionInfos1 Table options information.
+ * @param set0 Set of string identifiers.
+ * @param set1 Set of string identifiers.
* @throws IllegalStateException If there is a duplicate ID.
*/
- static void checkDuplicates(Map<String, TableOptionInfo<?>>
tableOptionInfos0, Map<String, TableOptionInfo<?>> tableOptionInfos1) {
- for (String id : tableOptionInfos1.keySet()) {
- if (tableOptionInfos0.containsKey(id)) {
- throw new IllegalStateException("Duplicate id:" + id);
+ static void checkDuplicates(Set<String> set0, Set<String> set1) {
+ for (String id : set1) {
+ if (set0.contains(id)) {
+ throw new IllegalStateException("Duplicate id: " + id);
}
}
Review Comment:
```suggestion
if (!Collections.disjoint(set0, set1)) {
throw new IllegalStateException("Duplicate id: " + id);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]