This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new de83b942f0 Set initial capacity on HashSet/HashMap when known (#6451)
de83b942f0 is described below
commit de83b942f03200f58c1a9bd359401f0247c78061
Author: Dave Marion <[email protected]>
AuthorDate: Tue Jul 7 11:25:51 2026 -0400
Set initial capacity on HashSet/HashMap when known (#6451)
---
.../accumulo/core/client/MutationsRejectedException.java | 6 +++---
.../apache/accumulo/core/client/rfile/RFileWriter.java | 6 +++---
.../accumulo/core/clientImpl/InstanceOperationsImpl.java | 8 ++++++--
.../accumulo/core/clientImpl/TableOperationsImpl.java | 8 ++++----
.../java/org/apache/accumulo/core/data/Condition.java | 4 ++--
.../main/java/org/apache/accumulo/core/data/Mutation.java | 2 +-
.../core/data/constraints/VisibilityConstraint.java | 2 +-
.../java/org/apache/accumulo/core/file/rfile/RFile.java | 2 +-
.../system/ColumnFamilySkippingIterator.java | 3 +--
.../accumulo/core/metadata/schema/TabletMetadata.java | 5 +++--
.../org/apache/accumulo/core/util/LocalityGroupUtil.java | 2 +-
.../core/util/compaction/ExternalCompactionUtil.java | 10 ++++++----
.../server/manager/state/TabletStateChangeIterator.java | 15 +++++++++------
server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java | 10 ++++++----
.../apache/accumulo/gc/GarbageCollectionAlgorithm.java | 2 +-
.../org/apache/accumulo/tserver/TabletClientHandler.java | 8 +++++---
.../apache/accumulo/tserver/ThriftScanClientHandler.java | 4 ++--
.../apache/accumulo/tserver/session/SessionManager.java | 5 +++--
.../apache/accumulo/tserver/tablet/CompactableUtils.java | 2 +-
.../java/org/apache/accumulo/tserver/tablet/Tablet.java | 4 ++--
20 files changed, 61 insertions(+), 47 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
index f34761576b..a12f9a3bd8 100644
---
a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
+++
b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
@@ -43,7 +43,7 @@ public class MutationsRejectedException extends
AccumuloException {
private static final long serialVersionUID = 1L;
private final ArrayList<ConstraintViolationSummary> cvsl = new ArrayList<>();
- private final HashMap<TabletId,Set<SecurityErrorCode>> af = new HashMap<>();
+ private final HashMap<TabletId,Set<SecurityErrorCode>> af;
private final HashSet<String> es = new HashSet<>();
private final int unknownErrors;
@@ -69,7 +69,7 @@ public class MutationsRejectedException extends
AccumuloException {
+ " security codes: " + hashMap.toString() + " # server errors " +
serverSideErrors.size()
+ " # exceptions " + unknownErrors, cause);
this.cvsl.addAll(cvsList);
- this.af.putAll(hashMap);
+ this.af = new HashMap<>(hashMap);
this.es.addAll(serverSideErrors);
this.unknownErrors = unknownErrors;
}
@@ -95,7 +95,7 @@ public class MutationsRejectedException extends
AccumuloException {
+ " security codes: " + format(hashMap, (ClientContext) client) + "
# server errors "
+ serverSideErrors.size() + " # exceptions " + unknownErrors, cause);
this.cvsl.addAll(cvsList);
- this.af.putAll(hashMap);
+ this.af = new HashMap<>(hashMap);
this.es.addAll(serverSideErrors);
this.unknownErrors = unknownErrors;
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
index ffa43e3bc4..a8e98481ee 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
@@ -123,7 +123,7 @@ public class RFileWriter implements AutoCloseable {
* @throws IllegalStateException When default locality group already started.
*/
public void startNewLocalityGroup(String name, List<byte[]> families) throws
IOException {
- HashSet<ByteSequence> fams = new HashSet<>();
+ HashSet<ByteSequence> fams = new HashSet<>(families.size(), 1.0f);
for (byte[] family : families) {
fams.add(new ArrayByteSequence(family));
}
@@ -147,7 +147,7 @@ public class RFileWriter implements AutoCloseable {
* @throws IllegalStateException When default locality group already started.
*/
public void startNewLocalityGroup(String name, Set<String> families) throws
IOException {
- HashSet<ByteSequence> fams = new HashSet<>();
+ HashSet<ByteSequence> fams = new HashSet<>(families.size(), 1.0f);
for (String family : families) {
fams.add(new ArrayByteSequence(family));
}
@@ -162,7 +162,7 @@ public class RFileWriter implements AutoCloseable {
* @throws IllegalStateException When default locality group already started.
*/
public void startNewLocalityGroup(String name, String... families) throws
IOException {
- HashSet<ByteSequence> fams = new HashSet<>();
+ HashSet<ByteSequence> fams = new HashSet<>(families.length, 1.0f);
for (String family : families) {
fams.add(new ArrayByteSequence(family));
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
b/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
index e21b7357a8..e30128d0eb 100644
---
a/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
+++
b/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
@@ -31,6 +31,7 @@ import static
org.apache.accumulo.core.rpc.ThriftUtil.returnClient;
import static
org.apache.accumulo.core.util.threads.ThreadPoolNames.INSTANCE_OPS_COMPACTIONS_FINDER_POOL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
@@ -215,8 +216,11 @@ public class InstanceOperationsImpl implements
InstanceOperations {
@Override
public Set<String> getCompactors() {
- Set<String> compactors = new HashSet<>();
- ExternalCompactionUtil.getCompactorAddrs(context).values().forEach(addrs
-> {
+ Collection<List<HostAndPort>> compactorGroups =
+ ExternalCompactionUtil.getCompactorAddrs(context).values();
+ Set<String> compactors =
+ new HashSet<>(compactorGroups.stream().mapToInt(List::size).sum(),
1.0f);
+ compactorGroups.forEach(addrs -> {
addrs.forEach(hp -> compactors.add(hp.toString()));
});
return compactors;
diff --git
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
index ee12b6ebab..e905e62271 100644
---
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
+++
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
@@ -1219,11 +1219,11 @@ public class TableOperationsImpl extends
TableOperationsHelper {
AccumuloConfiguration conf = new
ConfigurationCopy(this.getProperties(tableName));
Map<String,Set<ByteSequence>> groups =
LocalityGroupUtil.getLocalityGroups(conf);
- Map<String,Set<Text>> groups2 = new HashMap<>();
+ Map<String,Set<Text>> groups2 = new HashMap<>(groups.size(), 1.0f);
for (Entry<String,Set<ByteSequence>> entry : groups.entrySet()) {
- HashSet<Text> colFams = new HashSet<>();
+ HashSet<Text> colFams = new HashSet<>(entry.getValue().size(), 1.0f);
for (ByteSequence bs : entry.getValue()) {
colFams.add(new Text(bs.toArray()));
@@ -1293,7 +1293,7 @@ public class TableOperationsImpl extends
TableOperationsHelper {
mergedExtents.addAll(unmergedExtents);
- Set<Range> ranges = new HashSet<>();
+ Set<Range> ranges = new HashSet<>(mergedExtents.size(), 1.0f);
for (KeyExtent k : mergedExtents) {
ranges.add(k.toDataRange().clip(range));
}
@@ -1673,7 +1673,7 @@ public class TableOperationsImpl extends
TableOperationsHelper {
boolean keepOffline = ic.isKeepOffline();
boolean keepMapping = ic.isKeepMappings();
- Set<String> checkedImportDirs = new HashSet<>();
+ Set<String> checkedImportDirs = new HashSet<>(importDirs.size(), 1.0f);
try {
for (String s : importDirs) {
checkedImportDirs.add(checkPath(s, "Table", "").toString());
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Condition.java
b/core/src/main/java/org/apache/accumulo/core/data/Condition.java
index f1b6e13fb6..59c5668fcf 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Condition.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Condition.java
@@ -256,8 +256,8 @@ public class Condition {
checkArgument(iterators != null, "iterators is null");
if (iterators.length > 1) {
- HashSet<String> names = new HashSet<>();
- HashSet<Integer> prios = new HashSet<>();
+ HashSet<String> names = new HashSet<>(iterators.length, 1.0f);
+ HashSet<Integer> prios = new HashSet<>(iterators.length, 1.0f);
for (IteratorSetting iteratorSetting : iterators) {
if (!names.add(iteratorSetting.getName())) {
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
b/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
index 25393a51bb..95ee6f4120 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
@@ -1454,7 +1454,7 @@ public class Mutation implements Writable {
if ((first & 0x02) == 0x02) {
int numMutations = WritableUtils.readVInt(in);
- this.replicationSources = new HashSet<>();
+ this.replicationSources = new HashSet<>(numMutations, 1.0f);
for (int i = 0; i < numMutations; i++) {
replicationSources.add(WritableUtils.readString(in));
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/data/constraints/VisibilityConstraint.java
b/core/src/main/java/org/apache/accumulo/core/data/constraints/VisibilityConstraint.java
index c413600d5b..e814782f2e 100644
---
a/core/src/main/java/org/apache/accumulo/core/data/constraints/VisibilityConstraint.java
+++
b/core/src/main/java/org/apache/accumulo/core/data/constraints/VisibilityConstraint.java
@@ -64,7 +64,7 @@ public class VisibilityConstraint implements Constraint {
HashSet<String> ok = null;
if (updates.size() > 1) {
- ok = new HashSet<>();
+ ok = new HashSet<>(updates.size());
}
VisibilityEvaluator ve = null;
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
index 9e2d4633c2..0e941129b8 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
@@ -1449,7 +1449,7 @@ public class RFile {
* @see LocalityGroupUtil#seek(FileSKVIterator, Range, String, Map)
*/
public Map<String,ArrayList<ByteSequence>> getLocalityGroupCF() {
- Map<String,ArrayList<ByteSequence>> cf = new HashMap<>();
+ Map<String,ArrayList<ByteSequence>> cf = new
HashMap<>(localityGroups.size(), 1.0f);
for (LocalityGroupMetadata lcg : localityGroups) {
ArrayList<ByteSequence> setCF;
diff --git
a/core/src/main/java/org/apache/accumulo/core/iteratorsImpl/system/ColumnFamilySkippingIterator.java
b/core/src/main/java/org/apache/accumulo/core/iteratorsImpl/system/ColumnFamilySkippingIterator.java
index 3745bf0fc3..ae26b0dd81 100644
---
a/core/src/main/java/org/apache/accumulo/core/iteratorsImpl/system/ColumnFamilySkippingIterator.java
+++
b/core/src/main/java/org/apache/accumulo/core/iteratorsImpl/system/ColumnFamilySkippingIterator.java
@@ -117,8 +117,7 @@ public class ColumnFamilySkippingIterator extends
ServerSkippingIterator
if (columnFamilies instanceof Set<?>) {
colFamSet = (Set<ByteSequence>) columnFamilies;
} else {
- colFamSet = new HashSet<>();
- colFamSet.addAll(columnFamilies);
+ colFamSet = new HashSet<>(columnFamilies);
}
if (inclusive) {
diff --git
a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java
index c3c5f27485..dd11a95df8 100644
---
a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java
+++
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java
@@ -535,11 +535,12 @@ public class TabletMetadata {
* pulled from org.apache.accumulo.server.manager.LiveTServerSet
*/
public static synchronized Set<TServerInstance>
getLiveTServers(ClientContext context) {
- final Set<TServerInstance> liveServers = new HashSet<>();
final String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
+ final List<String> children = context.getZooCache().getChildren(path);
+ final Set<TServerInstance> liveServers = new HashSet<>(children.size());
- for (String child : context.getZooCache().getChildren(path)) {
+ for (String child : children) {
checkServer(context, path, child).ifPresent(liveServers::add);
}
log.trace("Found {} live tservers at ZK path: {}", liveServers.size(),
path);
diff --git
a/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
b/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
index 4fdb0b6003..f6d2535ed3 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
@@ -111,8 +111,8 @@ public class LocalityGroupUtil {
public static Map<String,Set<ByteSequence>>
getLocalityGroups(AccumuloConfiguration acuconf)
throws LocalityGroupConfigurationException {
- Map<String,Set<ByteSequence>> result = new HashMap<>();
String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(",");
+ Map<String,Set<ByteSequence>> result = new HashMap<>(groups.length);
for (String group : groups) {
if (!group.isEmpty()) {
result.put(group, new HashSet<>());
diff --git
a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
index db6f4ac15a..c6be864ce8 100644
---
a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
+++
b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java
@@ -116,10 +116,10 @@ public class ExternalCompactionUtil {
*/
public static Map<String,List<HostAndPort>> getCompactorAddrs(ClientContext
context) {
try {
- final Map<String,List<HostAndPort>> queuesAndAddresses = new HashMap<>();
final String compactorQueuesPath = context.getZooKeeperRoot() +
Constants.ZCOMPACTORS;
ZooReader zooReader = context.getZooReader();
List<String> queues = zooReader.getChildren(compactorQueuesPath);
+ final Map<String,List<HostAndPort>> queuesAndAddresses = new
HashMap<>(queues.size(), 1.0f);
for (String queue : queues) {
queuesAndAddresses.putIfAbsent(queue, new ArrayList<>());
try {
@@ -257,16 +257,18 @@ public class ExternalCompactionUtil {
getCompactionIdsRunningOnCompactors(ClientContext context) {
final ExecutorService executor = ThreadPools.getServerThreadPools()
.getPoolBuilder(COMPACTOR_RUNNING_COMPACTION_IDS_POOL).numCoreThreads(16).build();
- List<Future<ExternalCompactionId>> futures = new ArrayList<>();
- getCompactorAddrs(context).forEach((q, hp) -> {
+ var compactors = getCompactorAddrs(context);
+ List<Future<ExternalCompactionId>> futures = new
ArrayList<>(compactors.size());
+
+ compactors.forEach((q, hp) -> {
hp.forEach(hostAndPort -> {
futures.add(executor.submit(() -> getRunningCompactionId(hostAndPort,
context)));
});
});
executor.shutdown();
- HashSet<ExternalCompactionId> runningIds = new HashSet<>();
+ HashSet<ExternalCompactionId> runningIds = new HashSet<>(compactors.size()
/ 4);
futures.forEach(future -> {
try {
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletStateChangeIterator.java
b/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletStateChangeIterator.java
index a14e78af05..bf5af33b46 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletStateChangeIterator.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletStateChangeIterator.java
@@ -129,7 +129,7 @@ public class TabletStateChangeIterator extends
SkippingIterator {
if (input == null) {
return Collections.emptySet();
}
- Set<KeyExtent> result = new HashSet<>();
+ Set<KeyExtent> result = new HashSet<>(count, 1.0f);
for (int i = 0; i < count; i++) {
// need a count and cannot use InputStream.available() because its
behavior is not reliable
// across InputStream impls
@@ -142,8 +142,9 @@ public class TabletStateChangeIterator extends
SkippingIterator {
if (tableIDs == null) {
return null;
}
- Set<TableId> result = new HashSet<>();
- for (String tableID : tableIDs.split(",")) {
+ String[] ids = tableIDs.split(",");
+ Set<TableId> result = new HashSet<>(ids.length, 1.0f);
+ for (String tableID : ids) {
result.add(TableId.of(tableID));
}
return result;
@@ -154,9 +155,10 @@ public class TabletStateChangeIterator extends
SkippingIterator {
return null;
}
// parse "host:port[INSTANCE]"
- Set<TServerInstance> result = new HashSet<>();
if (!servers.isEmpty()) {
- for (String part : servers.split(",")) {
+ String[] s = servers.split(",");
+ Set<TServerInstance> result = new HashSet<>(s.length, 1.0f);
+ for (String part : s) {
String[] parts = part.split("\\[", 2);
String hostport = parts[0];
String instance = parts[1];
@@ -165,8 +167,9 @@ public class TabletStateChangeIterator extends
SkippingIterator {
}
result.add(new TServerInstance(AddressUtil.parseAddress(hostport,
false), instance));
}
+ return result;
}
- return result;
+ return null;
}
private Map<TableId,MergeInfo> parseMerges(String merges) {
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index bc1062224a..cbd968245e 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -244,8 +244,9 @@ public class GCRun implements GarbageCollectionEnvironment {
while (retries <= 10) {
try {
zr.sync(tablesPath);
- final Map<TableId,TableState> tids = new HashMap<>();
- for (String table : zr.getChildren(tablesPath)) {
+ var tables = zr.getChildren(tablesPath);
+ final Map<TableId,TableState> tids = new HashMap<>(tables.size(),
1.0f);
+ for (String table : tables) {
TableId tableId = TableId.of(table);
TableState tableState = null;
String statePath = context.getZooKeeperRoot() + Constants.ZTABLES +
"/"
@@ -608,8 +609,9 @@ public class GCRun implements GarbageCollectionEnvironment {
} else if (level == DataLevel.METADATA) {
return Set.of(MetadataTable.ID);
} else if (level == DataLevel.USER) {
- Set<TableId> tableIds = new HashSet<>();
- getTableIDs().forEach((k, v) -> {
+ var tids = getTableIDs();
+ Set<TableId> tableIds = new HashSet<>(tids.size(), 1.0f);
+ tids.forEach((k, v) -> {
if (v == TableState.ONLINE || v == TableState.OFFLINE) {
// Don't return tables that are NEW, DELETING, or in an
// UNKNOWN state.
diff --git
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
index 50b4a9f1c3..1d5863ca9e 100644
---
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
+++
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
@@ -145,7 +145,7 @@ public class GarbageCollectionAlgorithm {
List<GcCandidate> candidateEntriesToBeDeleted = new ArrayList<>();
Set<TableId> tableIdsBefore = gce.getCandidateTableIDs();
- Set<TableId> tableIdsSeen = new HashSet<>();
+ Set<TableId> tableIdsSeen = new HashSet<>(tableIdsBefore.size());
Iterator<Reference> iter = gce.getReferences().iterator();
while (iter.hasNext()) {
Reference ref = iter.next();
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
index 3644f6146c..608291db7a 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
@@ -177,7 +177,7 @@ public class TabletClientHandler implements
TabletClientService.Iface {
for (Entry<TKeyExtent,Map<String,MapFileInfo>> entry :
files.entrySet()) {
TKeyExtent tke = entry.getKey();
Map<String,MapFileInfo> fileMap = entry.getValue();
- Map<TabletFile,MapFileInfo> fileRefMap = new HashMap<>();
+ Map<TabletFile,MapFileInfo> fileRefMap = new
HashMap<>(fileMap.size(), 1.0f);
for (Entry<String,MapFileInfo> mapping : fileMap.entrySet()) {
Path path = new Path(mapping.getKey());
FileSystem ns =
context.getVolumeManager().getFileSystemByPath(path);
@@ -219,7 +219,7 @@ public class TabletClientHandler implements
TabletClientService.Iface {
watcher.runQuietly(Constants.BULK_ARBITRATOR_TYPE, tid, () -> {
tabletImports.forEach((tke, fileMap) -> {
- Map<TabletFile,MapFileInfo> newFileMap = new HashMap<>();
+ Map<TabletFile,MapFileInfo> newFileMap = new HashMap<>(fileMap.size(),
1.0f);
for (Entry<String,MapFileInfo> mapping : fileMap.entrySet()) {
Path path = new Path(dir, mapping.getKey());
@@ -1209,7 +1209,9 @@ public class TabletClientHandler implements
TabletClientService.Iface {
Set<KeyExtent> onlineOverlapping =
KeyExtent.findOverlapping(extent, server.getOnlineTablets());
- Set<KeyExtent> all = new HashSet<>();
+ Set<KeyExtent> all = new HashSet<>(
+ unopenedOverlapping.size() + openingOverlapping.size() +
onlineOverlapping.size(),
+ 1.0f);
all.addAll(unopenedOverlapping);
all.addAll(openingOverlapping);
all.addAll(onlineOverlapping);
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java
index e0a54c8374..1b3284036b 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftScanClientHandler.java
@@ -200,7 +200,7 @@ public class ThriftScanClientHandler implements
TabletScanClientService.Iface {
throw new NotServingTabletException(extent.toThrift());
}
- HashSet<Column> columnSet = new HashSet<>();
+ HashSet<Column> columnSet = new HashSet<>(columns.size(), 1.0f);
for (TColumn tcolumn : columns) {
columnSet.add(new Column(tcolumn));
}
@@ -356,7 +356,7 @@ public class ThriftScanClientHandler implements
TabletScanClientService.Iface {
Map<String,String> executionHints, long busyTimeout)
throws ThriftSecurityException, TSampleNotPresentException,
ScanServerBusyException {
- final Map<KeyExtent,List<TRange>> batch = new HashMap<>();
+ final Map<KeyExtent,List<TRange>> batch = new HashMap<>(tbatch.size(),
1.0f);
tbatch.forEach((k, v) -> {
batch.put(KeyExtent.fromThrift(k), v);
});
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java
index 830ab48749..1cee93e79a 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java
@@ -407,7 +407,7 @@ public class SessionManager {
public Map<TableId,MapCounter<ScanRunState>> getActiveScansPerTable() {
Map<TableId,MapCounter<ScanRunState>> counts = new HashMap<>();
- Set<Entry<Long,Session>> copiedIdleSessions = new HashSet<>();
+ Set<Entry<Long,Session>> copiedIdleSessions = new
HashSet<>(deferredCleanupQueue.size(), 1.0f);
/**
* Add sessions so that get the list returned in the active scans call
@@ -448,7 +448,8 @@ public class SessionManager {
final List<ActiveScan> activeScans =
new ArrayList<>(sessions.size() + deferredCleanupQueue.size());
final long ct = System.currentTimeMillis();
- final Set<Entry<Long,Session>> copiedIdleSessions = new HashSet<>();
+ final Set<Entry<Long,Session>> copiedIdleSessions =
+ new HashSet<>(deferredCleanupQueue.size(), 1.0f);
/**
* Add sessions that get the list returned in the active scans call
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableUtils.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableUtils.java
index d332050aab..0ef01a1883 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableUtils.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableUtils.java
@@ -112,7 +112,7 @@ public class CompactableUtils {
public static Map<StoredTabletFile,Pair<Key,Key>> getFirstAndLastKeys(Tablet
tablet,
Set<StoredTabletFile> allFiles) throws IOException {
- final Map<StoredTabletFile,Pair<Key,Key>> result = new HashMap<>();
+ final Map<StoredTabletFile,Pair<Key,Key>> result = new
HashMap<>(allFiles.size(), 1.0f);
final FileOperations fileFactory = FileOperations.getInstance();
final VolumeManager fs = tablet.getTabletServer().getVolumeManager();
final TableConfiguration tableConf = tablet.getTableConfiguration();
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 54877265cc..63b3d95866 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -341,7 +341,7 @@ public class Tablet extends TabletBase {
final AtomicLong maxTime = new AtomicLong(Long.MIN_VALUE);
final CommitSession commitSession = getTabletMemory().getCommitSession();
try {
- Set<String> absPaths = new HashSet<>();
+ Set<String> absPaths = new HashSet<>(datafiles.size());
for (TabletFile ref : datafiles.keySet()) {
absPaths.add(ref.getPathStr());
}
@@ -395,7 +395,7 @@ public class Tablet extends TabletBase {
}
}
// make some closed references that represent the recovered logs
- currentLogs = new HashSet<>();
+ currentLogs = new HashSet<>(logEntries.size(), 1.0f);
for (LogEntry logEntry : logEntries) {
currentLogs.add(new DfsLogger(tabletServer.getContext(),
tabletServer.getServerConfig(),
logEntry.filename, logEntry.getColumnQualifier().toString()));