Skip to content

Commit

Permalink
IGNITE-14823 Sequence, socket, source abbrevations (#11208)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Jan 30, 2024
1 parent e6438ee commit aec5f95
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1531,11 +1531,11 @@ private static class CastImplementor extends AbstractRexCallImplementor {
@Override Expression implementSafe(final RexToLixTranslator translator,
final RexCall call, final List<Expression> argValueList) {
assert call.getOperands().size() == 1;
final RelDataType sourceType = call.getOperands().get(0).getType();
final RelDataType srcType = call.getOperands().get(0).getType();

// Short-circuit if no cast is required
RexNode arg = call.getOperands().get(0);
if (call.getType().equals(sourceType)) {
if (call.getType().equals(srcType)) {
// No cast required, omit cast
return argValueList.get(0);
}
Expand All @@ -1548,7 +1548,7 @@ private static class CastImplementor extends AbstractRexCallImplementor {
}
final RelDataType targetType =
nullifyType(translator.typeFactory, call.getType(), false);
return translator.translateCast(sourceType,
return translator.translateCast(srcType,
targetType, argValueList.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,12 @@ Expression translateCast(
case BINARY:
case VARBINARY:
// If this is a widening cast, no need to truncate.
final int sourcePrecision = sourceType.getPrecision();
if (SqlTypeUtil.comparePrecision(sourcePrecision, targetPrecision) <= 0)
final int srcPrecision = sourceType.getPrecision();
if (SqlTypeUtil.comparePrecision(srcPrecision, targetPrecision) <= 0)
truncate = false;

// If this is a widening cast, no need to pad.
if (SqlTypeUtil.comparePrecision(sourcePrecision, targetPrecision) >= 0)
if (SqlTypeUtil.comparePrecision(srcPrecision, targetPrecision) >= 0)
pad = false;

// fall through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public boolean belongs(long sourceId) {
* being calculated fragment.
*/
public ColocationGroup colocate(ColocationGroup other) throws ColocationMappingException {
long[] sourceIds;
long[] srcIds;
if (this.sourceIds == null || other.sourceIds == null)
sourceIds = U.firstNotNull(this.sourceIds, other.sourceIds);
srcIds = U.firstNotNull(this.sourceIds, other.sourceIds);
else
sourceIds = LongStream.concat(Arrays.stream(this.sourceIds), Arrays.stream(other.sourceIds)).distinct().toArray();
srcIds = LongStream.concat(Arrays.stream(this.sourceIds), Arrays.stream(other.sourceIds)).distinct().toArray();

List<UUID> nodeIds;
if (this.nodeIds == null || other.nodeIds == null)
Expand Down Expand Up @@ -198,7 +198,7 @@ public ColocationGroup colocate(ColocationGroup other) throws ColocationMappingE
}
}

return new ColocationGroup(sourceIds, nodeIds, assignments);
return new ColocationGroup(srcIds, nodeIds, assignments);
}

/** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ private IgniteRel split(IgniteRel rel) {
RelNode input = rel instanceof IgniteTrimExchange ? rel.getInput(0) : rel;

long targetFragmentId = curr.id;
long sourceFragmentId = IdGenerator.nextId();
long exchangeId = sourceFragmentId;
long srcFragmentId = IdGenerator.nextId();
long exchangeId = srcFragmentId;

IgniteReceiver receiver = new IgniteReceiver(cluster, traits, rowType, exchangeId, sourceFragmentId);
IgniteReceiver receiver = new IgniteReceiver(cluster, traits, rowType, exchangeId, srcFragmentId);
IgniteSender snd = new IgniteSender(cluster, traits, input, exchangeId, targetFragmentId, rel.distribution());

curr.remotes.add(receiver);
stack.push(new FragmentProto(sourceFragmentId, snd));
stack.push(new FragmentProto(srcFragmentId, snd));

return receiver;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private RelNode convertMerge(SqlMerge call) {

// first, convert the merge's source select to construct the columns
// from the target table and the set expressions in the update call
RelNode mergeSourceRel = convertSelect(
RelNode mergeSrcRel = convertSelect(
requireNonNull(call.getSourceSelect(), () -> "sourceSelect for " + call), false);

// then, convert the insert statement so we can get the insert
Expand Down Expand Up @@ -260,7 +260,7 @@ private RelNode convertMerge(SqlMerge call) {
nLevel1Exprs = level1InsertExprs.size();
}

LogicalJoin join = (LogicalJoin)mergeSourceRel.getInput(0);
LogicalJoin join = (LogicalJoin)mergeSrcRel.getInput(0);

final List<RexNode> projects = new ArrayList<>();

Expand All @@ -276,7 +276,7 @@ private RelNode convertMerge(SqlMerge call) {
projects.add(level1InsertExprs.get(level1Idx));
}
if (updateCall != null) {
final LogicalProject project = (LogicalProject)mergeSourceRel;
final LogicalProject project = (LogicalProject)mergeSrcRel;
projects.addAll(project.getProjects());
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ private void validateTableModify(SqlNode table) {
for (SqlNode exp : call.getSourceExpressionList())
selectList.add(SqlValidatorUtil.addAlias(exp, SqlUtil.deriveAliasFromOrdinal(ordinal++)));

SqlNode sourceTable = call.getTargetTable();
SqlNode srcTable = call.getTargetTable();

if (call.getAlias() != null) {
sourceTable =
srcTable =
SqlValidatorUtil.addAlias(
sourceTable,
srcTable,
call.getAlias().getSimple());
}

return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable,
return new SqlSelect(SqlParserPos.ZERO, null, selectList, srcTable,
call.getCondition(), null, null, null, null, null, null, null);
}

Expand All @@ -207,16 +207,16 @@ private void validateTableModify(SqlNode table) {
final SqlNodeList selectList = SqlNodeList.of(
new SqlIdentifier(QueryUtils.KEY_FIELD_NAME, SqlParserPos.ZERO));

SqlNode sourceTable = call.getTargetTable();
SqlNode srcTable = call.getTargetTable();

if (call.getAlias() != null) {
sourceTable =
srcTable =
SqlValidatorUtil.addAlias(
sourceTable,
srcTable,
call.getAlias().getSimple());
}

return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable,
return new SqlSelect(SqlParserPos.ZERO, null, selectList, srcTable,
call.getCondition(), null, null, null, null, null, null, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public List<Fragment> go(IgniteRel root) {
RelOptCluster cluster = rel.getCluster();

long targetFragmentId = curr.id;
long sourceFragmentId = IdGenerator.nextId();
long exchangeId = sourceFragmentId;
long srcFragmentId = IdGenerator.nextId();
long exchangeId = srcFragmentId;

IgniteReceiver receiver = new IgniteReceiver(cluster, rel.getTraitSet(), rel.getRowType(), exchangeId, sourceFragmentId);
IgniteReceiver receiver = new IgniteReceiver(cluster, rel.getTraitSet(), rel.getRowType(), exchangeId, srcFragmentId);
IgniteSender snd = new IgniteSender(cluster, rel.getTraitSet(), rel.getInput(), exchangeId, targetFragmentId,
rel.distribution());

curr.remotes.add(receiver);
stack.push(new FragmentProto(sourceFragmentId, snd));
stack.push(new FragmentProto(srcFragmentId, snd));

return receiver;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ protected boolean projectsLeft(RelCollation collation) {

/** Creates mapping from left join keys to the right and vice versa with regards to {@code left2Right}. */
protected Mappings.TargetMapping buildTransposeMapping(boolean left2Right) {
ImmutableIntList sourceKeys = left2Right ? joinInfo.leftKeys : joinInfo.rightKeys;
ImmutableIntList srcKeys = left2Right ? joinInfo.leftKeys : joinInfo.rightKeys;
ImmutableIntList targetKeys = left2Right ? joinInfo.rightKeys : joinInfo.leftKeys;

Map<Integer, Integer> keyMap = new HashMap<>();
for (int i = 0; i < joinInfo.leftKeys.size(); i++)
keyMap.put(sourceKeys.get(i), targetKeys.get(i));
keyMap.put(srcKeys.get(i), targetKeys.get(i));

return Mappings.target(
keyMap,
Expand Down
6 changes: 3 additions & 3 deletions modules/checkstyle/src/main/resources/abbrevations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ response,res
sender,snd
service,srvc
session,ses
#sequence,seq
#socket,sock
#source,src
sequence,seq
socket,sock
source,src
#string,s,str
#subject,subj
#system,sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ private <T> List<List<T>> generateAllCombinations(List<T> source, Predicate<T> s
List<List<T>> res = new ArrayList<>();

for (int i = 0; i < source.size(); i++) {
List<T> sourceCopy = new ArrayList<>(source);
List<T> srcCopy = new ArrayList<>(source);

T removed = sourceCopy.remove(i);
T removed = srcCopy.remove(i);

generateAllCombinations(singletonList(removed), sourceCopy, stopFunc, res);
generateAllCombinations(singletonList(removed), srcCopy, stopFunc, res);
}

return res;
Expand All @@ -314,13 +314,13 @@ private <T> void generateAllCombinations(List<T> res, List<T> source, Predicate<
for (int i = 0; i < source.size(); i++) {
ArrayList<T> res0 = new ArrayList<>(res);

List<T> sourceCopy = new ArrayList<>(source);
List<T> srcCopy = new ArrayList<>(source);

T removed = sourceCopy.remove(i);
T removed = srcCopy.remove(i);

res0.add(removed);

generateAllCombinations(res0, sourceCopy, stopFunc, acc);
generateAllCombinations(res0, srcCopy, stopFunc, acc);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private JdbcThinSSLUtil() {
*/
public static SSLSocket createSSLSocket(InetSocketAddress addr, ConnectionProperties connProps) throws SQLException {
try {
SSLSocketFactory sslSocketFactory = getSSLSocketFactory(connProps);
SSLSocketFactory sslSockFactory = getSSLSocketFactory(connProps);

SSLSocket sock = (SSLSocket)sslSocketFactory.createSocket(addr.getAddress(), addr.getPort());
SSLSocket sock = (SSLSocket)sslSockFactory.createSocket(addr.getAddress(), addr.getPort());

sock.setUseClientMode(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,14 @@ private void createLeftOver() {
* @return length of newline sequence or 0 if none found
*/
private int getNewLineMatchByteCount(byte[] data, int i) {
for (byte[] newLineSequence : newLineSequences) {
for (byte[] newLineSeq : newLineSequences) {
boolean match = true;
for (int j = newLineSequence.length - 1; j >= 0; j--) {
int k = i + j - (newLineSequence.length - 1);
match &= k >= 0 && data[k] == newLineSequence[j];
for (int j = newLineSeq.length - 1; j >= 0; j--) {
int k = i + j - (newLineSeq.length - 1);
match &= k >= 0 && data[k] == newLineSeq[j];
}
if (match) {
return newLineSequence.length;
return newLineSeq.length;
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public DataStorageConfiguration getDataStorageConfiguration() {

/** */
public TestJdbcPojoDataSourceFactory getDataSourceFactory() {
TestJdbcPojoDataSourceFactory testJdbcPojoDataSourceFactory = new TestJdbcPojoDataSourceFactory();
TestJdbcPojoDataSourceFactory testJdbcPojoDataSrcFactory = new TestJdbcPojoDataSourceFactory();

testJdbcPojoDataSourceFactory.setURL("jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1");
testJdbcPojoDataSrcFactory.setURL("jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1");

testJdbcPojoDataSourceFactory.setUserName("sa");
testJdbcPojoDataSrcFactory.setUserName("sa");

testJdbcPojoDataSourceFactory.setPassword("");
testJdbcPojoDataSrcFactory.setPassword("");

return testJdbcPojoDataSourceFactory;
return testJdbcPojoDataSrcFactory;
}

/** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,44 @@ public void testValidBigHandshakeMessage() throws Exception {
@Test
public void testHandshakeTooLargeServerDropsConnection() throws Exception {
try (LocalIgniteCluster ignored = LocalIgniteCluster.start(1, IPv4_HOST)) {
Socket clientSocket = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSocket.getOutputStream();
Socket clientSock = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSock.getOutputStream();

stream.write(new byte[]{1, 1, 1, 1});
stream.flush();

// Read returns -1 when end of stream has been reached, blocks otherwise.
assertEquals(-1, clientSocket.getInputStream().read());
assertEquals(-1, clientSock.getInputStream().read());
}
}

/** */
@Test
public void testNegativeMessageSizeDropsConnection() throws Exception {
try (LocalIgniteCluster ignored = LocalIgniteCluster.start(1, IPv4_HOST)) {
Socket clientSocket = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSocket.getOutputStream();
Socket clientSock = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSock.getOutputStream();

byte b = (byte)255;
stream.write(new byte[]{b, b, b, b});
stream.flush();

// Read returns -1 when end of stream has been reached, blocks otherwise.
assertEquals(-1, clientSocket.getInputStream().read());
assertEquals(-1, clientSock.getInputStream().read());
}
}

/** */
@Test
public void testInvalidHandshakeHeaderDropsConnection() throws Exception {
try (LocalIgniteCluster ignored = LocalIgniteCluster.start(1, IPv4_HOST)) {
Socket clientSocket = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSocket.getOutputStream();
Socket clientSock = new Socket(IPv4_HOST, 10800);
OutputStream stream = clientSock.getOutputStream();

stream.write(new byte[]{10, 0, 0, 0, 42, 42, 42});
stream.flush();

assertEquals(-1, clientSocket.getInputStream().read());
assertEquals(-1, clientSock.getInputStream().read());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ public void testSequence() throws Exception {

ignite.cluster().state(ClusterState.ACTIVE);

IgniteAtomicSequence sequence = ignite.atomicSequence("testSequence", 0, true);
IgniteAtomicSequence seq = ignite.atomicSequence("testSequence", 0, true);

int i = 0;

while (i < 1000) {
sequence.incrementAndGet();
seq.incrementAndGet();

i++;
}
Expand All @@ -160,9 +160,9 @@ public void testSequence() throws Exception {

ignite.cluster().state(ClusterState.ACTIVE);

sequence = ignite.atomicSequence("testSequence", 0, false);
seq = ignite.atomicSequence("testSequence", 0, false);

assertTrue(sequence.incrementAndGet() > i);
assertTrue(seq.incrementAndGet() > i);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public interface MyRenewService extends Service {
* @throws Exception In case of an error.
*/
private URLClassLoader prepareClassLoader(int ver) throws Exception {
String source = "import org.apache.ignite.internal.processors.service.ServiceHotRedeploymentViaDeploymentSpiTest;\n" +
String src = "import org.apache.ignite.internal.processors.service.ServiceHotRedeploymentViaDeploymentSpiTest;\n" +
"import org.apache.ignite.services.ServiceContext;\n" +
"public class MyRenewServiceImpl implements ServiceHotRedeploymentViaDeploymentSpiTest.MyRenewService {\n" +
" @Override public int version() {\n" +
Expand All @@ -221,7 +221,7 @@ private URLClassLoader prepareClassLoader(int ver) throws Exception {

File srcFile = new File(srcTmpDir.toFile(), "MyRenewServiceImpl.java");

Path srcFilePath = Files.write(srcFile.toPath(), source.getBytes(StandardCharsets.UTF_8));
Path srcFilePath = Files.write(srcFile.toPath(), src.getBytes(StandardCharsets.UTF_8));

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private class Acceptor implements Runnable {
/** {@inheritDoc} */
@Override public void run() {
while (running) {
Socket socket = acceptConnection();
workersExecutor.submit(new Worker(socket));
Socket sock = acceptConnection();
workersExecutor.submit(new Worker(sock));
}
}

Expand Down
Loading

0 comments on commit aec5f95

Please sign in to comment.