Skip to content

Commit

Permalink
[core] Fixing squid:S1319 - Declarations should use Java collection i…
Browse files Browse the repository at this point in the history
…nterfaces such as "List" rather than specific implementation classes such as "LinkedList".

(manolama - updated bindings added since the PR)

Signed-off-by: Chris Larsen <[email protected]>
  • Loading branch information
kirill-vlasov authored and manolama committed Aug 5, 2017
1 parent 59bc986 commit cf5d2ca
Show file tree
Hide file tree
Showing 48 changed files with 213 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private Scanner getRow(String table, Text row, Set<String> fields) throws TableN

@Override
public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {

Scanner scanner = null;
try {
Expand Down Expand Up @@ -280,7 +280,7 @@ public Status scan(String table, String startkey, int recordcount,

@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
BatchWriter bw = null;
try {
bw = getWriter(table);
Expand Down Expand Up @@ -308,7 +308,7 @@ public Status update(String table, String key,

@Override
public Status insert(String t, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
return update(t, key, values);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void cleanup() throws DBException {

@Override
public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {
try {
Record record;

Expand Down Expand Up @@ -134,7 +134,7 @@ public Status scan(String table, String start, int count, Set<String> fields,
}

private Status write(String table, String key, WritePolicy writePolicy,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
Bin[] bins = new Bin[values.size()];
int index = 0;

Expand All @@ -156,13 +156,13 @@ private Status write(String table, String key, WritePolicy writePolicy,

@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
return write(table, key, updatePolicy, values);
}

@Override
public Status insert(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
return write(table, key, insertPolicy, values);
}

Expand Down
10 changes: 5 additions & 5 deletions arangodb/src/main/java/com/yahoo/ycsb/db/ArangoDBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void cleanup() throws DBException {
* {@link DB} class's description for a discussion of error codes.
*/
@Override
public Status insert(String table, String key, HashMap<String, ByteIterator> values) {
public Status insert(String table, String key, Map<String, ByteIterator> values) {
try {
BaseDocument toInsert = new BaseDocument(key);
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
Expand Down Expand Up @@ -225,7 +225,7 @@ public Status insert(String table, String key, HashMap<String, ByteIterator> val
*/
@SuppressWarnings("unchecked")
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
DocumentEntity<BaseDocument> targetDoc = arangoDriver.getDocument(table, key, BaseDocument.class);
BaseDocument aDocument = targetDoc.getEntity();
Expand Down Expand Up @@ -261,7 +261,7 @@ public Status read(String table, String key, Set<String> fields, HashMap<String,
* description for a discussion of error codes.
*/
@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
public Status update(String table, String key, Map<String, ByteIterator> values) {
try {

if (!transactionUpdate) {
Expand Down Expand Up @@ -455,8 +455,8 @@ private ByteIterator stringToByteIterator(String content) {
return new StringByteIterator(content);
}

private String mapToJson(HashMap<String, ByteIterator> values) {
HashMap<String, String> intervalRst = new HashMap<String, String>();
private String mapToJson(Map<String, ByteIterator> values) {
Map<String, String> intervalRst = new HashMap<String, String>();
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
intervalRst.put(entry.getKey(), byteIteratorToString(entry.getValue()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void cleanup() throws DBException {
* {@link DB} class's description for a discussion of error codes.
*/
@Override
public Status insert(String table, String key, HashMap<String, ByteIterator> values) {
public Status insert(String table, String key, Map<String, ByteIterator> values) {
try {
BaseDocument toInsert = new BaseDocument(key);
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
Expand Down Expand Up @@ -205,7 +205,7 @@ public Status insert(String table, String key, HashMap<String, ByteIterator> val
* @return Zero on success, a non-zero error code on error or "not found".
*/
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
VPackSlice document = arangoDB.db(databaseName).collection(table).getDocument(key, VPackSlice.class, null);
if (!this.fillMap(result, document, fields)) {
Expand Down Expand Up @@ -233,7 +233,7 @@ public Status read(String table, String key, Set<String> fields, HashMap<String,
* description for a discussion of error codes.
*/
@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
public Status update(String table, String key, Map<String, ByteIterator> values) {
try {
if (!transactionUpdate) {
BaseDocument updateDoc = new BaseDocument();
Expand Down Expand Up @@ -414,7 +414,7 @@ private ByteIterator stringToByteIterator(String content) {
return new StringByteIterator(content);
}

private String mapToJson(HashMap<String, ByteIterator> values) {
private String mapToJson(Map<String, ByteIterator> values) {
VPackBuilder builder = new VPackBuilder().add(ValueType.OBJECT);
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
builder.add(entry.getKey(), byteIteratorToString(entry.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
Expand Down Expand Up @@ -196,7 +197,7 @@ public void cleanup() throws DBException {

@Override
public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {
setTable(table);

final GetRequest get = new GetRequest(
Expand Down Expand Up @@ -299,7 +300,7 @@ public Status scan(String table, String startkey, int recordcount,

@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
setTable(table);

if (debug) {
Expand Down Expand Up @@ -347,7 +348,7 @@ public Status update(String table, String key,

@Override
public Status insert(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
return update(table, key, values);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.microsoft.azure.documentdb.FeedOptions;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void init() throws DBException {

@Override
public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {
Document record = getDocumentById(table, key);

if (record != null) {
Expand All @@ -95,7 +96,7 @@ public Status read(String table, String key, Set<String> fields,

@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
Document record = getDocumentById(table, key);

if (record == null) {
Expand All @@ -120,7 +121,7 @@ public Status update(String table, String key,

@Override
public Status insert(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
Document record = new Document();

record.set("id", key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void cleanup() {

@Override
public Status read(String table, String key, Set<String> fields,
final HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {
if (fields != null) {
return readSubset(key, fields, result);
} else {
Expand Down Expand Up @@ -145,12 +146,12 @@ public Status scan(String table, String startkey, int recordcount,
}

@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
public Status update(String table, String key, Map<String, ByteIterator> values) {
return insertOrUpdate(key, values);
}

@Override
public Status insert(String table, String key, HashMap<String, ByteIterator> values) {
public Status insert(String table, String key, Map<String, ByteIterator> values) {
if (batchSize == 1) {
return insertOrUpdate(key, values);
} else {
Expand Down Expand Up @@ -187,7 +188,7 @@ private String getStorageConnectionString(String protocol, String account, Strin
/*
* Read subset of properties instead of full fields with projection.
*/
public Status readSubset(String key, Set<String> fields, HashMap<String, ByteIterator> result) {
public Status readSubset(String key, Set<String> fields, Map<String, ByteIterator> result) {
String whereStr = String.format("RowKey eq '%s'", key);

TableQuery<TableServiceEntity> projectionQuery = TableQuery.from(
Expand Down Expand Up @@ -220,7 +221,7 @@ public HashMap<String, ByteIterator> resolve(String partitionkey, String rowKey,
}
}

private Status readEntity(String key, HashMap<String, ByteIterator> result) {
private Status readEntity(String key, Map<String, ByteIterator> result) {
try {
// firstly, retrieve the entity to be deleted
TableOperation retrieveOp =
Expand All @@ -238,7 +239,7 @@ private Status readEntity(String key, HashMap<String, ByteIterator> result) {
}
}

private Status insertBatch(String key, HashMap<String, ByteIterator> values) {
private Status insertBatch(String key, Map<String, ByteIterator> values) {
HashMap<String, EntityProperty> properties = new HashMap<String, EntityProperty>();
for (Entry<String, ByteIterator> entry : values.entrySet()) {
String fieldName = entry.getKey();
Expand All @@ -259,7 +260,7 @@ private Status insertBatch(String key, HashMap<String, ByteIterator> values) {
return Status.OK;
}

private Status insertOrUpdate(String key, HashMap<String, ByteIterator> values) {
private Status insertOrUpdate(String key, Map<String, ByteIterator> values) {
HashMap<String, EntityProperty> properties = new HashMap<String, EntityProperty>();
for (Entry<String, ByteIterator> entry : values.entrySet()) {
String fieldName = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void cleanup() throws DBException {
*/
@Override
public Status read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
Map<String, ByteIterator> result) {
try {
Statement stmt;
Select.Builder selectBuilder;
Expand Down Expand Up @@ -402,7 +402,7 @@ public Status scan(String table, String startkey, int recordcount,
*/
@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {
// Insert and updates provide the same functionality
return insert(table, key, values);
}
Expand All @@ -422,7 +422,7 @@ public Status update(String table, String key,
*/
@Override
public Status insert(String table, String key,
HashMap<String, ByteIterator> values) {
Map<String, ByteIterator> values) {

try {
Insert insertStmt = QueryBuilder.insertInto(table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void testReadSingleColumn() throws Exception {
@Test
public void testUpdate() throws Exception {
final String key = "key";
final HashMap<String, String> input = new HashMap<String, String>();
final Map<String, String> input = new HashMap<String, String>();
input.put("field0", "value1");
input.put("field1", "value2");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void init() throws DBException {
}

private Status readUsingQuery(
String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
Statement query;
Iterable<String> columns = fields == null ? STANDARD_FIELDS : fields;
if (fields == null || fields.size() == fieldCount) {
Expand Down Expand Up @@ -253,7 +253,7 @@ private Status readUsingQuery(

@Override
public Status read(
String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
if (queriesForReads) {
return readUsingQuery(table, key, fields, result);
}
Expand Down Expand Up @@ -324,7 +324,7 @@ public Status scan(
}

@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
public Status update(String table, String key, Map<String, ByteIterator> values) {
Mutation.WriteBuilder m = Mutation.newInsertOrUpdateBuilder(table);
m.set(PRIMARY_KEY_COLUMN).to(key);
for (Map.Entry<String, ByteIterator> e : values.entrySet()) {
Expand All @@ -340,7 +340,7 @@ public Status update(String table, String key, HashMap<String, ByteIterator> val
}

@Override
public Status insert(String table, String key, HashMap<String, ByteIterator> values) {
public Status insert(String table, String key, Map<String, ByteIterator> values) {
if (bufferedMutations.size() < batchInserts) {
Mutation.WriteBuilder m = Mutation.newInsertOrUpdateBuilder(table);
m.set(PRIMARY_KEY_COLUMN).to(key);
Expand Down Expand Up @@ -389,7 +389,7 @@ public Status delete(String table, String key) {
}

private static void decodeStruct(
Iterable<String> columns, StructReader structReader, HashMap<String, ByteIterator> result) {
Iterable<String> columns, StructReader structReader, Map<String, ByteIterator> result) {
for (String col : columns) {
result.put(col, new StringByteIterator(structReader.getString(col)));
}
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/com/yahoo/ycsb/BasicDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.yahoo.ycsb;

import java.util.*;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

Expand Down Expand Up @@ -107,7 +108,7 @@ protected static StringBuilder getStringBuilder() {
* @param result A HashMap of field/value pairs for the result
* @return Zero on success, a non-zero error code on error
*/
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
delay();

if (verbose) {
Expand Down Expand Up @@ -170,7 +171,7 @@ public Status scan(String table, String startkey, int recordcount, Set<String> f
* @param values A HashMap of field/value pairs to update in the record
* @return Zero on success, a non-zero error code on error
*/
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
public Status update(String table, String key, Map<String, ByteIterator> values) {
delay();

if (verbose) {
Expand All @@ -197,7 +198,7 @@ public Status update(String table, String key, HashMap<String, ByteIterator> val
* @param values A HashMap of field/value pairs to insert in the record
* @return Zero on success, a non-zero error code on error
*/
public Status insert(String table, String key, HashMap<String, ByteIterator> values) {
public Status insert(String table, String key, Map<String, ByteIterator> values) {
delay();

if (verbose) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/yahoo/ycsb/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ int record = 0;
} else {
System.out.println("--------------------------------");
}
for (HashMap<String, ByteIterator> result : results) {
for (Map<String, ByteIterator> result : results) {
System.out.println("Record " + (record++));
for (Map.Entry<String, ByteIterator> ent : result.entrySet()) {
System.out.println(ent.getKey() + "=" + ent.getValue());
Expand Down
Loading

0 comments on commit cf5d2ca

Please sign in to comment.