Skip to content

Commit

Permalink
fix pmd error
Browse files Browse the repository at this point in the history
  • Loading branch information
brharrington committed Mar 14, 2024
1 parent c39e2f3 commit 220cf3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void sendToLWC() {
EvalPayload payload = evaluator.eval(t);
if (!payload.getMetrics().isEmpty()) {
List<CompletableFuture<Void>> futures = new ArrayList<>();
payload.toBatches(batchSize, p -> futures.add(publisher.publish(p)));
payload.consumeBatches(batchSize, p -> futures.add(publisher.publish(p)));
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public List<Message> getMessages() {
* @return
* List of payloads that have at most {@code batchSize} metrics per payload.
*/
public List<EvalPayload> toBatches(int batchSize) {
public List<EvalPayload> consumeBatches(int batchSize) {
List<EvalPayload> payloads = new ArrayList<>(metrics.size() / batchSize + 1);
toBatches(batchSize, payloads::add);
consumeBatches(batchSize, payloads::add);
return payloads;
}

Expand All @@ -85,7 +85,7 @@ public List<EvalPayload> toBatches(int batchSize) {
* @param consumer
* Consumer to receive an eval payload batch.
*/
public void toBatches(int batchSize, Consumer<EvalPayload> consumer) {
public void consumeBatches(int batchSize, Consumer<EvalPayload> consumer) {
int size = metrics.size();
if (size <= batchSize) {
consumer.accept(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ private List<EvalPayload.Message> messages(int n) {
@Test
public void toBatchesBelowThreshold() {
EvalPayload payload = new EvalPayload(0L, metrics(4));
List<EvalPayload> batches = payload.toBatches(4);
List<EvalPayload> batches = payload.consumeBatches(4);
Assertions.assertEquals(1, batches.size());
Assertions.assertSame(payload, batches.get(0));
}

@Test
public void toBatchesAboveThreshold() {
EvalPayload payload = new EvalPayload(0L, metrics(21));
List<EvalPayload> batches = payload.toBatches(4);
List<EvalPayload> batches = payload.consumeBatches(4);
Assertions.assertEquals(6, batches.size());
int i = 0;
for (EvalPayload batch : batches) {
Expand All @@ -100,7 +100,7 @@ public void toBatchesAboveThreshold() {
@Test
public void toBatchesWithMessages() {
EvalPayload payload = new EvalPayload(0L, metrics(21), messages(2));
List<EvalPayload> batches = payload.toBatches(4);
List<EvalPayload> batches = payload.consumeBatches(4);
Assertions.assertEquals(6, batches.size());
int i = 0;
for (EvalPayload batch : batches) {
Expand Down

0 comments on commit 220cf3f

Please sign in to comment.