busbey commented on a change in pull request #2985: URL: https://github.com/apache/hadoop/pull/2985#discussion_r629418343
########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/nonguava/Sets.java ########## @@ -0,0 +1,258 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.util.nonguava; + +import org.apache.hadoop.classification.InterfaceAudience; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Static utility methods pertaining to {@link Set} instances. This class is + * Hadoop's internal utility and replacement of + * org.apache.hadoop.thirdparty.com.google.common.collect.Sets. Review comment: If we're going to refer to the class from Guava we should do so with something like "This class is Hadoop's internal use alternative to Guava's Sets utility class." rather than referring to the relocated version of that class that we used previously. ########## File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java ########## @@ -659,7 +660,7 @@ public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) { // storage directory with ancient logs. Clear out any logs we've // accumulated so far, and then skip to the next segment of logs // after the gap. - SortedSet<Long> startTxIds = Sets.newTreeSet(logsByStartTxId.keySet()); + SortedSet<Long> startTxIds = new TreeSet<>(logsByStartTxId.keySet()); Review comment: looks like there are a few of these. Is there a particular reason we're skipping `Sets.newTreeSet`? It feels odd to implement `differenceInTreeSets` but not a wrapped tree set creation. ########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java ########## @@ -262,20 +263,24 @@ private static void loadData() throws Exception { event54.setTimestamp(cTime); entity5.addEvent(event54); Map<String, Set<String>> isRelatedTo1 = new HashMap<String, Set<String>>(); - isRelatedTo1.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - isRelatedTo1.put("type4", Sets.newHashSet("entity41", "entity42")); - isRelatedTo1.put("type1", Sets.newHashSet("entity14", "entity15")); - isRelatedTo1.put("type3", - Sets.newHashSet("entity31", "entity35", "entity32", "entity33")); + isRelatedTo1.put("type2", new HashSet<>(Arrays.asList("entity21", "entity22", + "entity23", "entity24"))); + isRelatedTo1.put("type4", new HashSet<>(Arrays.asList("entity41", + "entity42"))); + isRelatedTo1.put("type1", new HashSet<>(Arrays.asList("entity14", + "entity15"))); + isRelatedTo1.put("type3", new HashSet<>(Arrays.asList("entity31", + "entity35", "entity32", "entity33"))); entity5.addIsRelatedToEntities(isRelatedTo1); Map<String, Set<String>> relatesTo1 = new HashMap<String, Set<String>>(); - relatesTo1.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - relatesTo1.put("type4", Sets.newHashSet("entity41", "entity42")); - relatesTo1.put("type1", Sets.newHashSet("entity14", "entity15")); - relatesTo1.put("type3", - Sets.newHashSet("entity31", "entity35", "entity32", "entity33")); + relatesTo1.put("type2", new HashSet<>(Arrays.asList("entity21", + "entity22", "entity23", "entity24"))); + relatesTo1.put("type4", new HashSet<>(Arrays.asList("entity41", + "entity42"))); + relatesTo1.put("type1", new HashSet<>(Arrays.asList("entity14", + "entity15"))); + relatesTo1.put("type3", new HashSet<>(Arrays.asList("entity31", + "entity35", "entity32", "entity33"))); Review comment: why not use the `Sets.newHashSet(E element...)` method here? ########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/nonguava/Sets.java ########## @@ -0,0 +1,258 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.util.nonguava; Review comment: Can we put this in `org.apache.hadoop.util` instead of referencing a thirdparty in the package? Doing so also avoids us needing a `package-info.java` for the new package. ########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java ########## @@ -262,20 +263,24 @@ private static void loadData() throws Exception { event54.setTimestamp(cTime); entity5.addEvent(event54); Map<String, Set<String>> isRelatedTo1 = new HashMap<String, Set<String>>(); - isRelatedTo1.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - isRelatedTo1.put("type4", Sets.newHashSet("entity41", "entity42")); - isRelatedTo1.put("type1", Sets.newHashSet("entity14", "entity15")); - isRelatedTo1.put("type3", - Sets.newHashSet("entity31", "entity35", "entity32", "entity33")); + isRelatedTo1.put("type2", new HashSet<>(Arrays.asList("entity21", "entity22", + "entity23", "entity24"))); + isRelatedTo1.put("type4", new HashSet<>(Arrays.asList("entity41", + "entity42"))); + isRelatedTo1.put("type1", new HashSet<>(Arrays.asList("entity14", + "entity15"))); + isRelatedTo1.put("type3", new HashSet<>(Arrays.asList("entity31", + "entity35", "entity32", "entity33"))); Review comment: why not use the `Sets.newHashSet(E element...)` method here? ########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java ########## @@ -323,18 +328,25 @@ private static void loadData() throws Exception { event64.setTimestamp(cTime); entity6.addEvent(event64); Map<String, Set<String>> isRelatedTo2 = new HashMap<String, Set<String>>(); - isRelatedTo2.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - isRelatedTo2.put("type5", Sets.newHashSet("entity51", "entity52")); - isRelatedTo2.put("type6", Sets.newHashSet("entity61", "entity66")); - isRelatedTo2.put("type3", Sets.newHashSet("entity31")); + isRelatedTo2.put("type2", new HashSet<>(Arrays.asList("entity21", + "entity22", "entity23", "entity24"))); + isRelatedTo2.put("type5", new HashSet<>(Arrays.asList("entity51", + "entity52"))); + isRelatedTo2.put("type6", new HashSet<>(Arrays.asList("entity61", + "entity66"))); + isRelatedTo2.put("type3", + new HashSet<>(Collections.singletonList("entity31"))); Review comment: why not use the `Sets.newHashSet(E element...)` method here? ########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java ########## @@ -323,18 +328,25 @@ private static void loadData() throws Exception { event64.setTimestamp(cTime); entity6.addEvent(event64); Map<String, Set<String>> isRelatedTo2 = new HashMap<String, Set<String>>(); - isRelatedTo2.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - isRelatedTo2.put("type5", Sets.newHashSet("entity51", "entity52")); - isRelatedTo2.put("type6", Sets.newHashSet("entity61", "entity66")); - isRelatedTo2.put("type3", Sets.newHashSet("entity31")); + isRelatedTo2.put("type2", new HashSet<>(Arrays.asList("entity21", + "entity22", "entity23", "entity24"))); + isRelatedTo2.put("type5", new HashSet<>(Arrays.asList("entity51", + "entity52"))); + isRelatedTo2.put("type6", new HashSet<>(Arrays.asList("entity61", + "entity66"))); + isRelatedTo2.put("type3", + new HashSet<>(Collections.singletonList("entity31"))); entity6.addIsRelatedToEntities(isRelatedTo2); Map<String, Set<String>> relatesTo2 = new HashMap<String, Set<String>>(); relatesTo2.put("type2", - Sets.newHashSet("entity21", "entity22", "entity23", "entity24")); - relatesTo2.put("type5", Sets.newHashSet("entity51", "entity52")); - relatesTo2.put("type6", Sets.newHashSet("entity61", "entity66")); - relatesTo2.put("type3", Sets.newHashSet("entity31")); + new HashSet<>(Arrays.asList("entity21", "entity22", "entity23", + "entity24"))); + relatesTo2.put("type5", new HashSet<>(Arrays.asList("entity51", + "entity52"))); + relatesTo2.put("type6", new HashSet<>(Arrays.asList("entity61", + "entity66"))); + relatesTo2.put("type3", + new HashSet<>(Collections.singletonList("entity31"))); Review comment: why not use the `Sets.newHashSet(E element...)` method here? -- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
