Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -69,7 +69,7 @@ public MutationsRejectedException(Instance instance, List<ConstraintViolationSum
+ " 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;
}
Expand All @@ -95,7 +95,7 @@ public MutationsRejectedException(AccumuloClient client, List<ConstraintViolatio
+ " 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void _startNewLocalityGroup(String name, Set<ByteSequence> columnFamilie
* @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));
}
Expand All @@ -147,7 +147,7 @@ public void startNewLocalityGroup(String name, byte[]... families) throws IOExce
* @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));
}
Expand All @@ -162,7 +162,7 @@ public void startNewLocalityGroup(String name, Set<String> families) throws IOEx
* @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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -214,8 +215,11 @@ public List<String> getManagerLocations() {

@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,11 +1217,11 @@ public Map<String,Set<Text>> getLocalityGroups(String tableName)

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()));
Expand Down Expand Up @@ -1291,7 +1291,7 @@ public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSpli

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));
}
Expand Down Expand Up @@ -1671,7 +1671,7 @@ public void importTable(String tableName, Set<String> importDirs, ImportConfigur
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public Condition setIterators(IteratorSetting... iterators) {
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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public void readFields(DataInput in) throws IOException {

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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<Short> check(Environment env, Mutation mutation) {

HashSet<String> ok = null;
if (updates.size() > 1) {
ok = new HashSet<>();
ok = new HashSet<>(updates.size());
}

VisibilityEvaluator ve = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> op
* @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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean i
if (columnFamilies instanceof Set<?>) {
colFamSet = (Set<ByteSequence>) columnFamilies;
} else {
colFamSet = new HashSet<>();
colFamSet.addAll(columnFamilies);
colFamSet = new HashSet<>(columnFamilies);
}

if (inclusive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,12 @@ public static TabletMetadata create(String id, String prevEndRow, String endRow)
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public static void checkLocalityGroups(Map<String,String> config)

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<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public static Optional<HostAndPort> findCompactionCoordinator(ClientContext cont
*/
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 {
Expand Down Expand Up @@ -254,16 +254,18 @@ public static List<RunningCompaction> getCompactionsRunningOnCompactors(ClientCo
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static Set<KeyExtent> decodeMigrations(DataInputStream input, int count) throws
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
Expand All @@ -142,8 +142,9 @@ private Set<TableId> parseTableIDs(String tableIDs) {
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;
Expand All @@ -154,9 +155,10 @@ private Set<TServerInstance> parseServers(String servers) {
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];
Expand All @@ -165,8 +167,9 @@ private Set<TServerInstance> parseServers(String servers) {
}
result.add(new TServerInstance(AddressUtil.parseAddress(hostport, false), instance));
}
return result;
}
return result;
return null;
}

private Map<TableId,MergeInfo> parseMerges(String merges) {
Expand Down
10 changes: 6 additions & 4 deletions server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ public Map<TableId,TableState> getTableIDs() throws InterruptedException {
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 + "/"
Expand Down Expand Up @@ -607,8 +608,9 @@ public Set<TableId> getCandidateTableIDs() throws InterruptedException {
} 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void removeCandidatesInUse(GarbageCollectionEnvironment gce,

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public List<TKeyExtent> bulkImport(TInfo tinfo, TCredentials credentials, final
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);
Expand Down Expand Up @@ -219,7 +219,7 @@ public void loadFiles(TInfo tinfo, TCredentials credentials, long tid, String di

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());
Expand Down Expand Up @@ -1209,7 +1209,9 @@ public void loadTablet(TInfo tinfo, TCredentials credentials, String lock,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public InitialScan startScan(TInfo tinfo, TCredentials credentials, KeyExtent ex
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));
}
Expand Down Expand Up @@ -356,7 +356,7 @@ public InitialMultiScan startMultiScan(TInfo tinfo, TCredentials credentials,
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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void run() {
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
Expand Down Expand Up @@ -446,7 +446,8 @@ public List<ActiveScan> getActiveScans() {

final List<ActiveScan> activeScans = new ArrayList<>();
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
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());
}
Expand Down Expand Up @@ -395,7 +395,7 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
}
}
// 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()));
Expand Down