Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
egalpin committed Oct 10, 2024
1 parent a9c8d2e commit 734189b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public BrokerRequestIdGenerator(String brokerId) {
}

public long get() {
long normalized = ((_incrementingId.getAndIncrement() & Long.MAX_VALUE) % (OFFSET / BrokerRequestIdConstants.TABLE_TYPE_OFFSET))
* BrokerRequestIdConstants.TABLE_TYPE_OFFSET;
long normalized =
((_incrementingId.getAndIncrement() & Long.MAX_VALUE) % (OFFSET / BrokerRequestIdConstants.TABLE_TYPE_OFFSET))
* BrokerRequestIdConstants.TABLE_TYPE_OFFSET;
return _mask + normalized;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pinot.broker.requesthandler;

import org.apache.pinot.common.BrokerRequestIdConstants;
import org.testng.annotations.Test;

import static org.testng.Assert.*;
Expand All @@ -29,11 +30,11 @@ public class BrokerRequestIdGeneratorTest {
public void testGet() {
BrokerRequestIdGenerator gen = new BrokerRequestIdGenerator("foo");
long id = gen.get();
assertEquals(id % 10, 0);
assertEquals(id / 10 % 10, 0);
assertEquals(id % BrokerRequestIdConstants.TABLE_TYPE_OFFSET, 0);
assertEquals(id / BrokerRequestIdConstants.TABLE_TYPE_OFFSET % BrokerRequestIdConstants.TABLE_TYPE_OFFSET, 0);

id = gen.get();
assertEquals(id % 10, 0);
assertEquals(id / 10 % 10, 1);
assertEquals(id % BrokerRequestIdConstants.TABLE_TYPE_OFFSET, 0);
assertEquals(id / BrokerRequestIdConstants.TABLE_TYPE_OFFSET % BrokerRequestIdConstants.TABLE_TYPE_OFFSET, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ public AsyncQueryResponse submitQuery(long requestId, String rawTableName,
ServerRoutingInstance serverRoutingInstance = entry.getKey().toServerRoutingInstance(preferTls);

// TODO(egalpin): inject value into request ID to indicate REALTIME Vs OFFLINE table type?
long tableTypeDigit =
serverQueryRoutingContext.getTableType().equals(TableType.OFFLINE) ? BrokerRequestIdConstants.OFFLINE_TABLE_DIGIT
: BrokerRequestIdConstants.REALTIME_TABLE_DIGIT;
long tableTypeDigit = serverQueryRoutingContext.getTableType().equals(TableType.OFFLINE)
? BrokerRequestIdConstants.OFFLINE_TABLE_DIGIT : BrokerRequestIdConstants.REALTIME_TABLE_DIGIT;

InstanceRequest instanceRequest =
getInstanceRequest(requestId + tableTypeDigit, serverQueryRoutingContext.getBrokerRequest(),
Expand Down Expand Up @@ -199,7 +198,8 @@ void receiveDataTable(ServerRoutingInstance serverRoutingInstance, DataTable dat
// TODO(egalpin): How can we handle rolling out brokers expecting query_hash to be present, but while old server
// versions are still running and not yet setting the query hash from their side? If possible, deploying servers
// first would work.
AsyncQueryResponse asyncQueryResponse = _asyncQueryResponseMap.get(requestId / BrokerRequestIdConstants.TABLE_TYPE_OFFSET);
AsyncQueryResponse asyncQueryResponse =
_asyncQueryResponseMap.get(requestId / BrokerRequestIdConstants.TABLE_TYPE_OFFSET);

// Query future might be null if the query is already done (maybe due to failure)
if (asyncQueryResponse != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public void testValidResponse()
byte[] offlineResponseBytes = offlineDataTable.toBytes();

DataTable realtimeDataTable = DataTableBuilderFactory.getEmptyDataTable();
realtimeDataTable.getMetadata()
.put(MetadataKey.REQUEST_ID.getName(), Long.toString(requestId + BrokerRequestIdConstants.REALTIME_TABLE_DIGIT));
realtimeDataTable.getMetadata().put(MetadataKey.REQUEST_ID.getName(),
Long.toString(requestId + BrokerRequestIdConstants.REALTIME_TABLE_DIGIT));
realtimeDataTable.getMetadata()
.put(MetadataKey.TABLE.getName(), REALTIME_BROKER_REQUEST.getQuerySource().getTableName());
byte[] realtimeResponseBytes = realtimeDataTable.toBytes();
Expand Down

0 comments on commit 734189b

Please sign in to comment.