Skip to content

Commit

Permalink
IGNITE-14823 Handler abbrevation (#11117)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Dec 21, 2023
1 parent 2689972 commit 431f598
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ private static int compare(Object o1, Object o2, int nullComparison) {

/** {@inheritDoc} */
@Override public Iterable<Row> values(List<RexLiteral> values, RelDataType rowType) {
RowHandler<Row> handler = ctx.rowHandler();
RowFactory<Row> factory = handler.factory(typeFactory, rowType);
RowHandler<Row> hnd = ctx.rowHandler();
RowFactory<Row> factory = hnd.factory(typeFactory, rowType);

int columns = rowType.getFieldCount();
assert values.size() % columns == 0;
Expand All @@ -273,7 +273,7 @@ private static int compare(Object o1, Object o2, int nullComparison) {

RexLiteral literal = values.get(i);

handler.set(field, currRow, literal.getValueAs(types.get(field)));
hnd.set(field, currRow, literal.getValueAs(types.get(field)));
}

return rows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ private Group newGroup(Row r) {
final Object[] grpKeys = new Object[grpSet.cardinality()];
List<Integer> fldIdxs = grpSet.asList();

final RowHandler<Row> rowHandler = rowFactory.handler();
final RowHandler<Row> rowHnd = rowFactory.handler();

for (int i = 0; i < grpKeys.length; ++i)
grpKeys[i] = rowHandler.get(fldIdxs.get(i), r);
grpKeys[i] = rowHnd.get(fldIdxs.get(i), r);

Group grp = new Group(grpKeys);

Expand Down Expand Up @@ -249,10 +249,10 @@ private void addOnMapper(Row row) {

/** */
private void addOnReducer(Row row) {
RowHandler<Row> handler = context().rowHandler();
RowHandler<Row> hnd = context().rowHandler();

List<Accumulator> accums = hasAccumulators() ?
(List<Accumulator>)handler.get(handler.columnCount(row) - 1, row)
(List<Accumulator>)hnd.get(hnd.columnCount(row) - 1, row)
: Collections.emptyList();

for (int i = 0; i < accums.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,27 @@ else if (affFields.isEmpty())
RowHandler.RowFactory<Row> factory,
@Nullable ImmutableBitSet requiredColumns
) throws IgniteCheckedException {
RowHandler<Row> handler = factory.handler();
RowHandler<Row> hnd = factory.handler();

assert handler == ectx.rowHandler();
assert hnd == ectx.rowHandler();

Row res = factory.create();

assert handler.columnCount(res) == (requiredColumns == null ? descriptors.length : requiredColumns.cardinality());
assert hnd.columnCount(res) == (requiredColumns == null ? descriptors.length : requiredColumns.cardinality());

if (requiredColumns == null) {
for (int i = 0; i < descriptors.length; i++) {
CacheColumnDescriptor desc = descriptors[i];

handler.set(i, res, TypeUtils.toInternal(ectx,
hnd.set(i, res, TypeUtils.toInternal(ectx,
desc.value(ectx, cacheContext(), row), desc.storageType()));
}
}
else {
for (int i = 0, j = requiredColumns.nextSetBit(0); j != -1; j = requiredColumns.nextSetBit(j + 1), i++) {
CacheColumnDescriptor desc = descriptors[j];

handler.set(i, res, TypeUtils.toInternal(ectx,
hnd.set(i, res, TypeUtils.toInternal(ectx,
desc.value(ectx, cacheContext(), row), desc.storageType()));
}
}
Expand Down Expand Up @@ -350,9 +350,9 @@ private <Row> ModifyTuple insertTuple(Row row, ExecutionContext<Row> ectx) throw

/** */
private <Row> Object insertKey(Row row, ExecutionContext<Row> ectx) throws IgniteCheckedException {
RowHandler<Row> handler = ectx.rowHandler();
RowHandler<Row> hnd = ectx.rowHandler();

Object key = handler.get(keyField, row);
Object key = hnd.get(keyField, row);

if (key != null)
return TypeUtils.fromInternal(ectx, key, descriptors[QueryUtils.KEY_COL].storageType());
Expand All @@ -364,7 +364,7 @@ private <Row> Object insertKey(Row row, ExecutionContext<Row> ectx) throws Ignit
if (!desc.field() || !desc.key())
continue;

Object fieldVal = handler.get(i, row);
Object fieldVal = hnd.get(i, row);

if (fieldVal != null) {
if (key == null)
Expand All @@ -382,9 +382,9 @@ private <Row> Object insertKey(Row row, ExecutionContext<Row> ectx) throws Ignit

/** */
private <Row> Object insertVal(Row row, ExecutionContext<Row> ectx) throws IgniteCheckedException {
RowHandler<Row> handler = ectx.rowHandler();
RowHandler<Row> hnd = ectx.rowHandler();

Object val = handler.get(valField, row);
Object val = hnd.get(valField, row);

if (val == null) {
val = newVal(typeDesc.valueTypeName(), typeDesc.valueClass());
Expand All @@ -393,7 +393,7 @@ private <Row> Object insertVal(Row row, ExecutionContext<Row> ectx) throws Ignit
for (int i = 2; i < descriptors.length; i++) {
final CacheColumnDescriptor desc = descriptors[i];

Object fieldVal = handler.get(i, row);
Object fieldVal = hnd.get(i, row);

if (desc.field() && !desc.key() && fieldVal != null)
desc.set(val, TypeUtils.fromInternal(ectx, fieldVal, desc.storageType()));
Expand Down Expand Up @@ -449,10 +449,10 @@ private IgniteCheckedException instantiationException(String typeName, Reflectiv
/** */
private <Row> ModifyTuple updateTuple(Row row, List<String> updateColList, int offset, ExecutionContext<Row> ectx)
throws IgniteCheckedException {
RowHandler<Row> handler = ectx.rowHandler();
RowHandler<Row> hnd = ectx.rowHandler();

Object key = Objects.requireNonNull(handler.get(offset + QueryUtils.KEY_COL, row));
Object val = clone(Objects.requireNonNull(handler.get(offset + QueryUtils.VAL_COL, row)));
Object key = Objects.requireNonNull(hnd.get(offset + QueryUtils.KEY_COL, row));
Object val = clone(Objects.requireNonNull(hnd.get(offset + QueryUtils.VAL_COL, row)));

offset += descriptorsMap.size();

Expand All @@ -461,7 +461,7 @@ private <Row> ModifyTuple updateTuple(Row row, List<String> updateColList, int o

assert !desc.key();

Object fieldVal = handler.get(i + offset, row);
Object fieldVal = hnd.get(i + offset, row);

if (desc.field())
desc.set(val, TypeUtils.fromInternal(ectx, fieldVal, desc.storageType()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,16 @@ public static <Row> Function<Row, Row> resultTypeConverter(ExecutionContext<Row>
assert resultType.isStruct();

if (hasConvertableFields(resultType)) {
RowHandler<Row> handler = ectx.rowHandler();
RowHandler<Row> hnd = ectx.rowHandler();
List<RelDataType> types = RelOptUtil.getFieldTypeList(resultType);
RowHandler.RowFactory<Row> factory = handler.factory(ectx.getTypeFactory(), types);
RowHandler.RowFactory<Row> factory = hnd.factory(ectx.getTypeFactory(), types);
List<Function<Object, Object>> converters = transform(types, t -> fieldConverter(ectx, t));
return r -> {
Row newRow = factory.create();
assert handler.columnCount(newRow) == converters.size();
assert handler.columnCount(r) == converters.size();
assert hnd.columnCount(newRow) == converters.size();
assert hnd.columnCount(r) == converters.size();
for (int i = 0; i < converters.size(); i++)
handler.set(i, newRow, converters.get(i).apply(handler.get(i, r)));
hnd.set(i, newRow, converters.get(i).apply(hnd.get(i, r)));
return newRow;
};
}
Expand Down
2 changes: 1 addition & 1 deletion modules/checkstyle/src/main/resources/abbrevations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ execute,exec
frequency,freq
future,fut
#group,grp
#handler,hnd
handler,hnd
#header,hdr
#implementation,impl
#index,idx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void testCacheIndexList() {

injectTestSystemOut();

final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--index-name", idxName));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_list", "--index-name", idxName));

String outStr = testOut.toString();

Expand All @@ -108,7 +108,7 @@ public void testCacheIndexList() {
assertEquals("Unexpected number of index description lines: " + indexDescrLinesNum,
indexDescrLinesNum, expectedIndexDescrLinesNum);

Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
Set<IndexListInfoContainer> cmdResult = hnd.getLastOperationResult();
assertNotNull(cmdResult);

final int resSetSize = cmdResult.size();
Expand All @@ -131,9 +131,9 @@ public void tesAllArgs() {

injectTestSystemOut();

final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list",
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_list",
"--node-id", grid(0).localNode().id().toString(),
"--group-name", "^" + GROUP_NAME + "$",
"--cache-name", CACHE_NAME,
Expand All @@ -156,7 +156,7 @@ public void testListCacheWithoutIndexes() {

injectTestSystemOut();

final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

try {
ignite.createCache(tmpCacheName);
Expand All @@ -166,7 +166,7 @@ public void testListCacheWithoutIndexes() {
streamer.addData(i * 13, i * 17);
}

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--cache-name", tmpCacheName));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_list", "--cache-name", tmpCacheName));

String str = testOut.toString();

Expand Down Expand Up @@ -215,11 +215,11 @@ private void checkGroup(String grpRegEx, String grpName, int expectedResNum) {

/** */
private void checkGroup(String grpRegEx, Predicate<String> predicate, int expectedResNum) {
final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--group-name", grpRegEx));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_list", "--group-name", grpRegEx));

Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
Set<IndexListInfoContainer> cmdResult = hnd.getLastOperationResult();
assertNotNull(cmdResult);

boolean isResCorrect =
Expand Down Expand Up @@ -262,11 +262,11 @@ public void testCacheNameFilter2() {

/** */
private void checkCacheNameFilter(String cacheRegEx, Predicate<String> predicate, int expectedResNum) {
final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--cache-name", cacheRegEx));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_list", "--cache-name", cacheRegEx));

Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
Set<IndexListInfoContainer> cmdResult = hnd.getLastOperationResult();
assertNotNull(cmdResult);

boolean isResCorrect =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testCommandOutput() throws Exception {
injectTestSystemOut();
idxRebuildsStartedNum.set(0);

final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

stopGrid(GRIDS_NUM - 1);
stopGrid(GRIDS_NUM - 2);
Expand All @@ -163,9 +163,9 @@ public void testCommandOutput() throws Exception {
boolean allRebuildsStarted = GridTestUtils.waitForCondition(() -> idxRebuildsStartedNum.get() == 6, 30_000);
assertTrue("Failed to wait for all indexes to start being rebuilt", allRebuildsStarted);

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_rebuild_status"));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_rebuild_status"));

checkResult(handler, 1, 2);
checkResult(hnd, 1, 2);

statusRequestingFinished.set(true);

Expand All @@ -187,7 +187,7 @@ public void testCommandOutput() throws Exception {

assertTrue(idxProgressBlockedLatch.await(getTestTimeout(), MILLISECONDS));

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_rebuild_status"));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_rebuild_status"));

checkRebuildInProgressOutputFor("cache1");

Expand All @@ -202,7 +202,7 @@ public void testNodeIdOption() throws Exception {
injectTestSystemOut();
idxRebuildsStartedNum.set(0);

final TestCommandHandler handler = newCommandHandler(createTestLogger());
final TestCommandHandler hnd = newCommandHandler(createTestLogger());

stopGrid(GRIDS_NUM - 1);
stopGrid(GRIDS_NUM - 2);
Expand All @@ -221,11 +221,11 @@ public void testNodeIdOption() throws Exception {
boolean allRebuildsStarted = GridTestUtils.waitForCondition(() -> idxRebuildsStartedNum.get() == 6, 30_000);
assertTrue("Failed to wait for all indexes to start being rebuilt", allRebuildsStarted);

assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_rebuild_status", "--node-id", id1.toString()));
assertEquals(EXIT_CODE_OK, execute(hnd, "--cache", "indexes_rebuild_status", "--node-id", id1.toString()));

statusRequestingFinished.set(true);

checkResult(handler, 2);
checkResult(hnd, 2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2474,12 +2474,12 @@ private CacheGroupContext startCacheGroup(
boolean persistenceEnabled = recoveryMode || sharedCtx.localNode().isClient() ? desc.persistenceEnabled() :
dataRegion != null && dataRegion.config().isPersistenceEnabled();

CompressionHandler compressHandler = CompressionHandler.create(ctx, cfg);
CompressionHandler compressHnd = CompressionHandler.create(ctx, cfg);

if (log.isInfoEnabled() && compressHandler.compressionEnabled()) {
if (log.isInfoEnabled() && compressHnd.compressionEnabled()) {
log.info("Disk page compression is enabled [cacheGrp=" + CU.cacheOrGroupName(cfg) +
", compression=" + compressHandler.diskPageCompression() + ", level=" +
compressHandler.diskPageCompressionLevel() + "]");
", compression=" + compressHnd.diskPageCompression() + ", level=" +
compressHnd.diskPageCompressionLevel() + "]");
}

CacheGroupContext grp = new CacheGroupContext(sharedCtx,
Expand All @@ -2496,7 +2496,7 @@ private CacheGroupContext startCacheGroup(
persistenceEnabled,
desc.walEnabled(),
recoveryMode,
compressHandler
compressHnd
);

for (Object obj : grp.configuredUserObjects())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public ClientListenerNioListener(
}

ClientListenerMessageParser parser = connCtx.parser();
ClientListenerRequestHandler handler = connCtx.handler();
ClientListenerRequestHandler hnd = connCtx.handler();

ClientListenerRequest req;

Expand All @@ -180,7 +180,7 @@ public ClientListenerNioListener(
}
catch (Exception e) {
try {
handler.unregisterRequest(parser.decodeRequestId(msg));
hnd.unregisterRequest(parser.decodeRequestId(msg));
}
catch (Exception e1) {
U.error(log, "Failed to unregister request.", e1);
Expand Down Expand Up @@ -208,7 +208,7 @@ public ClientListenerNioListener(
ClientListenerResponse resp;

try (OperationSecurityContext s = ctx.security().withContext(connCtx.securityContext())) {
resp = handler.handle(req);
resp = hnd.handle(req);
}

if (resp != null) {
Expand All @@ -228,14 +228,14 @@ public ClientListenerNioListener(
}
}
catch (Throwable e) {
handler.unregisterRequest(req.requestId());
hnd.unregisterRequest(req.requestId());

if (e instanceof Error)
U.error(log, "Failed to process client request [req=" + req + ", msg=" + e.getMessage() + "]", e);
else
U.warn(log, "Failed to process client request [req=" + req + ", msg=" + e.getMessage() + "]", e);

ses.send(parser.encode(handler.handleException(e, req)));
ses.send(parser.encode(hnd.handleException(e, req)));

if (e instanceof Error)
throw (Error)e;
Expand Down
Loading

0 comments on commit 431f598

Please sign in to comment.