Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit a70bd73

Browse files
Alexander PatrikalakisAlexander Patrikalakis
authored andcommitted
Update license header, short circuiting and streaming
1 parent bd08d5f commit a70bd73

20 files changed

+61
-61
lines changed

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/AbstractDynamoDbStore.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818
import java.util.List;
1919
import java.util.concurrent.ExecutionException;
2020
import java.util.concurrent.TimeUnit;
21+
import java.util.stream.Collectors;
2122

2223
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
2324
import com.amazonaws.services.dynamodbv2.model.DeleteItemRequest;
@@ -186,21 +187,18 @@ String encodeKeyForLog(final StaticBuffer key) {
186187
}
187188

188189
String encodeForLog(final List<?> columns) {
189-
final StringBuilder result = new StringBuilder("[");
190-
for (int i = 0; i < columns.size(); i++) {
191-
final Object obj = columns.get(i);
192-
StaticBuffer column = null;
193-
if (obj instanceof StaticBuffer) {
194-
column = (StaticBuffer) obj;
195-
} else if (obj instanceof Entry) {
196-
column = ((Entry) obj).getColumn();
197-
}
198-
result.append(encodeKeyForLog(column));
199-
if (i < columns.size() - 1) {
200-
result.append(",");
201-
}
202-
}
203-
return result.append("]").toString();
190+
return columns.stream()
191+
.map(obj -> {
192+
if (obj instanceof StaticBuffer) {
193+
return (StaticBuffer) obj;
194+
} else if (obj instanceof Entry) {
195+
return ((Entry) obj).getColumn();
196+
} else {
197+
return null;
198+
}
199+
})
200+
.map(this::encodeKeyForLog)
201+
.collect(Collectors.joining(",", "[", "]"));
204202
}
205203

206204
@Override

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/BackendRuntimeException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -35,9 +35,8 @@ public BackendException getBackendException() {
3535
final Throwable throwable = super.getCause();
3636
if (throwable instanceof BackendException) {
3737
return (BackendException) throwable;
38-
} else {
39-
return null;
4038
}
39+
return null;
4140
}
4241

4342
private static final long serialVersionUID = 6184087040805925812L;

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/Client.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License").
@@ -127,9 +127,10 @@ public Client(final Configuration config) {
127127
Constants.DYNAMODB_INITIAL_RETRY_MILLIS.getName() + " must be at least 1");
128128

129129
final double controlPlaneRate = config.get(Constants.DYNAMODB_CONTROL_PLANE_RATE);
130-
Preconditions.checkArgument(controlPlaneRate >= 0,
130+
Preconditions.checkArgument(controlPlaneRate > 0,
131131
"must have a positive control plane rate");
132-
final RateLimiter controlPlaneRateLimiter = RateLimiter.create(controlPlaneRate);
132+
final RateLimiter controlPlaneRateLimiter = RateLimiterCreator.createBurstingLimiter(controlPlaneRate,
133+
DEFAULT_BURST_BUCKET_SIZE_IN_SECONDS);
133134

134135
final Map<String, RateLimiter> readRateLimit = new HashMap<>();
135136
final Map<String, RateLimiter> writeRateLimit = new HashMap<>();

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/Constants.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License").
@@ -37,8 +37,7 @@
3737
*
3838
*/
3939
public final class Constants {
40-
private Constants() {
41-
}
40+
private Constants() { }
4241
//begin adaptation of
4342
//https://github.com/buka/titan/blob/master/src/main/java/com/thinkaurelius/titan/diskstorage/dynamodb/DynamoDBClient.java#L26
4443
public static final String JANUSGRAPH_VALUE = "v";
@@ -49,7 +48,7 @@ private Constants() {
4948
public static final String HEX_PREFIX = "0x";
5049
public static final String JANUSGRAPH_USER_AGENT = "dynamodb-janusgraph010-storage-backend_1.0.0";
5150

52-
public static final List<String> REQUIRED_BACKEND_STORES = ImmutableList.of(Backend.EDGESTORE_NAME, //
51+
public static final List<String> REQUIRED_BACKEND_STORES = ImmutableList.of(Backend.EDGESTORE_NAME,
5352
Backend.INDEXSTORE_NAME,
5453
Backend.SYSTEM_TX_LOG_NAME,
5554
Backend.SYSTEM_MGMT_LOG_NAME,

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/DynamoDBStoreManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -222,9 +222,8 @@ public List<KeyRange> getLocalKeyPartition() throws BackendException {
222222
public Deployment getDeployment() {
223223
if (client.getDelegate().isEmbedded()) {
224224
return Deployment.EMBEDDED;
225-
} else {
226-
return Deployment.REMOTE;
227225
}
226+
return Deployment.REMOTE;
228227
}
229228

230229
@Override

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/DynamoDbDelegate.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -927,9 +927,8 @@ void updatePagesHistogram(final String apiName, final String tableName, final in
927927
final String getMeterName(final String apiName, final String tableName) {
928928
if (tableName == null) {
929929
return String.format("%s.%s", metricsPrefix, apiName);
930-
} else {
931-
return String.format("%s.%s.%s", metricsPrefix, apiName, tableName);
932930
}
931+
return String.format("%s.%s.%s", metricsPrefix, apiName, tableName);
933932
}
934933
final int getMaxConcurrentUsers() {
935934
return this.maxConcurrentUsers;

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/DynamoDbStore.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -159,10 +159,9 @@ private QueryRequest createQueryRequest(final StaticBuffer hashKey, final SliceQ
159159
.rangeKey(rangeQuery.getSliceStart(), rangeQuery.getSliceEnd())
160160
.build();
161161

162-
final QueryRequest request = super.createQueryRequest()
162+
return super.createQueryRequest()
163163
.withKeyConditionExpression(keyConditionExpression.getConditionExpression())
164164
.withExpressionAttributeValues(keyConditionExpression.getAttributeValues());
165-
return request;
166165
}
167166

168167
@Override

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/ListTablesWorker.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
2525
import lombok.Getter;
2626

2727
/**
28+
* This class merges multiple pages of table names into one ListTablesResult.
29+
*
2830
* @author Alexander Patrikalakis
2931
*/
3032
public class ListTablesWorker extends PaginatingTask<ListTablesResult> {

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/QueryResultWrapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -23,6 +23,9 @@
2323
import lombok.RequiredArgsConstructor;
2424

2525
/**
26+
* The QueryResultWrapper class associates the JanusGraph key that was used to create the QueryRequest
27+
* resulting in the enclosed QueryResult.
28+
*
2629
* @author Alexander Patrikalakis
2730
*/
2831
@RequiredArgsConstructor

src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/EntryBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public List<Entry> buildAll() {
6565
sliceStartEntry = null;
6666
sliceEndEntry = null;
6767
}
68-
//TODO(alexp) Arrays.parallelSort(filteredEntries) in JDK 8? Can you switch to java 8?
68+
//TODO(amcp) Arrays.parallelSort(filteredEntries)?
6969
//https://github.com/awslabs/dynamodb-titan-storage-backend/issues/159
7070
return item.entrySet().stream()
7171
.map(entry -> {

0 commit comments

Comments
 (0)