repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java | AuroraProtocol.searchProbableMaster | private static void searchProbableMaster(AuroraListener listener,
final GlobalStateInfo globalInfo,
HostAddress probableMaster) {
AuroraProtocol protocol = getNewProtocol(listener.getProxy(), globalInfo,
listener.getUrlParser());
try {
protocol.setHostAddress(probableMaster);
p... | java | private static void searchProbableMaster(AuroraListener listener,
final GlobalStateInfo globalInfo,
HostAddress probableMaster) {
AuroraProtocol protocol = getNewProtocol(listener.getProxy(), globalInfo,
listener.getUrlParser());
try {
protocol.setHostAddress(probableMaster);
p... | [
"private",
"static",
"void",
"searchProbableMaster",
"(",
"AuroraListener",
"listener",
",",
"final",
"GlobalStateInfo",
"globalInfo",
",",
"HostAddress",
"probableMaster",
")",
"{",
"AuroraProtocol",
"protocol",
"=",
"getNewProtocol",
"(",
"listener",
".",
"getProxy",
... | Connect aurora probable master. Aurora master change in time. The only way to check that a
server is a master is to asked him.
@param listener aurora failover to call back if master is found
@param globalInfo server global variables information
@param probableMaster probable master host | [
"Connect",
"aurora",
"probable",
"master",
".",
"Aurora",
"master",
"change",
"in",
"time",
".",
"The",
"only",
"way",
"to",
"check",
"that",
"a",
"server",
"is",
"a",
"master",
"is",
"to",
"asked",
"him",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java#L89-L115 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java | AuroraProtocol.getNewProtocol | public static AuroraProtocol getNewProtocol(FailoverProxy proxy, final GlobalStateInfo globalInfo,
UrlParser urlParser) {
AuroraProtocol newProtocol = new AuroraProtocol(urlParser, globalInfo, proxy.lock);
newProtocol.setProxy(proxy);
return newProtocol;
} | java | public static AuroraProtocol getNewProtocol(FailoverProxy proxy, final GlobalStateInfo globalInfo,
UrlParser urlParser) {
AuroraProtocol newProtocol = new AuroraProtocol(urlParser, globalInfo, proxy.lock);
newProtocol.setProxy(proxy);
return newProtocol;
} | [
"public",
"static",
"AuroraProtocol",
"getNewProtocol",
"(",
"FailoverProxy",
"proxy",
",",
"final",
"GlobalStateInfo",
"globalInfo",
",",
"UrlParser",
"urlParser",
")",
"{",
"AuroraProtocol",
"newProtocol",
"=",
"new",
"AuroraProtocol",
"(",
"urlParser",
",",
"global... | Initialize new protocol instance.
@param proxy proxy
@param globalInfo server global variables information
@param urlParser connection string data's
@return new AuroraProtocol | [
"Initialize",
"new",
"protocol",
"instance",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java#L335-L340 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/CmdInformationBatch.java | CmdInformationBatch.reset | @Override
public void reset() {
insertIds.clear();
updateCounts.clear();
insertIdNumber = 0;
hasException = false;
rewritten = false;
} | java | @Override
public void reset() {
insertIds.clear();
updateCounts.clear();
insertIdNumber = 0;
hasException = false;
rewritten = false;
} | [
"@",
"Override",
"public",
"void",
"reset",
"(",
")",
"{",
"insertIds",
".",
"clear",
"(",
")",
";",
"updateCounts",
".",
"clear",
"(",
")",
";",
"insertIdNumber",
"=",
"0",
";",
"hasException",
"=",
"false",
";",
"rewritten",
"=",
"false",
";",
"}"
] | Clear error state, used for clear exception after first batch query, when fall back to
per-query execution. | [
"Clear",
"error",
"state",
"used",
"for",
"clear",
"exception",
"after",
"first",
"batch",
"query",
"when",
"fall",
"back",
"to",
"per",
"-",
"query",
"execution",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/CmdInformationBatch.java#L98-L105 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java | SelectResultSet.readNextValue | private boolean readNextValue() throws IOException, SQLException {
byte[] buf = reader.getPacketArray(false);
//is error Packet
if (buf[0] == ERROR) {
protocol.removeActiveStreamingResult();
protocol.removeHasMoreResults();
protocol.setHasWarnings(false);
ErrorPacket errorPacket = n... | java | private boolean readNextValue() throws IOException, SQLException {
byte[] buf = reader.getPacketArray(false);
//is error Packet
if (buf[0] == ERROR) {
protocol.removeActiveStreamingResult();
protocol.removeHasMoreResults();
protocol.setHasWarnings(false);
ErrorPacket errorPacket = n... | [
"private",
"boolean",
"readNextValue",
"(",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"byte",
"[",
"]",
"buf",
"=",
"reader",
".",
"getPacketArray",
"(",
"false",
")",
";",
"//is error Packet",
"if",
"(",
"buf",
"[",
"0",
"]",
"==",
"ERROR",
... | Read next value.
@return true if have a new value
@throws IOException exception
@throws SQLException exception | [
"Read",
"next",
"value",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java#L430-L492 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java | SelectResultSet.deleteCurrentRowData | protected void deleteCurrentRowData() throws SQLException {
//move data
System.arraycopy(data, rowPointer + 1, data, rowPointer, dataSize - 1 - rowPointer);
data[dataSize - 1] = null;
dataSize--;
lastRowPointer = -1;
previous();
} | java | protected void deleteCurrentRowData() throws SQLException {
//move data
System.arraycopy(data, rowPointer + 1, data, rowPointer, dataSize - 1 - rowPointer);
data[dataSize - 1] = null;
dataSize--;
lastRowPointer = -1;
previous();
} | [
"protected",
"void",
"deleteCurrentRowData",
"(",
")",
"throws",
"SQLException",
"{",
"//move data",
"System",
".",
"arraycopy",
"(",
"data",
",",
"rowPointer",
"+",
"1",
",",
"data",
",",
"rowPointer",
",",
"dataSize",
"-",
"1",
"-",
"rowPointer",
")",
";",... | Delete current data. Position cursor to the previous row.
@throws SQLException if previous() fail. | [
"Delete",
"current",
"data",
".",
"Position",
"cursor",
"to",
"the",
"previous",
"row",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java#L519-L526 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java | SelectResultSet.close | public void close() throws SQLException {
isClosed = true;
if (!isEof) {
lock.lock();
try {
while (!isEof) {
dataSize = 0; //to avoid storing data
readNextValue();
}
} catch (SQLException queryException) {
throw ExceptionMapper.getException(queryExc... | java | public void close() throws SQLException {
isClosed = true;
if (!isEof) {
lock.lock();
try {
while (!isEof) {
dataSize = 0; //to avoid storing data
readNextValue();
}
} catch (SQLException queryException) {
throw ExceptionMapper.getException(queryExc... | [
"public",
"void",
"close",
"(",
")",
"throws",
"SQLException",
"{",
"isClosed",
"=",
"true",
";",
"if",
"(",
"!",
"isEof",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"while",
"(",
"!",
"isEof",
")",
"{",
"dataSize",
"=",
"0",
";",
... | Close resultSet. | [
"Close",
"resultSet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/SelectResultSet.java#L596-L626 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java | CallableProcedureStatement.nameToIndex | private int nameToIndex(String parameterName) throws SQLException {
parameterMetadata.readMetadataFromDbIfRequired();
for (int i = 1; i <= parameterMetadata.getParameterCount(); i++) {
String name = parameterMetadata.getName(i);
if (name != null && name.equalsIgnoreCase(parameterName)) {
ret... | java | private int nameToIndex(String parameterName) throws SQLException {
parameterMetadata.readMetadataFromDbIfRequired();
for (int i = 1; i <= parameterMetadata.getParameterCount(); i++) {
String name = parameterMetadata.getName(i);
if (name != null && name.equalsIgnoreCase(parameterName)) {
ret... | [
"private",
"int",
"nameToIndex",
"(",
"String",
"parameterName",
")",
"throws",
"SQLException",
"{",
"parameterMetadata",
".",
"readMetadataFromDbIfRequired",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"parameterMetadata",
".",
"getParamete... | Convert parameter name to parameter index in the query.
@param parameterName name
@return index
@throws SQLException exception | [
"Convert",
"parameter",
"name",
"to",
"parameter",
"index",
"in",
"the",
"query",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java#L158-L167 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java | CallableProcedureStatement.nameToOutputIndex | private int nameToOutputIndex(String parameterName) throws SQLException {
parameterMetadata.readMetadataFromDbIfRequired();
for (int i = 0; i < parameterMetadata.getParameterCount(); i++) {
String name = parameterMetadata.getName(i + 1);
if (name != null && name.equalsIgnoreCase(parameterName)) {
... | java | private int nameToOutputIndex(String parameterName) throws SQLException {
parameterMetadata.readMetadataFromDbIfRequired();
for (int i = 0; i < parameterMetadata.getParameterCount(); i++) {
String name = parameterMetadata.getName(i + 1);
if (name != null && name.equalsIgnoreCase(parameterName)) {
... | [
"private",
"int",
"nameToOutputIndex",
"(",
"String",
"parameterName",
")",
"throws",
"SQLException",
"{",
"parameterMetadata",
".",
"readMetadataFromDbIfRequired",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameterMetadata",
".",
"getPar... | Convert parameter name to output parameter index in the query.
@param parameterName name
@return index
@throws SQLException exception | [
"Convert",
"parameter",
"name",
"to",
"output",
"parameter",
"index",
"in",
"the",
"query",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java#L177-L191 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java | CallableProcedureStatement.indexToOutputIndex | private int indexToOutputIndex(int parameterIndex) throws SQLException {
try {
if (outputParameterMapper[parameterIndex - 1] == -1) {
//this is not an outputParameter
throw new SQLException("Parameter in index '" + parameterIndex
+ "' is not declared as output parameter with method... | java | private int indexToOutputIndex(int parameterIndex) throws SQLException {
try {
if (outputParameterMapper[parameterIndex - 1] == -1) {
//this is not an outputParameter
throw new SQLException("Parameter in index '" + parameterIndex
+ "' is not declared as output parameter with method... | [
"private",
"int",
"indexToOutputIndex",
"(",
"int",
"parameterIndex",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"if",
"(",
"outputParameterMapper",
"[",
"parameterIndex",
"-",
"1",
"]",
"==",
"-",
"1",
")",
"{",
"//this is not an outputParameter",
"throw",
... | Convert parameter index to corresponding outputIndex.
@param parameterIndex index
@return index
@throws SQLException exception | [
"Convert",
"parameter",
"index",
"to",
"corresponding",
"outputIndex",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/CallableProcedureStatement.java#L200-L215 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/parameters/ReaderParameter.java | ReaderParameter.writeTo | public void writeTo(PacketOutputStream pos) throws IOException {
pos.write(QUOTE);
if (length == Long.MAX_VALUE) {
pos.write(reader, true, noBackslashEscapes);
} else {
pos.write(reader, length, true, noBackslashEscapes);
}
pos.write(QUOTE);
} | java | public void writeTo(PacketOutputStream pos) throws IOException {
pos.write(QUOTE);
if (length == Long.MAX_VALUE) {
pos.write(reader, true, noBackslashEscapes);
} else {
pos.write(reader, length, true, noBackslashEscapes);
}
pos.write(QUOTE);
} | [
"public",
"void",
"writeTo",
"(",
"PacketOutputStream",
"pos",
")",
"throws",
"IOException",
"{",
"pos",
".",
"write",
"(",
"QUOTE",
")",
";",
"if",
"(",
"length",
"==",
"Long",
".",
"MAX_VALUE",
")",
"{",
"pos",
".",
"write",
"(",
"reader",
",",
"true... | Write reader to database in text format.
@param pos database outputStream
@throws IOException if any error occur when reading reader | [
"Write",
"reader",
"to",
"database",
"in",
"text",
"format",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/parameters/ReaderParameter.java#L89-L97 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.reset | @Override
public void reset() throws SQLException {
cmdPrologue();
try {
writer.startPacket(0);
writer.write(COM_RESET_CONNECTION);
writer.flush();
getResult(new Results());
//clear prepare statement cache
if (options.cachePrepStmts && options.useServerPrepStmts) {
... | java | @Override
public void reset() throws SQLException {
cmdPrologue();
try {
writer.startPacket(0);
writer.write(COM_RESET_CONNECTION);
writer.flush();
getResult(new Results());
//clear prepare statement cache
if (options.cachePrepStmts && options.useServerPrepStmts) {
... | [
"@",
"Override",
"public",
"void",
"reset",
"(",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",
";",
"try",
"{",
"writer",
".",
"startPacket",
"(",
"0",
")",
";",
"writer",
".",
"write",
"(",
"COM_RESET_CONNECTION",
")",
";",
"writer",
".",... | Reset connection state.
<ol>
<li>Transaction will be rollback</li>
<li>transaction isolation will be reset</li>
<li>user variables will be removed</li>
<li>sessions variables will be reset to global values</li>
</ol>
@throws SQLException if command failed | [
"Reset",
"connection",
"state",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L172-L194 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executeQuery | @Override
public void executeQuery(boolean mustExecuteOnMaster, Results results, final String sql)
throws SQLException {
cmdPrologue();
try {
writer.startPacket(0);
writer.write(COM_QUERY);
writer.write(sql);
writer.flush();
getResult(results);
} catch (SQLException ... | java | @Override
public void executeQuery(boolean mustExecuteOnMaster, Results results, final String sql)
throws SQLException {
cmdPrologue();
try {
writer.startPacket(0);
writer.write(COM_QUERY);
writer.write(sql);
writer.flush();
getResult(results);
} catch (SQLException ... | [
"@",
"Override",
"public",
"void",
"executeQuery",
"(",
"boolean",
"mustExecuteOnMaster",
",",
"Results",
"results",
",",
"final",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",
";",
"try",
"{",
"writer",
".",
"startPacket",
"(",... | Execute query directly to outputStream.
@param mustExecuteOnMaster was intended to be launched on master connection
@param results result
@param sql the query to executeInternal
@throws SQLException exception | [
"Execute",
"query",
"directly",
"to",
"outputStream",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L216-L238 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executeQuery | public void executeQuery(boolean mustExecuteOnMaster, Results results,
final ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters) throws SQLException {
cmdPrologue();
try {
if (clientPrepareResult.getParamCount() == 0 && !clientPrepareResult
.isQueryMultiValuesRewr... | java | public void executeQuery(boolean mustExecuteOnMaster, Results results,
final ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters) throws SQLException {
cmdPrologue();
try {
if (clientPrepareResult.getParamCount() == 0 && !clientPrepareResult
.isQueryMultiValuesRewr... | [
"public",
"void",
"executeQuery",
"(",
"boolean",
"mustExecuteOnMaster",
",",
"Results",
"results",
",",
"final",
"ClientPrepareResult",
"clientPrepareResult",
",",
"ParameterHolder",
"[",
"]",
"parameters",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",... | Execute a unique clientPrepareQuery.
@param mustExecuteOnMaster was intended to be launched on master connection
@param results results
@param clientPrepareResult clientPrepareResult
@param parameters parameters
@throws SQLException exception | [
"Execute",
"a",
"unique",
"clientPrepareQuery",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L270-L295 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executeBatch | private void executeBatch(Results results, final List<String> queries)
throws SQLException {
if (!options.useBatchMultiSend) {
String sql = null;
SQLException exception = null;
for (int i = 0; i < queries.size() && !isInterrupted(); i++) {
try {
sql = queries.get(i);
... | java | private void executeBatch(Results results, final List<String> queries)
throws SQLException {
if (!options.useBatchMultiSend) {
String sql = null;
SQLException exception = null;
for (int i = 0; i < queries.size() && !isInterrupted(); i++) {
try {
sql = queries.get(i);
... | [
"private",
"void",
"executeBatch",
"(",
"Results",
"results",
",",
"final",
"List",
"<",
"String",
">",
"queries",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"!",
"options",
".",
"useBatchMultiSend",
")",
"{",
"String",
"sql",
"=",
"null",
";",
"SQLExc... | Execute list of queries not rewritable.
@param results result object
@param queries list of queries
@throws SQLException exception | [
"Execute",
"list",
"of",
"queries",
"not",
"rewritable",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L702-L783 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.prepare | @Override
public ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException {
cmdPrologue();
lock.lock();
try {
if (options.cachePrepStmts && options.useServerPrepStmts) {
ServerPrepareResult pr = serverPrepareStatementCache.get(database + "-" + sql);
if ... | java | @Override
public ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException {
cmdPrologue();
lock.lock();
try {
if (options.cachePrepStmts && options.useServerPrepStmts) {
ServerPrepareResult pr = serverPrepareStatementCache.get(database + "-" + sql);
if ... | [
"@",
"Override",
"public",
"ServerPrepareResult",
"prepare",
"(",
"String",
"sql",
",",
"boolean",
"executeOnMaster",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"options",
".... | Prepare query on server side. Will permit to know the parameter number of the query, and permit
to send only the data on next results.
<p>For failover, two additional information are in the result-set object : - current
connection : Since server maintain a state of this prepare statement, all query will be
executed on... | [
"Prepare",
"query",
"on",
"server",
"side",
".",
"Will",
"permit",
"to",
"know",
"the",
"parameter",
"number",
"of",
"the",
"query",
"and",
"permit",
"to",
"send",
"only",
"the",
"data",
"on",
"next",
"results",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L801-L828 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executeBatchRewrite | private void executeBatchRewrite(Results results,
final ClientPrepareResult prepareResult, List<ParameterHolder[]> parameterList,
boolean rewriteValues) throws SQLException {
cmdPrologue();
ParameterHolder[] parameters;
int currentIndex = 0;
int totalParameterList = parameterList.size();
... | java | private void executeBatchRewrite(Results results,
final ClientPrepareResult prepareResult, List<ParameterHolder[]> parameterList,
boolean rewriteValues) throws SQLException {
cmdPrologue();
ParameterHolder[] parameters;
int currentIndex = 0;
int totalParameterList = parameterList.size();
... | [
"private",
"void",
"executeBatchRewrite",
"(",
"Results",
"results",
",",
"final",
"ClientPrepareResult",
"prepareResult",
",",
"List",
"<",
"ParameterHolder",
"[",
"]",
">",
"parameterList",
",",
"boolean",
"rewriteValues",
")",
"throws",
"SQLException",
"{",
"cmdP... | Specific execution for batch rewrite that has specific query for memory.
@param results result
@param prepareResult prepareResult
@param parameterList parameters
@param rewriteValues is rewritable flag
@throws SQLException exception | [
"Specific",
"execution",
"for",
"batch",
"rewrite",
"that",
"has",
"specific",
"query",
"for",
"memory",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L892-L924 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executeBatchServer | public boolean executeBatchServer(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results, String sql, final List<ParameterHolder[]> parametersList,
boolean hasLongData) throws SQLException {
cmdPrologue();
if (options.useBulkStmts
&& !hasLongData
... | java | public boolean executeBatchServer(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results, String sql, final List<ParameterHolder[]> parametersList,
boolean hasLongData) throws SQLException {
cmdPrologue();
if (options.useBulkStmts
&& !hasLongData
... | [
"public",
"boolean",
"executeBatchServer",
"(",
"boolean",
"mustExecuteOnMaster",
",",
"ServerPrepareResult",
"serverPrepareResult",
",",
"Results",
"results",
",",
"String",
"sql",
",",
"final",
"List",
"<",
"ParameterHolder",
"[",
"]",
">",
"parametersList",
",",
... | Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch.
@param mustExecuteOnMaster must normally be executed on master connection
@param serverPrepareResult prepare result. can be null if not prepared.
@param results execution results
@param sql sql query if needed to be p... | [
"Execute",
"Prepare",
"if",
"needed",
"and",
"execute",
"COM_STMT_EXECUTE",
"queries",
"in",
"batch",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L938-L1011 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.executePreparedQuery | @Override
public void executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult, Results results,
ParameterHolder[] parameters)
throws SQLException {
cmdPrologue();
try {
int parameterCount = serverPrepareResult.getParameters().length;
//send b... | java | @Override
public void executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult, Results results,
ParameterHolder[] parameters)
throws SQLException {
cmdPrologue();
try {
int parameterCount = serverPrepareResult.getParameters().length;
//send b... | [
"@",
"Override",
"public",
"void",
"executePreparedQuery",
"(",
"boolean",
"mustExecuteOnMaster",
",",
"ServerPrepareResult",
"serverPrepareResult",
",",
"Results",
"results",
",",
"ParameterHolder",
"[",
"]",
"parameters",
")",
"throws",
"SQLException",
"{",
"cmdProlog... | Execute a query that is already prepared.
@param mustExecuteOnMaster must execute on master
@param serverPrepareResult prepare result
@param results execution result
@param parameters parameters
@throws SQLException exception | [
"Execute",
"a",
"query",
"that",
"is",
"already",
"prepared",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1022-L1056 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.rollback | public void rollback() throws SQLException {
cmdPrologue();
lock.lock();
try {
if (inTransaction()) {
executeQuery("ROLLBACK");
}
} catch (Exception e) {
/* eat exception */
} finally {
lock.unlock();
}
} | java | public void rollback() throws SQLException {
cmdPrologue();
lock.lock();
try {
if (inTransaction()) {
executeQuery("ROLLBACK");
}
} catch (Exception e) {
/* eat exception */
} finally {
lock.unlock();
}
} | [
"public",
"void",
"rollback",
"(",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"inTransaction",
"(",
")",
")",
"{",
"executeQuery",
"(",
"\"ROLLBACK\"",
")",
";",
"}",
"... | Rollback transaction. | [
"Rollback",
"transaction",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1061-L1077 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.forceReleasePrepareStatement | public boolean forceReleasePrepareStatement(int statementId) throws SQLException {
if (lock.tryLock()) {
try {
checkClose();
try {
writer.startPacket(0);
writer.write(COM_STMT_CLOSE);
writer.writeInt(statementId);
writer.flush();
return tru... | java | public boolean forceReleasePrepareStatement(int statementId) throws SQLException {
if (lock.tryLock()) {
try {
checkClose();
try {
writer.startPacket(0);
writer.write(COM_STMT_CLOSE);
writer.writeInt(statementId);
writer.flush();
return tru... | [
"public",
"boolean",
"forceReleasePrepareStatement",
"(",
"int",
"statementId",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"lock",
".",
"tryLock",
"(",
")",
")",
"{",
"try",
"{",
"checkClose",
"(",
")",
";",
"try",
"{",
"writer",
".",
"startPacket",
"(... | Force release of prepare statement that are not used. This method will be call when adding a
new prepare statement in cache, so the packet can be send to server without problem.
@param statementId prepared statement Id to remove.
@return true if successfully released
@throws SQLException if connection exception. | [
"Force",
"release",
"of",
"prepare",
"statement",
"that",
"are",
"not",
"used",
".",
"This",
"method",
"will",
"be",
"call",
"when",
"adding",
"a",
"new",
"prepare",
"statement",
"in",
"cache",
"so",
"the",
"packet",
"can",
"be",
"send",
"to",
"server",
... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1087-L1117 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.cancelCurrentQuery | @Override
public void cancelCurrentQuery() throws SQLException {
try (MasterProtocol copiedProtocol = new MasterProtocol(urlParser, new GlobalStateInfo(),
new ReentrantLock())) {
copiedProtocol.setHostAddress(getHostAddress());
copiedProtocol.connect();
//no lock, because there is alread... | java | @Override
public void cancelCurrentQuery() throws SQLException {
try (MasterProtocol copiedProtocol = new MasterProtocol(urlParser, new GlobalStateInfo(),
new ReentrantLock())) {
copiedProtocol.setHostAddress(getHostAddress());
copiedProtocol.connect();
//no lock, because there is alread... | [
"@",
"Override",
"public",
"void",
"cancelCurrentQuery",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"MasterProtocol",
"copiedProtocol",
"=",
"new",
"MasterProtocol",
"(",
"urlParser",
",",
"new",
"GlobalStateInfo",
"(",
")",
",",
"new",
"ReentrantLock",
... | Cancels the current query - clones the current protocol and executes a query using the new
connection.
@throws SQLException never thrown | [
"Cancels",
"the",
"current",
"query",
"-",
"clones",
"the",
"current",
"protocol",
"and",
"executes",
"a",
"query",
"using",
"the",
"new",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1270-L1280 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.releasePrepareStatement | @Override
public void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException {
//If prepared cache is enable, the ServerPrepareResult can be shared in many PrepStatement,
//so synchronised use count indicator will be decrement.
serverPrepareResult.decrementShareCounter();
... | java | @Override
public void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException {
//If prepared cache is enable, the ServerPrepareResult can be shared in many PrepStatement,
//so synchronised use count indicator will be decrement.
serverPrepareResult.decrementShareCounter();
... | [
"@",
"Override",
"public",
"void",
"releasePrepareStatement",
"(",
"ServerPrepareResult",
"serverPrepareResult",
")",
"throws",
"SQLException",
"{",
"//If prepared cache is enable, the ServerPrepareResult can be shared in many PrepStatement,",
"//so synchronised use count indicator will be... | Deallocate prepare statement if not used anymore.
@param serverPrepareResult allocation result
@throws SQLException if de-allocation failed. | [
"Deallocate",
"prepare",
"statement",
"if",
"not",
"used",
"anymore",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1308-L1318 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.setTimeout | @Override
public void setTimeout(int timeout) throws SocketException {
lock.lock();
try {
this.socket.setSoTimeout(timeout);
} finally {
lock.unlock();
}
} | java | @Override
public void setTimeout(int timeout) throws SocketException {
lock.lock();
try {
this.socket.setSoTimeout(timeout);
} finally {
lock.unlock();
}
} | [
"@",
"Override",
"public",
"void",
"setTimeout",
"(",
"int",
"timeout",
")",
"throws",
"SocketException",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"socket",
".",
"setSoTimeout",
"(",
"timeout",
")",
";",
"}",
"finally",
"{",
"l... | Sets the connection timeout.
@param timeout the timeout, in milliseconds
@throws SocketException if there is an error in the underlying protocol, such as a TCP error. | [
"Sets",
"the",
"connection",
"timeout",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1358-L1366 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.setTransactionIsolation | public void setTransactionIsolation(final int level) throws SQLException {
cmdPrologue();
lock.lock();
try {
String query = "SET SESSION TRANSACTION ISOLATION LEVEL";
switch (level) {
case Connection.TRANSACTION_READ_UNCOMMITTED:
query += " READ UNCOMMITTED";
break;
... | java | public void setTransactionIsolation(final int level) throws SQLException {
cmdPrologue();
lock.lock();
try {
String query = "SET SESSION TRANSACTION ISOLATION LEVEL";
switch (level) {
case Connection.TRANSACTION_READ_UNCOMMITTED:
query += " READ UNCOMMITTED";
break;
... | [
"public",
"void",
"setTransactionIsolation",
"(",
"final",
"int",
"level",
")",
"throws",
"SQLException",
"{",
"cmdPrologue",
"(",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"String",
"query",
"=",
"\"SET SESSION TRANSACTION ISOLATION LEVEL\"",
";... | Set transaction isolation.
@param level transaction level.
@throws SQLException if transaction level is unknown | [
"Set",
"transaction",
"isolation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1374-L1400 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readPacket | private void readPacket(Results results) throws SQLException {
Buffer buffer;
try {
buffer = reader.getPacket(true);
} catch (IOException e) {
throw handleIoException(e);
}
switch (buffer.getByteAt(0)) {
//**************************************************************************... | java | private void readPacket(Results results) throws SQLException {
Buffer buffer;
try {
buffer = reader.getPacket(true);
} catch (IOException e) {
throw handleIoException(e);
}
switch (buffer.getByteAt(0)) {
//**************************************************************************... | [
"private",
"void",
"readPacket",
"(",
"Results",
"results",
")",
"throws",
"SQLException",
"{",
"Buffer",
"buffer",
";",
"try",
"{",
"buffer",
"=",
"reader",
".",
"getPacket",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw... | Read server response packet.
@param results result object
@throws SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/4-server-response-packets/">server response
packets</a> | [
"Read",
"server",
"response",
"packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1432-L1471 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readOkPacket | private void readOkPacket(Buffer buffer, Results results) {
buffer.skipByte(); //fieldCount
final long updateCount = buffer.getLengthEncodedNumeric();
final long insertId = buffer.getLengthEncodedNumeric();
serverStatus = buffer.readShort();
hasWarnings = (buffer.readShort() > 0);
if ((serverS... | java | private void readOkPacket(Buffer buffer, Results results) {
buffer.skipByte(); //fieldCount
final long updateCount = buffer.getLengthEncodedNumeric();
final long insertId = buffer.getLengthEncodedNumeric();
serverStatus = buffer.readShort();
hasWarnings = (buffer.readShort() > 0);
if ((serverS... | [
"private",
"void",
"readOkPacket",
"(",
"Buffer",
"buffer",
",",
"Results",
"results",
")",
"{",
"buffer",
".",
"skipByte",
"(",
")",
";",
"//fieldCount",
"final",
"long",
"updateCount",
"=",
"buffer",
".",
"getLengthEncodedNumeric",
"(",
")",
";",
"final",
... | Read OK_Packet.
@param buffer current buffer
@param results result object
@see <a href="https://mariadb.com/kb/en/mariadb/ok_packet/">OK_Packet</a> | [
"Read",
"OK_Packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1480-L1493 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readErrorPacket | private SQLException readErrorPacket(Buffer buffer, Results results) {
removeHasMoreResults();
this.hasWarnings = false;
buffer.skipByte();
final int errorNumber = buffer.readShort();
String message;
String sqlState;
if (buffer.readByte() == '#') {
sqlState = new String(buffer.readRawB... | java | private SQLException readErrorPacket(Buffer buffer, Results results) {
removeHasMoreResults();
this.hasWarnings = false;
buffer.skipByte();
final int errorNumber = buffer.readShort();
String message;
String sqlState;
if (buffer.readByte() == '#') {
sqlState = new String(buffer.readRawB... | [
"private",
"SQLException",
"readErrorPacket",
"(",
"Buffer",
"buffer",
",",
"Results",
"results",
")",
"{",
"removeHasMoreResults",
"(",
")",
";",
"this",
".",
"hasWarnings",
"=",
"false",
";",
"buffer",
".",
"skipByte",
"(",
")",
";",
"final",
"int",
"error... | Read ERR_Packet.
@param buffer current buffer
@param results result object
@return SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/err_packet/">ERR_Packet</a> | [
"Read",
"ERR_Packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1571-L1595 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readLocalInfilePacket | private void readLocalInfilePacket(Buffer buffer, Results results) throws SQLException {
int seq = 2;
buffer.getLengthEncodedNumeric(); //field pos
String fileName = buffer.readStringNullEnd(StandardCharsets.UTF_8);
try {
// Server request the local file (LOCAL DATA LOCAL INFILE)
// We do a... | java | private void readLocalInfilePacket(Buffer buffer, Results results) throws SQLException {
int seq = 2;
buffer.getLengthEncodedNumeric(); //field pos
String fileName = buffer.readStringNullEnd(StandardCharsets.UTF_8);
try {
// Server request the local file (LOCAL DATA LOCAL INFILE)
// We do a... | [
"private",
"void",
"readLocalInfilePacket",
"(",
"Buffer",
"buffer",
",",
"Results",
"results",
")",
"throws",
"SQLException",
"{",
"int",
"seq",
"=",
"2",
";",
"buffer",
".",
"getLengthEncodedNumeric",
"(",
")",
";",
"//field pos",
"String",
"fileName",
"=",
... | Read Local_infile Packet.
@param buffer current buffer
@param results result object
@throws SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/local_infile-packet/">local_infile packet</a> | [
"Read",
"Local_infile",
"Packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1605-L1678 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readResultSet | private void readResultSet(Buffer buffer, Results results) throws SQLException {
long fieldCount = buffer.getLengthEncodedNumeric();
try {
//read columns information's
ColumnInformation[] ci = new ColumnInformation[(int) fieldCount];
for (int i = 0; i < fieldCount; i++) {
ci[i] = new... | java | private void readResultSet(Buffer buffer, Results results) throws SQLException {
long fieldCount = buffer.getLengthEncodedNumeric();
try {
//read columns information's
ColumnInformation[] ci = new ColumnInformation[(int) fieldCount];
for (int i = 0; i < fieldCount; i++) {
ci[i] = new... | [
"private",
"void",
"readResultSet",
"(",
"Buffer",
"buffer",
",",
"Results",
"results",
")",
"throws",
"SQLException",
"{",
"long",
"fieldCount",
"=",
"buffer",
".",
"getLengthEncodedNumeric",
"(",
")",
";",
"try",
"{",
"//read columns information's",
"ColumnInforma... | Read ResultSet Packet.
@param buffer current buffer
@param results result object
@throws SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/resultset/">resultSet packets</a> | [
"Read",
"ResultSet",
"Packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1688-L1735 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.prolog | public void prolog(long maxRows, boolean hasProxy, MariaDbConnection connection,
MariaDbStatement statement)
throws SQLException {
if (explicitClosed) {
throw new SQLException("execute() is called on closed connection");
}
//old failover handling
if (!hasProxy && shouldReconnectWithout... | java | public void prolog(long maxRows, boolean hasProxy, MariaDbConnection connection,
MariaDbStatement statement)
throws SQLException {
if (explicitClosed) {
throw new SQLException("execute() is called on closed connection");
}
//old failover handling
if (!hasProxy && shouldReconnectWithout... | [
"public",
"void",
"prolog",
"(",
"long",
"maxRows",
",",
"boolean",
"hasProxy",
",",
"MariaDbConnection",
"connection",
",",
"MariaDbStatement",
"statement",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"explicitClosed",
")",
"{",
"throw",
"new",
"SQLException",... | Preparation before command.
@param maxRows query max rows
@param hasProxy has proxy
@param connection current connection
@param statement current statement
@throws SQLException if any error occur. | [
"Preparation",
"before",
"command",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1751-L1773 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.handleIoException | public SQLException handleIoException(Exception initialException) {
boolean mustReconnect;
boolean driverPreventError = false;
if (initialException instanceof MaxAllowedPacketException) {
mustReconnect = ((MaxAllowedPacketException) initialException).isMustReconnect();
driverPreventError = !mus... | java | public SQLException handleIoException(Exception initialException) {
boolean mustReconnect;
boolean driverPreventError = false;
if (initialException instanceof MaxAllowedPacketException) {
mustReconnect = ((MaxAllowedPacketException) initialException).isMustReconnect();
driverPreventError = !mus... | [
"public",
"SQLException",
"handleIoException",
"(",
"Exception",
"initialException",
")",
"{",
"boolean",
"mustReconnect",
";",
"boolean",
"driverPreventError",
"=",
"false",
";",
"if",
"(",
"initialException",
"instanceof",
"MaxAllowedPacketException",
")",
"{",
"mustR... | Handle IoException (reconnect if Exception is due to having send too much data, making server
close the connection.
<p>There is 3 kind of IOException :</p>
<ol>
<li> MaxAllowedPacketException :
without need of reconnect : thrown when driver don't send packet that would have been too big
then error is not a CONNECTION_... | [
"Handle",
"IoException",
"(",
"reconnect",
"if",
"Exception",
"is",
"due",
"to",
"having",
"send",
"too",
"much",
"data",
"making",
"server",
"close",
"the",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1857-L1897 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/parameters/TimeParameter.java | TimeParameter.writeTo | public void writeTo(final PacketOutputStream pos) throws IOException {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone(timeZone);
String dateString = sdf.format(time);
pos.write(QUOTE);
pos.write(dateString.getBytes());
int microseconds = (int) (time.getTime() % 1000) *... | java | public void writeTo(final PacketOutputStream pos) throws IOException {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone(timeZone);
String dateString = sdf.format(time);
pos.write(QUOTE);
pos.write(dateString.getBytes());
int microseconds = (int) (time.getTime() % 1000) *... | [
"public",
"void",
"writeTo",
"(",
"final",
"PacketOutputStream",
"pos",
")",
"throws",
"IOException",
"{",
"SimpleDateFormat",
"sdf",
"=",
"new",
"SimpleDateFormat",
"(",
"\"HH:mm:ss\"",
")",
";",
"sdf",
".",
"setTimeZone",
"(",
"timeZone",
")",
";",
"String",
... | Write Time parameter to outputStream.
@param pos the stream to write to | [
"Write",
"Time",
"parameter",
"to",
"outputStream",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/parameters/TimeParameter.java#L88-L107 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/Driver.java | Driver.connect | public Connection connect(final String url, final Properties props) throws SQLException {
UrlParser urlParser = UrlParser.parse(url, props);
if (urlParser == null || urlParser.getHostAddresses() == null) {
return null;
} else {
return MariaDbConnection.newConnection(urlParser, null);
}
} | java | public Connection connect(final String url, final Properties props) throws SQLException {
UrlParser urlParser = UrlParser.parse(url, props);
if (urlParser == null || urlParser.getHostAddresses() == null) {
return null;
} else {
return MariaDbConnection.newConnection(urlParser, null);
}
} | [
"public",
"Connection",
"connect",
"(",
"final",
"String",
"url",
",",
"final",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"UrlParser",
"urlParser",
"=",
"UrlParser",
".",
"parse",
"(",
"url",
",",
"props",
")",
";",
"if",
"(",
"urlParser",
... | Connect to the given connection string.
@param url the url to connect to
@return a connection
@throws SQLException if it is not possible to connect | [
"Connect",
"to",
"the",
"given",
"connection",
"string",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/Driver.java#L86-L95 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/Driver.java | Driver.getPropertyInfo | public DriverPropertyInfo[] getPropertyInfo(String url,
Properties info)
throws SQLException {
if (url != null) {
UrlParser urlParser = UrlParser.parse(url, info);
if (urlParser == null || urlParser.getOptions() == null) {
return new DriverPropertyInfo[0];
}
List<DriverP... | java | public DriverPropertyInfo[] getPropertyInfo(String url,
Properties info)
throws SQLException {
if (url != null) {
UrlParser urlParser = UrlParser.parse(url, info);
if (urlParser == null || urlParser.getOptions() == null) {
return new DriverPropertyInfo[0];
}
List<DriverP... | [
"public",
"DriverPropertyInfo",
"[",
"]",
"getPropertyInfo",
"(",
"String",
"url",
",",
"Properties",
"info",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"UrlParser",
"urlParser",
"=",
"UrlParser",
".",
"parse",
"(",
"url",
... | Get the property info.
@param url the url to get properties for
@param info the info props
@return something - not implemented
@throws SQLException if there is a problem getting the property info | [
"Get",
"the",
"property",
"info",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/Driver.java#L116-L143 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.initializeConnection | @Override
public void initializeConnection() throws SQLException {
super.initializeConnection();
try {
reconnectFailedConnection(new SearchFilter(true));
} catch (SQLException e) {
//initializeConnection failed
checkInitialConnection(e);
}
} | java | @Override
public void initializeConnection() throws SQLException {
super.initializeConnection();
try {
reconnectFailedConnection(new SearchFilter(true));
} catch (SQLException e) {
//initializeConnection failed
checkInitialConnection(e);
}
} | [
"@",
"Override",
"public",
"void",
"initializeConnection",
"(",
")",
"throws",
"SQLException",
"{",
"super",
".",
"initializeConnection",
"(",
")",
";",
"try",
"{",
"reconnectFailedConnection",
"(",
"new",
"SearchFilter",
"(",
"true",
")",
")",
";",
"}",
"catc... | Initialize connections.
@throws SQLException if a connection error append. | [
"Initialize",
"connections",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L166-L175 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.checkWaitingConnection | public void checkWaitingConnection() throws SQLException {
if (isSecondaryHostFail()) {
proxy.lock.lock();
try {
Protocol waitingProtocol = waitNewSecondaryProtocol.getAndSet(null);
if (waitingProtocol != null && pingSecondaryProtocol(waitingProtocol)) {
lockAndSwitchSecondary(... | java | public void checkWaitingConnection() throws SQLException {
if (isSecondaryHostFail()) {
proxy.lock.lock();
try {
Protocol waitingProtocol = waitNewSecondaryProtocol.getAndSet(null);
if (waitingProtocol != null && pingSecondaryProtocol(waitingProtocol)) {
lockAndSwitchSecondary(... | [
"public",
"void",
"checkWaitingConnection",
"(",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"isSecondaryHostFail",
"(",
")",
")",
"{",
"proxy",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"Protocol",
"waitingProtocol",
"=",
"waitNewSecondaryProtoc... | Verify that there is waiting connection that have to replace failing one. If there is replace
failed connection with new one.
@throws SQLException if error occur | [
"Verify",
"that",
"there",
"is",
"waiting",
"connection",
"that",
"have",
"to",
"replace",
"failing",
"one",
".",
"If",
"there",
"is",
"replace",
"failed",
"connection",
"with",
"new",
"one",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L439-L463 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.reconnectFailedConnection | public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException {
if (!searchFilter.isInitialConnection()
&& (isExplicitClosed()
|| (searchFilter.isFineIfFoundOnlyMaster() && !isMasterHostFail())
|| searchFilter.isFineIfFoundOnlySlave() && !isSecondaryHostFail())) {
... | java | public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException {
if (!searchFilter.isInitialConnection()
&& (isExplicitClosed()
|| (searchFilter.isFineIfFoundOnlyMaster() && !isMasterHostFail())
|| searchFilter.isFineIfFoundOnlySlave() && !isSecondaryHostFail())) {
... | [
"public",
"void",
"reconnectFailedConnection",
"(",
"SearchFilter",
"searchFilter",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"!",
"searchFilter",
".",
"isInitialConnection",
"(",
")",
"&&",
"(",
"isExplicitClosed",
"(",
")",
"||",
"(",
"searchFilter",
".",
... | Loop to connect.
@throws SQLException if there is any error during reconnection | [
"Loop",
"to",
"connect",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L471-L544 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.foundActiveMaster | public void foundActiveMaster(Protocol newMasterProtocol) {
if (isMasterHostFail()) {
if (isExplicitClosed()) {
newMasterProtocol.close();
return;
}
if (!waitNewMasterProtocol.compareAndSet(null, newMasterProtocol)) {
newMasterProtocol.close();
}
} else {
ne... | java | public void foundActiveMaster(Protocol newMasterProtocol) {
if (isMasterHostFail()) {
if (isExplicitClosed()) {
newMasterProtocol.close();
return;
}
if (!waitNewMasterProtocol.compareAndSet(null, newMasterProtocol)) {
newMasterProtocol.close();
}
} else {
ne... | [
"public",
"void",
"foundActiveMaster",
"(",
"Protocol",
"newMasterProtocol",
")",
"{",
"if",
"(",
"isMasterHostFail",
"(",
")",
")",
"{",
"if",
"(",
"isExplicitClosed",
"(",
")",
")",
"{",
"newMasterProtocol",
".",
"close",
"(",
")",
";",
"return",
";",
"}... | Method called when a new Master connection is found after a fallback.
@param newMasterProtocol the new active connection | [
"Method",
"called",
"when",
"a",
"new",
"Master",
"connection",
"is",
"found",
"after",
"a",
"fallback",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L551-L564 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.lockAndSwitchMaster | public void lockAndSwitchMaster(Protocol newMasterProtocol)
throws ReconnectDuringTransactionException {
if (masterProtocol != null && !masterProtocol.isClosed()) {
masterProtocol.close();
}
if (!currentReadOnlyAsked || isSecondaryHostFail()) {
//actually on a secondary read-only because ... | java | public void lockAndSwitchMaster(Protocol newMasterProtocol)
throws ReconnectDuringTransactionException {
if (masterProtocol != null && !masterProtocol.isClosed()) {
masterProtocol.close();
}
if (!currentReadOnlyAsked || isSecondaryHostFail()) {
//actually on a secondary read-only because ... | [
"public",
"void",
"lockAndSwitchMaster",
"(",
"Protocol",
"newMasterProtocol",
")",
"throws",
"ReconnectDuringTransactionException",
"{",
"if",
"(",
"masterProtocol",
"!=",
"null",
"&&",
"!",
"masterProtocol",
".",
"isClosed",
"(",
")",
")",
"{",
"masterProtocol",
"... | Use the parameter newMasterProtocol as new current master connection.
<i>Lock must be set</i>
@param newMasterProtocol new master connection
@throws ReconnectDuringTransactionException if there was an active transaction. | [
"Use",
"the",
"parameter",
"newMasterProtocol",
"as",
"new",
"current",
"master",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L574-L603 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.foundActiveSecondary | public void foundActiveSecondary(Protocol newSecondaryProtocol) throws SQLException {
if (isSecondaryHostFail()) {
if (isExplicitClosed()) {
newSecondaryProtocol.close();
return;
}
if (proxy.lock.tryLock()) {
try {
lockAndSwitchSecondary(newSecondaryProtocol);
... | java | public void foundActiveSecondary(Protocol newSecondaryProtocol) throws SQLException {
if (isSecondaryHostFail()) {
if (isExplicitClosed()) {
newSecondaryProtocol.close();
return;
}
if (proxy.lock.tryLock()) {
try {
lockAndSwitchSecondary(newSecondaryProtocol);
... | [
"public",
"void",
"foundActiveSecondary",
"(",
"Protocol",
"newSecondaryProtocol",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"isSecondaryHostFail",
"(",
")",
")",
"{",
"if",
"(",
"isExplicitClosed",
"(",
")",
")",
"{",
"newSecondaryProtocol",
".",
"close",
... | Method called when a new secondary connection is found after a fallback.
@param newSecondaryProtocol the new active connection
@throws SQLException if switch failed | [
"Method",
"called",
"when",
"a",
"new",
"secondary",
"connection",
"is",
"found",
"after",
"a",
"fallback",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L611-L632 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.lockAndSwitchSecondary | public void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws SQLException {
if (secondaryProtocol != null && !secondaryProtocol.isClosed()) {
secondaryProtocol.close();
}
//if asked to be on read only connection, switching to this new connection
if (currentReadOnlyAsked || (urlParser.... | java | public void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws SQLException {
if (secondaryProtocol != null && !secondaryProtocol.isClosed()) {
secondaryProtocol.close();
}
//if asked to be on read only connection, switching to this new connection
if (currentReadOnlyAsked || (urlParser.... | [
"public",
"void",
"lockAndSwitchSecondary",
"(",
"Protocol",
"newSecondaryProtocol",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"secondaryProtocol",
"!=",
"null",
"&&",
"!",
"secondaryProtocol",
".",
"isClosed",
"(",
")",
")",
"{",
"secondaryProtocol",
".",
"c... | Use the parameter newSecondaryProtocol as new current secondary connection.
@param newSecondaryProtocol new secondary connection
@throws SQLException if an error occur during setting session read-only | [
"Use",
"the",
"parameter",
"newSecondaryProtocol",
"as",
"new",
"current",
"secondary",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L640-L665 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.primaryFail | public HandleErrorResult primaryFail(Method method, Object[] args, boolean killCmd) {
boolean alreadyClosed = masterProtocol == null || !masterProtocol.isConnected();
boolean inTransaction = masterProtocol != null && masterProtocol.inTransaction();
//in case of SocketTimeoutException due to having set sock... | java | public HandleErrorResult primaryFail(Method method, Object[] args, boolean killCmd) {
boolean alreadyClosed = masterProtocol == null || !masterProtocol.isConnected();
boolean inTransaction = masterProtocol != null && masterProtocol.inTransaction();
//in case of SocketTimeoutException due to having set sock... | [
"public",
"HandleErrorResult",
"primaryFail",
"(",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
",",
"boolean",
"killCmd",
")",
"{",
"boolean",
"alreadyClosed",
"=",
"masterProtocol",
"==",
"null",
"||",
"!",
"masterProtocol",
".",
"isConnected",
"(",
... | To handle the newly detected failover on the master connection.
@param method the initial called method
@param args the initial args
@param killCmd is the fail due to a KILL cmd
@return an object to indicate if the previous Exception must be thrown, or the object resulting
if a failover worked | [
"To",
"handle",
"the",
"newly",
"detected",
"failover",
"on",
"the",
"master",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L781-L857 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.reconnect | public void reconnect() throws SQLException {
SearchFilter filter;
boolean inTransaction = false;
if (currentReadOnlyAsked) {
filter = new SearchFilter(true, true);
} else {
inTransaction = masterProtocol != null && masterProtocol.inTransaction();
filter = new SearchFilter(true, urlPar... | java | public void reconnect() throws SQLException {
SearchFilter filter;
boolean inTransaction = false;
if (currentReadOnlyAsked) {
filter = new SearchFilter(true, true);
} else {
inTransaction = masterProtocol != null && masterProtocol.inTransaction();
filter = new SearchFilter(true, urlPar... | [
"public",
"void",
"reconnect",
"(",
")",
"throws",
"SQLException",
"{",
"SearchFilter",
"filter",
";",
"boolean",
"inTransaction",
"=",
"false",
";",
"if",
"(",
"currentReadOnlyAsked",
")",
"{",
"filter",
"=",
"new",
"SearchFilter",
"(",
"true",
",",
"true",
... | Reconnect failed connection.
@throws SQLException if reconnection has failed | [
"Reconnect",
"failed",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L876-L891 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.pingSecondaryProtocol | private boolean pingSecondaryProtocol(Protocol protocol) {
try {
if (protocol != null && protocol.isConnected() && protocol.ping()) {
return true;
}
} catch (Exception e) {
protocol.close();
if (setSecondaryHostFail()) {
addToBlacklist(protocol.getHostAddress());
}... | java | private boolean pingSecondaryProtocol(Protocol protocol) {
try {
if (protocol != null && protocol.isConnected() && protocol.ping()) {
return true;
}
} catch (Exception e) {
protocol.close();
if (setSecondaryHostFail()) {
addToBlacklist(protocol.getHostAddress());
}... | [
"private",
"boolean",
"pingSecondaryProtocol",
"(",
"Protocol",
"protocol",
")",
"{",
"try",
"{",
"if",
"(",
"protocol",
"!=",
"null",
"&&",
"protocol",
".",
"isConnected",
"(",
")",
"&&",
"protocol",
".",
"ping",
"(",
")",
")",
"{",
"return",
"true",
";... | Ping secondary protocol. ! lock must be set !
@param protocol socket to ping
@return true if ping is valid. | [
"Ping",
"secondary",
"protocol",
".",
"!",
"lock",
"must",
"be",
"set",
"!"
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L899-L912 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.secondaryFail | public HandleErrorResult secondaryFail(Method method, Object[] args, boolean killCmd)
throws Throwable {
proxy.lock.lock();
try {
if (pingSecondaryProtocol(this.secondaryProtocol)) {
return relaunchOperation(method, args);
}
} finally {
proxy.lock.unlock();
}
if (!is... | java | public HandleErrorResult secondaryFail(Method method, Object[] args, boolean killCmd)
throws Throwable {
proxy.lock.lock();
try {
if (pingSecondaryProtocol(this.secondaryProtocol)) {
return relaunchOperation(method, args);
}
} finally {
proxy.lock.unlock();
}
if (!is... | [
"public",
"HandleErrorResult",
"secondaryFail",
"(",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
",",
"boolean",
"killCmd",
")",
"throws",
"Throwable",
"{",
"proxy",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"pingSecondaryPro... | To handle the newly detected failover on the secondary connection.
@param method the initial called method
@param args the initial args
@param killCmd is fail due to a KILL command
@return an object to indicate if the previous Exception must be thrown, or the object resulting
if a failover worked
@throws Throwable... | [
"To",
"handle",
"the",
"newly",
"detected",
"failover",
"on",
"the",
"secondary",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L924-L989 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java | MastersSlavesListener.connectedHosts | public List<HostAddress> connectedHosts() {
List<HostAddress> usedHost = new ArrayList<>();
if (isMasterHostFail()) {
Protocol masterProtocol = waitNewMasterProtocol.get();
if (masterProtocol != null) {
usedHost.add(masterProtocol.getHostAddress());
}
} else {
usedHost.add(m... | java | public List<HostAddress> connectedHosts() {
List<HostAddress> usedHost = new ArrayList<>();
if (isMasterHostFail()) {
Protocol masterProtocol = waitNewMasterProtocol.get();
if (masterProtocol != null) {
usedHost.add(masterProtocol.getHostAddress());
}
} else {
usedHost.add(m... | [
"public",
"List",
"<",
"HostAddress",
">",
"connectedHosts",
"(",
")",
"{",
"List",
"<",
"HostAddress",
">",
"usedHost",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"isMasterHostFail",
"(",
")",
")",
"{",
"Protocol",
"masterProtocol",
"=",
"... | List current connected HostAddress.
@return hostAddress List. | [
"List",
"current",
"connected",
"HostAddress",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L1072-L1094 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersSlavesListener.java | AbstractMastersSlavesListener.handleFailover | public HandleErrorResult handleFailover(SQLException qe, Method method, Object[] args,
Protocol protocol) throws Throwable {
if (isExplicitClosed()) {
throw new SQLException("Connection has been closed !");
}
//check that failover is due to kill command
boolean killCmd = qe != null
... | java | public HandleErrorResult handleFailover(SQLException qe, Method method, Object[] args,
Protocol protocol) throws Throwable {
if (isExplicitClosed()) {
throw new SQLException("Connection has been closed !");
}
//check that failover is due to kill command
boolean killCmd = qe != null
... | [
"public",
"HandleErrorResult",
"handleFailover",
"(",
"SQLException",
"qe",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
",",
"Protocol",
"protocol",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"isExplicitClosed",
"(",
")",
")",
"{",
"throw",
"n... | Handle failover on master or slave connection.
@param method called method
@param args methods parameters
@param protocol current protocol
@return HandleErrorResult object to indicate if query has finally been relaunched or exception
if not.
@throws Throwable if method with parameters doesn't exist | [
"Handle",
"failover",
"on",
"master",
"or",
"slave",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersSlavesListener.java#L96-L137 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersSlavesListener.java | AbstractMastersSlavesListener.setSecondaryHostFail | public boolean setSecondaryHostFail() {
if (secondaryHostFail.compareAndSet(false, true)) {
secondaryHostFailNanos = System.nanoTime();
currentConnectionAttempts.set(0);
return true;
}
return false;
} | java | public boolean setSecondaryHostFail() {
if (secondaryHostFail.compareAndSet(false, true)) {
secondaryHostFailNanos = System.nanoTime();
currentConnectionAttempts.set(0);
return true;
}
return false;
} | [
"public",
"boolean",
"setSecondaryHostFail",
"(",
")",
"{",
"if",
"(",
"secondaryHostFail",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"secondaryHostFailNanos",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"currentConnectionAttempts",
".",... | Set slave connection lost variables.
@return true if fail wasn't seen before | [
"Set",
"slave",
"connection",
"lost",
"variables",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersSlavesListener.java#L171-L178 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/io/TraceObject.java | TraceObject.remove | public void remove() {
for (int i = 0; i < buf.length; i++) {
buf[i] = null;// force null for easier garbage
}
buf = null;
} | java | public void remove() {
for (int i = 0; i < buf.length; i++) {
buf[i] = null;// force null for easier garbage
}
buf = null;
} | [
"public",
"void",
"remove",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"buf",
".",
"length",
";",
"i",
"++",
")",
"{",
"buf",
"[",
"i",
"]",
"=",
"null",
";",
"// force null for easier garbage",
"}",
"buf",
"=",
"null",
";",
... | Clear trace array for easy garbage. | [
"Clear",
"trace",
"array",
"for",
"easy",
"garbage",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/io/TraceObject.java#L82-L87 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbDataSource.java | MariaDbDataSource.getPooledConnection | public PooledConnection getPooledConnection(String user, String password) throws SQLException {
return new MariaDbPooledConnection((MariaDbConnection) getConnection(user, password));
} | java | public PooledConnection getPooledConnection(String user, String password) throws SQLException {
return new MariaDbPooledConnection((MariaDbConnection) getConnection(user, password));
} | [
"public",
"PooledConnection",
"getPooledConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"MariaDbPooledConnection",
"(",
"(",
"MariaDbConnection",
")",
"getConnection",
"(",
"user",
",",
"password",
... | Attempts to establish a physical database connection that can be used as a pooled connection.
@param user the database user on whose behalf the connection is being made
@param password the user's password
@return a <code>PooledConnection</code> object that is a physical connection to the database
that this
<code>C... | [
"Attempts",
"to",
"establish",
"a",
"physical",
"database",
"connection",
"that",
"can",
"be",
"used",
"as",
"a",
"pooled",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbDataSource.java#L464-L466 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.initializeConnection | @Override
public void initializeConnection() throws SQLException {
super.initializeConnection();
this.currentProtocol = null;
//launching initial loop
reconnectFailedConnection(new SearchFilter(true, false));
resetMasterFailoverData();
} | java | @Override
public void initializeConnection() throws SQLException {
super.initializeConnection();
this.currentProtocol = null;
//launching initial loop
reconnectFailedConnection(new SearchFilter(true, false));
resetMasterFailoverData();
} | [
"@",
"Override",
"public",
"void",
"initializeConnection",
"(",
")",
"throws",
"SQLException",
"{",
"super",
".",
"initializeConnection",
"(",
")",
";",
"this",
".",
"currentProtocol",
"=",
"null",
";",
"//launching initial loop",
"reconnectFailedConnection",
"(",
"... | Connect to database.
@throws SQLException if connection is on error. | [
"Connect",
"to",
"database",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L97-L104 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.preExecute | public void preExecute() throws SQLException {
lastQueryNanos = System.nanoTime();
//if connection is closed or failed on slave
if (this.currentProtocol != null && this.currentProtocol.isClosed()) {
preAutoReconnect();
}
} | java | public void preExecute() throws SQLException {
lastQueryNanos = System.nanoTime();
//if connection is closed or failed on slave
if (this.currentProtocol != null && this.currentProtocol.isClosed()) {
preAutoReconnect();
}
} | [
"public",
"void",
"preExecute",
"(",
")",
"throws",
"SQLException",
"{",
"lastQueryNanos",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"//if connection is closed or failed on slave",
"if",
"(",
"this",
".",
"currentProtocol",
"!=",
"null",
"&&",
"this",
".",
... | Before executing query, reconnect if connection is closed, and autoReconnect option is set.
@throws SQLException if connection has been explicitly closed. | [
"Before",
"executing",
"query",
"reconnect",
"if",
"connection",
"is",
"closed",
"and",
"autoReconnect",
"option",
"is",
"set",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L111-L117 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.reconnectFailedConnection | @Override
public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException {
proxy.lock.lock();
try {
if (!searchFilter.isInitialConnection()
&& (isExplicitClosed() || !isMasterHostFail())) {
return;
}
currentConnectionAttempts.incrementAndGet();
... | java | @Override
public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException {
proxy.lock.lock();
try {
if (!searchFilter.isInitialConnection()
&& (isExplicitClosed() || !isMasterHostFail())) {
return;
}
currentConnectionAttempts.incrementAndGet();
... | [
"@",
"Override",
"public",
"void",
"reconnectFailedConnection",
"(",
"SearchFilter",
"searchFilter",
")",
"throws",
"SQLException",
"{",
"proxy",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"searchFilter",
".",
"isInitialConnection",
"... | Loop to connect failed hosts.
@param searchFilter search parameters.
@throws SQLException if there is any error during reconnection | [
"Loop",
"to",
"connect",
"failed",
"hosts",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L191-L239 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.switchReadOnlyConnection | public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException {
if (urlParser.getOptions().assureReadOnly && currentReadOnlyAsked != mustBeReadOnly) {
proxy.lock.lock();
try {
// verify not updated now that hold lock, double check safe due to volatile
if (currentReadOn... | java | public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException {
if (urlParser.getOptions().assureReadOnly && currentReadOnlyAsked != mustBeReadOnly) {
proxy.lock.lock();
try {
// verify not updated now that hold lock, double check safe due to volatile
if (currentReadOn... | [
"public",
"void",
"switchReadOnlyConnection",
"(",
"Boolean",
"mustBeReadOnly",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"urlParser",
".",
"getOptions",
"(",
")",
".",
"assureReadOnly",
"&&",
"currentReadOnlyAsked",
"!=",
"mustBeReadOnly",
")",
"{",
"proxy",
... | Force session to read-only according to options.
@param mustBeReadOnly is read-only flag
@throws SQLException if a connection error occur | [
"Force",
"session",
"to",
"read",
"-",
"only",
"according",
"to",
"options",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L247-L260 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.foundActiveMaster | @Override
public void foundActiveMaster(Protocol protocol) throws SQLException {
if (isExplicitClosed()) {
proxy.lock.lock();
try {
protocol.close();
} finally {
proxy.lock.unlock();
}
return;
}
syncConnection(this.currentProtocol, protocol);
proxy.lock.lo... | java | @Override
public void foundActiveMaster(Protocol protocol) throws SQLException {
if (isExplicitClosed()) {
proxy.lock.lock();
try {
protocol.close();
} finally {
proxy.lock.unlock();
}
return;
}
syncConnection(this.currentProtocol, protocol);
proxy.lock.lo... | [
"@",
"Override",
"public",
"void",
"foundActiveMaster",
"(",
"Protocol",
"protocol",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"isExplicitClosed",
"(",
")",
")",
"{",
"proxy",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"protocol",
".",
"cl... | method called when a new Master connection is found after a fallback.
@param protocol the new active connection | [
"method",
"called",
"when",
"a",
"new",
"Master",
"connection",
"is",
"found",
"after",
"a",
"fallback",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L267-L291 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java | MastersFailoverListener.reconnect | public void reconnect() throws SQLException {
boolean inTransaction = currentProtocol != null && currentProtocol.inTransaction();
reconnectFailedConnection(new SearchFilter(true, false));
handleFailLoop();
if (inTransaction) {
throw new ReconnectDuringTransactionException(
"Connection re... | java | public void reconnect() throws SQLException {
boolean inTransaction = currentProtocol != null && currentProtocol.inTransaction();
reconnectFailedConnection(new SearchFilter(true, false));
handleFailLoop();
if (inTransaction) {
throw new ReconnectDuringTransactionException(
"Connection re... | [
"public",
"void",
"reconnect",
"(",
")",
"throws",
"SQLException",
"{",
"boolean",
"inTransaction",
"=",
"currentProtocol",
"!=",
"null",
"&&",
"currentProtocol",
".",
"inTransaction",
"(",
")",
";",
"reconnectFailedConnection",
"(",
"new",
"SearchFilter",
"(",
"t... | Try to reconnect connection.
@throws SQLException if reconnect a new connection but there was an active transaction. | [
"Try",
"to",
"reconnect",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersFailoverListener.java#L298-L306 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/StandardGssapiAuthentication.java | StandardGssapiAuthentication.authenticate | public void authenticate(final PacketOutputStream out, final PacketInputStream in, final AtomicInteger sequence,
final String servicePrincipalName, String mechanisms) throws SQLException, IOException {
if ("".equals(servicePrincipalName)) {
throw new SQLException("No principal name... | java | public void authenticate(final PacketOutputStream out, final PacketInputStream in, final AtomicInteger sequence,
final String servicePrincipalName, String mechanisms) throws SQLException, IOException {
if ("".equals(servicePrincipalName)) {
throw new SQLException("No principal name... | [
"public",
"void",
"authenticate",
"(",
"final",
"PacketOutputStream",
"out",
",",
"final",
"PacketInputStream",
"in",
",",
"final",
"AtomicInteger",
"sequence",
",",
"final",
"String",
"servicePrincipalName",
",",
"String",
"mechanisms",
")",
"throws",
"SQLException",... | Process default GSS plugin authentication.
@param out out stream
@param in in stream
@param sequence packet sequence
@param servicePrincipalName service principal name
@param mechanisms gssapi mechanism
@throws IOException if socket error
@throws SQLExcept... | [
"Process",
"default",
"GSS",
"plugin",
"authentication",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/StandardGssapiAuthentication.java#L89-L172 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/SendHandshakeResponsePacket.java | SendHandshakeResponsePacket.send | public static void send(final PacketOutputStream pos,
final String username,
final String password,
final HostAddress currentHost,
final String database,
final long clientCapabilities,
final long serverCapabilities,
final byte serverLanguage,
final byte packetSeq,
f... | java | public static void send(final PacketOutputStream pos,
final String username,
final String password,
final HostAddress currentHost,
final String database,
final long clientCapabilities,
final long serverCapabilities,
final byte serverLanguage,
final byte packetSeq,
f... | [
"public",
"static",
"void",
"send",
"(",
"final",
"PacketOutputStream",
"pos",
",",
"final",
"String",
"username",
",",
"final",
"String",
"password",
",",
"final",
"HostAddress",
"currentHost",
",",
"final",
"String",
"database",
",",
"final",
"long",
"clientCa... | Send handshake response packet.
@param pos output stream
@param username user name
@param password password
@param currentHost current hostname
@param database database name
@param clientCapabilities client capabilities
@param serverCapabilities server capabilities
@... | [
"Send",
"handshake",
"response",
"packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/SendHandshakeResponsePacket.java#L105-L187 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/HostAddress.java | HostAddress.parse | public static List<HostAddress> parse(String spec, HaMode haMode) {
if (spec == null) {
throw new IllegalArgumentException("Invalid connection URL, host address must not be empty ");
}
if ("".equals(spec)) {
return new ArrayList<>(0);
}
String[] tokens = spec.trim().split(",");
int s... | java | public static List<HostAddress> parse(String spec, HaMode haMode) {
if (spec == null) {
throw new IllegalArgumentException("Invalid connection URL, host address must not be empty ");
}
if ("".equals(spec)) {
return new ArrayList<>(0);
}
String[] tokens = spec.trim().split(",");
int s... | [
"public",
"static",
"List",
"<",
"HostAddress",
">",
"parse",
"(",
"String",
"spec",
",",
"HaMode",
"haMode",
")",
"{",
"if",
"(",
"spec",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid connection URL, host address must not be ... | parse - parse server addresses from the URL fragment.
@param spec list of endpoints in one of the forms 1 - host1,....,hostN:port (missing port
default to MariaDB default 3306 2 - host:port,...,host:port
@param haMode High availability mode
@return parsed endpoints | [
"parse",
"-",
"parse",
"server",
"addresses",
"from",
"the",
"URL",
"fragment",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/HostAddress.java#L109-L152 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/parameters/DateParameter.java | DateParameter.writeTo | public void writeTo(final PacketOutputStream os) throws IOException {
os.write(QUOTE);
os.write(dateByteFormat());
os.write(QUOTE);
} | java | public void writeTo(final PacketOutputStream os) throws IOException {
os.write(QUOTE);
os.write(dateByteFormat());
os.write(QUOTE);
} | [
"public",
"void",
"writeTo",
"(",
"final",
"PacketOutputStream",
"os",
")",
"throws",
"IOException",
"{",
"os",
".",
"write",
"(",
"QUOTE",
")",
";",
"os",
".",
"write",
"(",
"dateByteFormat",
"(",
")",
")",
";",
"os",
".",
"write",
"(",
"QUOTE",
")",
... | Write to server OutputStream in text protocol.
@param os output buffer | [
"Write",
"to",
"server",
"OutputStream",
"in",
"text",
"protocol",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/parameters/DateParameter.java#L89-L93 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtPrepare.java | ComStmtPrepare.read | public ServerPrepareResult read(PacketInputStream reader, boolean eofDeprecated)
throws IOException, SQLException {
Buffer buffer = reader.getPacket(true);
byte firstByte = buffer.getByteAt(buffer.position);
if (firstByte == ERROR) {
throw buildErrorException(buffer);
}
if (firstByte =... | java | public ServerPrepareResult read(PacketInputStream reader, boolean eofDeprecated)
throws IOException, SQLException {
Buffer buffer = reader.getPacket(true);
byte firstByte = buffer.getByteAt(buffer.position);
if (firstByte == ERROR) {
throw buildErrorException(buffer);
}
if (firstByte =... | [
"public",
"ServerPrepareResult",
"read",
"(",
"PacketInputStream",
"reader",
",",
"boolean",
"eofDeprecated",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"Buffer",
"buffer",
"=",
"reader",
".",
"getPacket",
"(",
"true",
")",
";",
"byte",
"firstByte",
... | Read COM_PREPARE_RESULT.
@param reader inputStream
@param eofDeprecated are EOF_packet deprecated
@return ServerPrepareResult prepare result
@throws IOException if connection has error
@throws SQLException if server answer with error. | [
"Read",
"COM_PREPARE_RESULT",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtPrepare.java#L101-L168 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/MastersSlavesProtocol.java | MastersSlavesProtocol.resetHostList | private static void resetHostList(MastersSlavesListener listener,
Deque<HostAddress> loopAddresses) {
//if all servers have been connected without result
//add back all servers
List<HostAddress> servers = new ArrayList<>();
servers.addAll(listener.getUrlParser().getHostAddresses());
Collection... | java | private static void resetHostList(MastersSlavesListener listener,
Deque<HostAddress> loopAddresses) {
//if all servers have been connected without result
//add back all servers
List<HostAddress> servers = new ArrayList<>();
servers.addAll(listener.getUrlParser().getHostAddresses());
Collection... | [
"private",
"static",
"void",
"resetHostList",
"(",
"MastersSlavesListener",
"listener",
",",
"Deque",
"<",
"HostAddress",
">",
"loopAddresses",
")",
"{",
"//if all servers have been connected without result",
"//add back all servers",
"List",
"<",
"HostAddress",
">",
"serve... | Reinitialize loopAddresses with all servers in randomize order.
@param listener current listener
@param loopAddresses the list to reinitialize | [
"Reinitialize",
"loopAddresses",
"with",
"all",
"servers",
"in",
"randomize",
"order",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/MastersSlavesProtocol.java#L202-L215 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java | MariaDbPooledConnection.fireStatementClosed | public void fireStatementClosed(Statement st) {
if (st instanceof PreparedStatement) {
StatementEvent event = new StatementEvent(this, (PreparedStatement) st);
for (StatementEventListener listener : statementEventListeners) {
listener.statementClosed(event);
}
}
} | java | public void fireStatementClosed(Statement st) {
if (st instanceof PreparedStatement) {
StatementEvent event = new StatementEvent(this, (PreparedStatement) st);
for (StatementEventListener listener : statementEventListeners) {
listener.statementClosed(event);
}
}
} | [
"public",
"void",
"fireStatementClosed",
"(",
"Statement",
"st",
")",
"{",
"if",
"(",
"st",
"instanceof",
"PreparedStatement",
")",
"{",
"StatementEvent",
"event",
"=",
"new",
"StatementEvent",
"(",
"this",
",",
"(",
"PreparedStatement",
")",
"st",
")",
";",
... | Fire statement close event to listeners.
@param st statement | [
"Fire",
"statement",
"close",
"event",
"to",
"listeners",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java#L189-L196 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java | MariaDbPooledConnection.fireStatementErrorOccured | public void fireStatementErrorOccured(Statement st, SQLException ex) {
if (st instanceof PreparedStatement) {
StatementEvent event = new StatementEvent(this, (PreparedStatement) st, ex);
for (StatementEventListener listener : statementEventListeners) {
listener.statementErrorOccurred(event);
... | java | public void fireStatementErrorOccured(Statement st, SQLException ex) {
if (st instanceof PreparedStatement) {
StatementEvent event = new StatementEvent(this, (PreparedStatement) st, ex);
for (StatementEventListener listener : statementEventListeners) {
listener.statementErrorOccurred(event);
... | [
"public",
"void",
"fireStatementErrorOccured",
"(",
"Statement",
"st",
",",
"SQLException",
"ex",
")",
"{",
"if",
"(",
"st",
"instanceof",
"PreparedStatement",
")",
"{",
"StatementEvent",
"event",
"=",
"new",
"StatementEvent",
"(",
"this",
",",
"(",
"PreparedSta... | Fire statement error to listeners.
@param st statement
@param ex exception | [
"Fire",
"statement",
"error",
"to",
"listeners",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java#L204-L211 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java | MariaDbPooledConnection.fireConnectionClosed | public void fireConnectionClosed() {
ConnectionEvent event = new ConnectionEvent(this);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionClosed(event);
}
} | java | public void fireConnectionClosed() {
ConnectionEvent event = new ConnectionEvent(this);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionClosed(event);
}
} | [
"public",
"void",
"fireConnectionClosed",
"(",
")",
"{",
"ConnectionEvent",
"event",
"=",
"new",
"ConnectionEvent",
"(",
"this",
")",
";",
"for",
"(",
"ConnectionEventListener",
"listener",
":",
"connectionEventListeners",
")",
"{",
"listener",
".",
"connectionClose... | Fire Connection close to listening listeners. | [
"Fire",
"Connection",
"close",
"to",
"listening",
"listeners",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java#L216-L221 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java | MariaDbPooledConnection.fireConnectionErrorOccured | public void fireConnectionErrorOccured(SQLException ex) {
ConnectionEvent event = new ConnectionEvent(this, ex);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionErrorOccurred(event);
}
} | java | public void fireConnectionErrorOccured(SQLException ex) {
ConnectionEvent event = new ConnectionEvent(this, ex);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionErrorOccurred(event);
}
} | [
"public",
"void",
"fireConnectionErrorOccured",
"(",
"SQLException",
"ex",
")",
"{",
"ConnectionEvent",
"event",
"=",
"new",
"ConnectionEvent",
"(",
"this",
",",
"ex",
")",
";",
"for",
"(",
"ConnectionEventListener",
"listener",
":",
"connectionEventListeners",
")",... | Fire connection error to listening listeners.
@param ex exception | [
"Fire",
"connection",
"error",
"to",
"listening",
"listeners",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java#L228-L233 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.setTimerTask | protected void setTimerTask(boolean isBatch) {
assert (timerTaskFuture == null);
timerTaskFuture = timeoutScheduler.schedule(() -> {
try {
isTimedout = true;
if (!isBatch) {
protocol.cancelCurrentQuery();
}
protocol.interrupt();
} catch (Throwable e) {
... | java | protected void setTimerTask(boolean isBatch) {
assert (timerTaskFuture == null);
timerTaskFuture = timeoutScheduler.schedule(() -> {
try {
isTimedout = true;
if (!isBatch) {
protocol.cancelCurrentQuery();
}
protocol.interrupt();
} catch (Throwable e) {
... | [
"protected",
"void",
"setTimerTask",
"(",
"boolean",
"isBatch",
")",
"{",
"assert",
"(",
"timerTaskFuture",
"==",
"null",
")",
";",
"timerTaskFuture",
"=",
"timeoutScheduler",
".",
"schedule",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"isTimedout",
"=",
"true",
... | Part of query prolog - setup timeout timer | [
"Part",
"of",
"query",
"prolog",
"-",
"setup",
"timeout",
"timer"
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L160-L174 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.executeExceptionEpilogue | protected SQLException executeExceptionEpilogue(SQLException sqle) {
//if has a failover, closing the statement
if (sqle.getSQLState() != null && sqle.getSQLState().startsWith("08")) {
try {
close();
} catch (SQLException sqlee) {
//eat exception
}
}
if (isTimedout) {
... | java | protected SQLException executeExceptionEpilogue(SQLException sqle) {
//if has a failover, closing the statement
if (sqle.getSQLState() != null && sqle.getSQLState().startsWith("08")) {
try {
close();
} catch (SQLException sqlee) {
//eat exception
}
}
if (isTimedout) {
... | [
"protected",
"SQLException",
"executeExceptionEpilogue",
"(",
"SQLException",
"sqle",
")",
"{",
"//if has a failover, closing the statement",
"if",
"(",
"sqle",
".",
"getSQLState",
"(",
")",
"!=",
"null",
"&&",
"sqle",
".",
"getSQLState",
"(",
")",
".",
"startsWith"... | Reset timeout after query, re-throw SQL exception.
@param sqle current exception
@return SQLException exception with new message in case of timer timeout. | [
"Reset",
"timeout",
"after",
"query",
"re",
"-",
"throw",
"SQL",
"exception",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L223-L241 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.executeLargeUpdate | @Override
public long executeLargeUpdate(String sql) throws SQLException {
if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) {
return 0;
}
return getLargeUpdateCount();
} | java | @Override
public long executeLargeUpdate(String sql) throws SQLException {
if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) {
return 0;
}
return getLargeUpdateCount();
} | [
"@",
"Override",
"public",
"long",
"executeLargeUpdate",
"(",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"executeInternal",
"(",
"sql",
",",
"fetchSize",
",",
"Statement",
".",
"NO_GENERATED_KEYS",
")",
")",
"{",
"return",
"0",
";",
"}",... | Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL
statement that returns nothing, such as an SQL DDL statement. This method should be used when
the returned row count may exceed Integer.MAX_VALUE.
@param sql sql command
@return update counts
@throws SQLException if any err... | [
"Executes",
"the",
"given",
"SQL",
"statement",
"which",
"may",
"be",
"an",
"INSERT",
"UPDATE",
"or",
"DELETE",
"statement",
"or",
"an",
"SQL",
"statement",
"that",
"returns",
"nothing",
"such",
"as",
"an",
"SQL",
"DDL",
"statement",
".",
"This",
"method",
... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L618-L624 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.getUpdateCount | public int getUpdateCount() {
if (results != null && results.getCmdInformation() != null && !results.isBatch()) {
return results.getCmdInformation().getUpdateCount();
}
return -1;
} | java | public int getUpdateCount() {
if (results != null && results.getCmdInformation() != null && !results.isBatch()) {
return results.getCmdInformation().getUpdateCount();
}
return -1;
} | [
"public",
"int",
"getUpdateCount",
"(",
")",
"{",
"if",
"(",
"results",
"!=",
"null",
"&&",
"results",
".",
"getCmdInformation",
"(",
")",
"!=",
"null",
"&&",
"!",
"results",
".",
"isBatch",
"(",
")",
")",
"{",
"return",
"results",
".",
"getCmdInformatio... | Retrieves the current result as an update count; if the result is a ResultSet object or there
are no more results, -1 is returned. This method should be called only once per result.
@return the current result as an update count; -1 if the current result is a ResultSet object
or there are no more results | [
"Retrieves",
"the",
"current",
"result",
"as",
"an",
"update",
"count",
";",
"if",
"the",
"result",
"is",
"a",
"ResultSet",
"object",
"or",
"there",
"are",
"no",
"more",
"results",
"-",
"1",
"is",
"returned",
".",
"This",
"method",
"should",
"be",
"calle... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L1057-L1062 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.getLargeUpdateCount | @Override
public long getLargeUpdateCount() {
if (results != null && results.getCmdInformation() != null && !results.isBatch()) {
return results.getCmdInformation().getLargeUpdateCount();
}
return -1;
} | java | @Override
public long getLargeUpdateCount() {
if (results != null && results.getCmdInformation() != null && !results.isBatch()) {
return results.getCmdInformation().getLargeUpdateCount();
}
return -1;
} | [
"@",
"Override",
"public",
"long",
"getLargeUpdateCount",
"(",
")",
"{",
"if",
"(",
"results",
"!=",
"null",
"&&",
"results",
".",
"getCmdInformation",
"(",
")",
"!=",
"null",
"&&",
"!",
"results",
".",
"isBatch",
"(",
")",
")",
"{",
"return",
"results",... | Retrieves the current result as an update count; if the result is a ResultSet object or there
are no more results, -1 is returned.
@return last update count | [
"Retrieves",
"the",
"current",
"result",
"as",
"an",
"update",
"count",
";",
"if",
"the",
"result",
"is",
"a",
"ResultSet",
"object",
"or",
"there",
"are",
"no",
"more",
"results",
"-",
"1",
"is",
"returned",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L1070-L1076 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.internalBatchExecution | private void internalBatchExecution(int size) throws SQLException {
executeQueryPrologue(true);
results = new Results(this,
0,
true,
size,
false,
resultSetScrollType,
resultSetConcurrency,
Statement.RETURN_GENERATED_KEYS,
protocol.getAutoIncrement... | java | private void internalBatchExecution(int size) throws SQLException {
executeQueryPrologue(true);
results = new Results(this,
0,
true,
size,
false,
resultSetScrollType,
resultSetConcurrency,
Statement.RETURN_GENERATED_KEYS,
protocol.getAutoIncrement... | [
"private",
"void",
"internalBatchExecution",
"(",
"int",
"size",
")",
"throws",
"SQLException",
"{",
"executeQueryPrologue",
"(",
"true",
")",
";",
"results",
"=",
"new",
"Results",
"(",
"this",
",",
"0",
",",
"true",
",",
"size",
",",
"false",
",",
"resul... | Internal batch execution.
@param size expected result-set size
@throws SQLException throw exception if batch error occur | [
"Internal",
"batch",
"execution",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L1337-L1351 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbStatement.java | MariaDbStatement.checkCloseOnCompletion | public void checkCloseOnCompletion(ResultSet resultSet) throws SQLException {
if (mustCloseOnCompletion
&& !closed
&& results != null
&& resultSet.equals(results.getResultSet())) {
close();
}
} | java | public void checkCloseOnCompletion(ResultSet resultSet) throws SQLException {
if (mustCloseOnCompletion
&& !closed
&& results != null
&& resultSet.equals(results.getResultSet())) {
close();
}
} | [
"public",
"void",
"checkCloseOnCompletion",
"(",
"ResultSet",
"resultSet",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"mustCloseOnCompletion",
"&&",
"!",
"closed",
"&&",
"results",
"!=",
"null",
"&&",
"resultSet",
".",
"equals",
"(",
"results",
".",
"getResu... | Check that close on completion is asked, and close if so.
@param resultSet resultSet
@throws SQLException if close has error | [
"Check",
"that",
"close",
"on",
"completion",
"is",
"asked",
"and",
"close",
"if",
"so",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbStatement.java#L1418-L1425 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/CallableFunctionStatement.java | CallableFunctionStatement.initFunctionData | public void initFunctionData(int parametersCount) {
params = new CallParameter[parametersCount];
for (int i = 0; i < parametersCount; i++) {
params[i] = new CallParameter();
if (i > 0) {
params[i].setInput(true);
}
}
// the query was in the form {?=call function()}, so the firs... | java | public void initFunctionData(int parametersCount) {
params = new CallParameter[parametersCount];
for (int i = 0; i < parametersCount; i++) {
params[i] = new CallParameter();
if (i > 0) {
params[i].setInput(true);
}
}
// the query was in the form {?=call function()}, so the firs... | [
"public",
"void",
"initFunctionData",
"(",
"int",
"parametersCount",
")",
"{",
"params",
"=",
"new",
"CallParameter",
"[",
"parametersCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parametersCount",
";",
"i",
"++",
")",
"{",
"params"... | Data initialisation when parameterCount is defined.
@param parametersCount number of parameters | [
"Data",
"initialisation",
"when",
"parameterCount",
"is",
"defined",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/CallableFunctionStatement.java#L131-L141 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/ServerSidePreparedStatement.java | ServerSidePreparedStatement.executeQueryPrologue | private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws SQLException {
executing = true;
if (closed) {
throw new SQLException("execute() is called on closed statement");
}
protocol
.prologProxy(serverPrepareResult, maxRows, protocol.getProxy() != null, connection,... | java | private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws SQLException {
executing = true;
if (closed) {
throw new SQLException("execute() is called on closed statement");
}
protocol
.prologProxy(serverPrepareResult, maxRows, protocol.getProxy() != null, connection,... | [
"private",
"void",
"executeQueryPrologue",
"(",
"ServerPrepareResult",
"serverPrepareResult",
")",
"throws",
"SQLException",
"{",
"executing",
"=",
"true",
";",
"if",
"(",
"closed",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"execute() is called on closed statemen... | must have "lock" locked before invoking | [
"must",
"have",
"lock",
"locked",
"before",
"invoking"
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/ServerSidePreparedStatement.java#L351-L359 | train |
intel-iot-devkit/upm | examples/java/GroveQTouch_Example.java | GroveQTouch_Example.printButtons | public static void printButtons(int buttonNumber){
boolean buttonPressed = false;
System.out.print("Button Pressed: ");
for(int i=0;i<7;i++){
if((buttonNumber & (1<<i)) != 0){
System.out.println(i+" ");
buttonPressed = true;
}
}
if(!buttonPressed){
System.out.println("None ");
}
} | java | public static void printButtons(int buttonNumber){
boolean buttonPressed = false;
System.out.print("Button Pressed: ");
for(int i=0;i<7;i++){
if((buttonNumber & (1<<i)) != 0){
System.out.println(i+" ");
buttonPressed = true;
}
}
if(!buttonPressed){
System.out.println("None ");
}
} | [
"public",
"static",
"void",
"printButtons",
"(",
"int",
"buttonNumber",
")",
"{",
"boolean",
"buttonPressed",
"=",
"false",
";",
"System",
".",
"out",
".",
"print",
"(",
"\"Button Pressed: \"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | This function prints out the button numbers from 0 through 6
@param buttonNumber | [
"This",
"function",
"prints",
"out",
"the",
"button",
"numbers",
"from",
"0",
"through",
"6"
] | 2c7fff24c7c5647ef50a65d5aff587de0c5b8b2f | https://github.com/intel-iot-devkit/upm/blob/2c7fff24c7c5647ef50a65d5aff587de0c5b8b2f/examples/java/GroveQTouch_Example.java#L53-L68 | train |
rapidoid/rapidoid | rapidoid-jpa/src/main/java/org/rapidoid/jpa/JPA.java | JPA.transaction | public static void transaction(Runnable action, boolean readOnly) {
Ctx ctx = Ctxs.get();
boolean newContext = ctx == null;
if (newContext) {
ctx = Ctxs.open("transaction");
}
try {
EntityManager em = ctx.persister();
JPA.with(em).transactional(action, readOnly);
} finally {
if (newContext) {... | java | public static void transaction(Runnable action, boolean readOnly) {
Ctx ctx = Ctxs.get();
boolean newContext = ctx == null;
if (newContext) {
ctx = Ctxs.open("transaction");
}
try {
EntityManager em = ctx.persister();
JPA.with(em).transactional(action, readOnly);
} finally {
if (newContext) {... | [
"public",
"static",
"void",
"transaction",
"(",
"Runnable",
"action",
",",
"boolean",
"readOnly",
")",
"{",
"Ctx",
"ctx",
"=",
"Ctxs",
".",
"get",
"(",
")",
";",
"boolean",
"newContext",
"=",
"ctx",
"==",
"null",
";",
"if",
"(",
"newContext",
")",
"{",... | FIXME replace Runnable with Executable | [
"FIXME",
"replace",
"Runnable",
"with",
"Executable"
] | 1775344bcf4abbee289d474b34d553ff6bc821b0 | https://github.com/rapidoid/rapidoid/blob/1775344bcf4abbee289d474b34d553ff6bc821b0/rapidoid-jpa/src/main/java/org/rapidoid/jpa/JPA.java#L210-L227 | train |
rapidoid/rapidoid | rapidoid-rest/src/main/java/org/rapidoid/setup/App.java | App.run | public static synchronized void run(String[] args, String... extraArgs) {
AppStarter.startUp(args, extraArgs);
// no implicit classpath scanning here
boot();
// finish initialization and start the application
onAppReady();
boot();
} | java | public static synchronized void run(String[] args, String... extraArgs) {
AppStarter.startUp(args, extraArgs);
// no implicit classpath scanning here
boot();
// finish initialization and start the application
onAppReady();
boot();
} | [
"public",
"static",
"synchronized",
"void",
"run",
"(",
"String",
"[",
"]",
"args",
",",
"String",
"...",
"extraArgs",
")",
"{",
"AppStarter",
".",
"startUp",
"(",
"args",
",",
"extraArgs",
")",
";",
"// no implicit classpath scanning here",
"boot",
"(",
")",
... | Initializes the app in non-atomic way.
Then starts serving requests immediately when routes are configured. | [
"Initializes",
"the",
"app",
"in",
"non",
"-",
"atomic",
"way",
".",
"Then",
"starts",
"serving",
"requests",
"immediately",
"when",
"routes",
"are",
"configured",
"."
] | 1775344bcf4abbee289d474b34d553ff6bc821b0 | https://github.com/rapidoid/rapidoid/blob/1775344bcf4abbee289d474b34d553ff6bc821b0/rapidoid-rest/src/main/java/org/rapidoid/setup/App.java#L90-L100 | train |
rapidoid/rapidoid | rapidoid-rest/src/main/java/org/rapidoid/setup/App.java | App.bootstrap | public static synchronized void bootstrap(String[] args, String... extraArgs) {
AppStarter.startUp(args, extraArgs);
boot();
App.scan(); // scan classpath for beans
// finish initialization and start the application
onAppReady();
boot();
} | java | public static synchronized void bootstrap(String[] args, String... extraArgs) {
AppStarter.startUp(args, extraArgs);
boot();
App.scan(); // scan classpath for beans
// finish initialization and start the application
onAppReady();
boot();
} | [
"public",
"static",
"synchronized",
"void",
"bootstrap",
"(",
"String",
"[",
"]",
"args",
",",
"String",
"...",
"extraArgs",
")",
"{",
"AppStarter",
".",
"startUp",
"(",
"args",
",",
"extraArgs",
")",
";",
"boot",
"(",
")",
";",
"App",
".",
"scan",
"("... | Initializes the app in non-atomic way.
Then scans the classpath for beans.
Then starts serving requests immediately when routes are configured. | [
"Initializes",
"the",
"app",
"in",
"non",
"-",
"atomic",
"way",
".",
"Then",
"scans",
"the",
"classpath",
"for",
"beans",
".",
"Then",
"starts",
"serving",
"requests",
"immediately",
"when",
"routes",
"are",
"configured",
"."
] | 1775344bcf4abbee289d474b34d553ff6bc821b0 | https://github.com/rapidoid/rapidoid/blob/1775344bcf4abbee289d474b34d553ff6bc821b0/rapidoid-rest/src/main/java/org/rapidoid/setup/App.java#L107-L118 | train |
rapidoid/rapidoid | rapidoid-commons/src/main/java/org/rapidoid/cache/impl/ConcurrentCacheAtom.java | ConcurrentCacheAtom.setValueInsideWriteLock | private V setValueInsideWriteLock(V newValue) {
CachedValue<V> cached = cachedValue; // read the cached value
V oldValue = cached != null ? cached.value : null;
if (newValue != null) {
long expiresAt = ttlInMs > 0 ? U.time() + ttlInMs : Long.MAX_VALUE;
cachedValue = new CachedValue<>(newValue, expiresAt);
... | java | private V setValueInsideWriteLock(V newValue) {
CachedValue<V> cached = cachedValue; // read the cached value
V oldValue = cached != null ? cached.value : null;
if (newValue != null) {
long expiresAt = ttlInMs > 0 ? U.time() + ttlInMs : Long.MAX_VALUE;
cachedValue = new CachedValue<>(newValue, expiresAt);
... | [
"private",
"V",
"setValueInsideWriteLock",
"(",
"V",
"newValue",
")",
"{",
"CachedValue",
"<",
"V",
">",
"cached",
"=",
"cachedValue",
";",
"// read the cached value",
"V",
"oldValue",
"=",
"cached",
"!=",
"null",
"?",
"cached",
".",
"value",
":",
"null",
";... | Sets new cached value, executes inside already acquired write lock. | [
"Sets",
"new",
"cached",
"value",
"executes",
"inside",
"already",
"acquired",
"write",
"lock",
"."
] | 1775344bcf4abbee289d474b34d553ff6bc821b0 | https://github.com/rapidoid/rapidoid/blob/1775344bcf4abbee289d474b34d553ff6bc821b0/rapidoid-commons/src/main/java/org/rapidoid/cache/impl/ConcurrentCacheAtom.java#L215-L228 | train |
lviggiano/owner | owner/src/main/java/org/aeonbits/owner/ConfigFactory.java | ConfigFactory.newInstance | public static Factory newInstance() {
ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor(new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread result = new Thread(r);
result.setDaemon(true);
return result;
}
... | java | public static Factory newInstance() {
ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor(new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread result = new Thread(r);
result.setDaemon(true);
return result;
}
... | [
"public",
"static",
"Factory",
"newInstance",
"(",
")",
"{",
"ScheduledExecutorService",
"scheduler",
"=",
"newSingleThreadScheduledExecutor",
"(",
"new",
"ThreadFactory",
"(",
")",
"{",
"public",
"Thread",
"newThread",
"(",
"Runnable",
"r",
")",
"{",
"Thread",
"r... | Returns a new instance of a config Factory object.
@return a new instance of a config Factory object. | [
"Returns",
"a",
"new",
"instance",
"of",
"a",
"config",
"Factory",
"object",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner/src/main/java/org/aeonbits/owner/ConfigFactory.java#L45-L55 | train |
lviggiano/owner | owner/src/main/java/org/aeonbits/owner/ConfigCache.java | ConfigCache.remove | @SuppressWarnings("unchecked")
public static <T extends Config> T remove(Object key) {
return (T) CACHE.remove(key);
} | java | @SuppressWarnings("unchecked")
public static <T extends Config> T remove(Object key) {
return (T) CACHE.remove(key);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"Config",
">",
"T",
"remove",
"(",
"Object",
"key",
")",
"{",
"return",
"(",
"T",
")",
"CACHE",
".",
"remove",
"(",
"key",
")",
";",
"}"
] | Removes the cached instance for the given key if it is present.
<p>Returns previous instance associated to the given key in the cache,
or <code>null</code> if the cache contained no instance for the given key.
<p>The cache will not contain the instance for the specified key once the
call returns.
@param <T> type o... | [
"Removes",
"the",
"cached",
"instance",
"for",
"the",
"given",
"key",
"if",
"it",
"is",
"present",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner/src/main/java/org/aeonbits/owner/ConfigCache.java#L155-L158 | train |
lviggiano/owner | owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java | PropertiesFileCreator.parse | public void parse(Class clazz, PrintWriter output, String headerName, String projectName) throws Exception {
long startTime = System.currentTimeMillis();
Group[] groups = parseMethods(clazz);
long finishTime = System.currentTimeMillis();
lastExecutionTime = finishTime - startTi... | java | public void parse(Class clazz, PrintWriter output, String headerName, String projectName) throws Exception {
long startTime = System.currentTimeMillis();
Group[] groups = parseMethods(clazz);
long finishTime = System.currentTimeMillis();
lastExecutionTime = finishTime - startTi... | [
"public",
"void",
"parse",
"(",
"Class",
"clazz",
",",
"PrintWriter",
"output",
",",
"String",
"headerName",
",",
"String",
"projectName",
")",
"throws",
"Exception",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"Group",
... | Method to parse the class and write file in the choosen output.
@param clazz class to parse
@param output output file path
@param headerName
@param projectName | [
"Method",
"to",
"parse",
"the",
"class",
"and",
"write",
"file",
"in",
"the",
"choosen",
"output",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java#L46-L57 | train |
lviggiano/owner | owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java | PropertiesFileCreator.parseMethods | private Group[] parseMethods(Class clazz) {
List<Group> groups = new ArrayList();
Group unknownGroup = new Group();
groups.add(unknownGroup);
String[] groupsOrder = new String[0];
for (Method method : clazz.getMethods()) {
Property prop = new Property();
... | java | private Group[] parseMethods(Class clazz) {
List<Group> groups = new ArrayList();
Group unknownGroup = new Group();
groups.add(unknownGroup);
String[] groupsOrder = new String[0];
for (Method method : clazz.getMethods()) {
Property prop = new Property();
... | [
"private",
"Group",
"[",
"]",
"parseMethods",
"(",
"Class",
"clazz",
")",
"{",
"List",
"<",
"Group",
">",
"groups",
"=",
"new",
"ArrayList",
"(",
")",
";",
"Group",
"unknownGroup",
"=",
"new",
"Group",
"(",
")",
";",
"groups",
".",
"add",
"(",
"unkno... | Method to get group array with subgroups and properties.
@param clazz class to parse
@return array of groups | [
"Method",
"to",
"get",
"group",
"array",
"with",
"subgroups",
"and",
"properties",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java#L65-L92 | train |
lviggiano/owner | owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java | PropertiesFileCreator.orderGroup | private Group[] orderGroup(List<Group> groups, String[] groupsOrder) {
LinkedList<Group> groupsOrdered = new LinkedList();
List<Group> remained = new ArrayList(groups);
for (String order : groupsOrder) {
for (Group remain : remained) {
if (remain.title.equals(order)... | java | private Group[] orderGroup(List<Group> groups, String[] groupsOrder) {
LinkedList<Group> groupsOrdered = new LinkedList();
List<Group> remained = new ArrayList(groups);
for (String order : groupsOrder) {
for (Group remain : remained) {
if (remain.title.equals(order)... | [
"private",
"Group",
"[",
"]",
"orderGroup",
"(",
"List",
"<",
"Group",
">",
"groups",
",",
"String",
"[",
"]",
"groupsOrder",
")",
"{",
"LinkedList",
"<",
"Group",
">",
"groupsOrdered",
"=",
"new",
"LinkedList",
"(",
")",
";",
"List",
"<",
"Group",
">"... | Order groups based on passed order.
@param groups groups to order
@param groupsOrder order to follow
@return ordered groups | [
"Order",
"groups",
"based",
"on",
"passed",
"order",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java#L102-L120 | train |
lviggiano/owner | owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java | PropertiesFileCreator.toPropertiesString | private String toPropertiesString(Group[] groups, String headerName, String projectName) {
StringBuilder result = new StringBuilder();
result.append(format(header, headerName, projectName));
for (Group group : groups) {
result.append(group.toString());
}
result.app... | java | private String toPropertiesString(Group[] groups, String headerName, String projectName) {
StringBuilder result = new StringBuilder();
result.append(format(header, headerName, projectName));
for (Group group : groups) {
result.append(group.toString());
}
result.app... | [
"private",
"String",
"toPropertiesString",
"(",
"Group",
"[",
"]",
"groups",
",",
"String",
"headerName",
",",
"String",
"projectName",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"result",
".",
"append",
"(",
"format",
"... | Convert groups list into string. | [
"Convert",
"groups",
"list",
"into",
"string",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner-creator-maven-plugin/src/main/java/org/aeonbits/owner/creator/PropertiesFileCreator.java#L125-L137 | train |
lviggiano/owner | owner-java8-extras/src/main/java/org/aeonbits/owner/util/bytesize/ByteSize.java | ByteSize.getBytes | public BigInteger getBytes(){
return value.multiply(unit.getFactor()).setScale(0, RoundingMode.CEILING).toBigIntegerExact();
} | java | public BigInteger getBytes(){
return value.multiply(unit.getFactor()).setScale(0, RoundingMode.CEILING).toBigIntegerExact();
} | [
"public",
"BigInteger",
"getBytes",
"(",
")",
"{",
"return",
"value",
".",
"multiply",
"(",
"unit",
".",
"getFactor",
"(",
")",
")",
".",
"setScale",
"(",
"0",
",",
"RoundingMode",
".",
"CEILING",
")",
".",
"toBigIntegerExact",
"(",
")",
";",
"}"
] | Returns the number of bytes that this byte size represents after multiplying the unit factor with the value.
Since the value part can be a represented by a decimal, there is some possibility of a rounding error. Therefore,
the result of multiplying the value and the unit factor are always rounded towards positive infi... | [
"Returns",
"the",
"number",
"of",
"bytes",
"that",
"this",
"byte",
"size",
"represents",
"after",
"multiplying",
"the",
"unit",
"factor",
"with",
"the",
"value",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner-java8-extras/src/main/java/org/aeonbits/owner/util/bytesize/ByteSize.java#L91-L93 | train |
lviggiano/owner | owner/src/main/java/org/aeonbits/owner/StrSubstitutor.java | StrSubstitutor.replace | String replace(String source) {
if (source == null)
return null;
Matcher m = PATTERN.matcher(source);
StringBuffer sb = new StringBuffer();
while (m.find()) {
String var = m.group(1);
String value = values.getProperty(var);
String replaceme... | java | String replace(String source) {
if (source == null)
return null;
Matcher m = PATTERN.matcher(source);
StringBuffer sb = new StringBuffer();
while (m.find()) {
String var = m.group(1);
String value = values.getProperty(var);
String replaceme... | [
"String",
"replace",
"(",
"String",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"return",
"null",
";",
"Matcher",
"m",
"=",
"PATTERN",
".",
"matcher",
"(",
"source",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
... | Replaces all the occurrences of variables with their matching values from the resolver using the given source
string as a template.
@param source the string to replace in, null returns null
@return the result of the replace operation | [
"Replaces",
"all",
"the",
"occurrences",
"of",
"variables",
"with",
"their",
"matching",
"values",
"from",
"the",
"resolver",
"using",
"the",
"given",
"source",
"string",
"as",
"a",
"template",
"."
] | 1223ecfbe3c275b3b7c5ec13e9238c9bb888754f | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner/src/main/java/org/aeonbits/owner/StrSubstitutor.java#L70-L83 | train |
siom79/japicmp | japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java | JarArchiveComparator.compare | public List<JApiClass> compare(JApiCmpArchive oldArchive, JApiCmpArchive newArchive) {
return compare(Collections.singletonList(oldArchive), Collections.singletonList(newArchive));
} | java | public List<JApiClass> compare(JApiCmpArchive oldArchive, JApiCmpArchive newArchive) {
return compare(Collections.singletonList(oldArchive), Collections.singletonList(newArchive));
} | [
"public",
"List",
"<",
"JApiClass",
">",
"compare",
"(",
"JApiCmpArchive",
"oldArchive",
",",
"JApiCmpArchive",
"newArchive",
")",
"{",
"return",
"compare",
"(",
"Collections",
".",
"singletonList",
"(",
"oldArchive",
")",
",",
"Collections",
".",
"singletonList",... | Compares the two given archives.
@param oldArchive the old version of the archive
@param newArchive the new version of the archive
@return a list which contains one instance of {@link japicmp.model.JApiClass} for each class found in one of the two archives
@throws JApiCmpException if the comparison fails | [
"Compares",
"the",
"two",
"given",
"archives",
"."
] | f008ea588eec721c45f568bf1db5074fbcbcfced | https://github.com/siom79/japicmp/blob/f008ea588eec721c45f568bf1db5074fbcbcfced/japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java#L82-L84 | train |
siom79/japicmp | japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java | JarArchiveComparator.compare | public List<JApiClass> compare(List<JApiCmpArchive> oldArchives, List<JApiCmpArchive> newArchives) {
return createAndCompareClassLists(toFileList(oldArchives), toFileList(newArchives));
} | java | public List<JApiClass> compare(List<JApiCmpArchive> oldArchives, List<JApiCmpArchive> newArchives) {
return createAndCompareClassLists(toFileList(oldArchives), toFileList(newArchives));
} | [
"public",
"List",
"<",
"JApiClass",
">",
"compare",
"(",
"List",
"<",
"JApiCmpArchive",
">",
"oldArchives",
",",
"List",
"<",
"JApiCmpArchive",
">",
"newArchives",
")",
"{",
"return",
"createAndCompareClassLists",
"(",
"toFileList",
"(",
"oldArchives",
")",
",",... | Compares the two given lists of archives.
@param oldArchives the old versions of the archives
@param newArchives the new versions of the archives
@return a list which contains one instance of {@link japicmp.model.JApiClass} for each class found in one of the archives
@throws JApiCmpException if the comparison fails | [
"Compares",
"the",
"two",
"given",
"lists",
"of",
"archives",
"."
] | f008ea588eec721c45f568bf1db5074fbcbcfced | https://github.com/siom79/japicmp/blob/f008ea588eec721c45f568bf1db5074fbcbcfced/japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java#L94-L96 | train |
siom79/japicmp | japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java | JarArchiveComparator.compareClassLists | List<JApiClass> compareClassLists(JarArchiveComparatorOptions options, List<CtClass> oldClasses, List<CtClass> newClasses) {
List<CtClass> oldClassesFiltered = applyFilter(options, oldClasses);
List<CtClass> newClassesFiltered = applyFilter(options, newClasses);
ClassesComparator classesComparator = new ClassesCo... | java | List<JApiClass> compareClassLists(JarArchiveComparatorOptions options, List<CtClass> oldClasses, List<CtClass> newClasses) {
List<CtClass> oldClassesFiltered = applyFilter(options, oldClasses);
List<CtClass> newClassesFiltered = applyFilter(options, newClasses);
ClassesComparator classesComparator = new ClassesCo... | [
"List",
"<",
"JApiClass",
">",
"compareClassLists",
"(",
"JarArchiveComparatorOptions",
"options",
",",
"List",
"<",
"CtClass",
">",
"oldClasses",
",",
"List",
"<",
"CtClass",
">",
"newClasses",
")",
"{",
"List",
"<",
"CtClass",
">",
"oldClassesFiltered",
"=",
... | Compares the two lists with CtClass objects using the provided options instance.
@param options the options to use
@param oldClasses a list of CtClasses that represent the old version
@param newClasses a list of CtClasses that represent the new version
@return a list of {@link japicmp.model.JApiClass} that represen... | [
"Compares",
"the",
"two",
"lists",
"with",
"CtClass",
"objects",
"using",
"the",
"provided",
"options",
"instance",
"."
] | f008ea588eec721c45f568bf1db5074fbcbcfced | https://github.com/siom79/japicmp/blob/f008ea588eec721c45f568bf1db5074fbcbcfced/japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java#L203-L218 | train |
siom79/japicmp | japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java | JarArchiveComparator.loadClass | public Optional<CtClass> loadClass(ArchiveType archiveType, String name) {
Optional<CtClass> loadedClass = Optional.absent();
if (this.options.getClassPathMode() == JarArchiveComparatorOptions.ClassPathMode.ONE_COMMON_CLASSPATH) {
try {
loadedClass = Optional.of(commonClassPool.get(name));
} catch (NotFou... | java | public Optional<CtClass> loadClass(ArchiveType archiveType, String name) {
Optional<CtClass> loadedClass = Optional.absent();
if (this.options.getClassPathMode() == JarArchiveComparatorOptions.ClassPathMode.ONE_COMMON_CLASSPATH) {
try {
loadedClass = Optional.of(commonClassPool.get(name));
} catch (NotFou... | [
"public",
"Optional",
"<",
"CtClass",
">",
"loadClass",
"(",
"ArchiveType",
"archiveType",
",",
"String",
"name",
")",
"{",
"Optional",
"<",
"CtClass",
">",
"loadedClass",
"=",
"Optional",
".",
"absent",
"(",
")",
";",
"if",
"(",
"this",
".",
"options",
... | Loads a class either from the old, new or common classpath.
@param archiveType specify if this class should be loaded from the old or new class path
@param name the name of the class (FQN)
@return the loaded class (if options are not set to ignore missing classes)
@throws japicmp.exception.JApiCmpException if loading t... | [
"Loads",
"a",
"class",
"either",
"from",
"the",
"old",
"new",
"or",
"common",
"classpath",
"."
] | f008ea588eec721c45f568bf1db5074fbcbcfced | https://github.com/siom79/japicmp/blob/f008ea588eec721c45f568bf1db5074fbcbcfced/japicmp/src/main/java/japicmp/cmp/JarArchiveComparator.java#L345-L379 | train |
siom79/japicmp | japicmp/src/main/java/japicmp/compat/CompatibilityChanges.java | CompatibilityChanges.isImplemented | private boolean isImplemented(JApiMethod jApiMethod) {
JApiClass aClass = jApiMethod.getjApiClass();
while(aClass != null) {
for (JApiMethod method : aClass.getMethods()) {
if (jApiMethod.getName().equals(method.getName()) && jApiMethod.hasSameParameter(method) &&
... | java | private boolean isImplemented(JApiMethod jApiMethod) {
JApiClass aClass = jApiMethod.getjApiClass();
while(aClass != null) {
for (JApiMethod method : aClass.getMethods()) {
if (jApiMethod.getName().equals(method.getName()) && jApiMethod.hasSameParameter(method) &&
... | [
"private",
"boolean",
"isImplemented",
"(",
"JApiMethod",
"jApiMethod",
")",
"{",
"JApiClass",
"aClass",
"=",
"jApiMethod",
".",
"getjApiClass",
"(",
")",
";",
"while",
"(",
"aClass",
"!=",
"null",
")",
"{",
"for",
"(",
"JApiMethod",
"method",
":",
"aClass",... | Is a method implemented in a super class
@param jApiMethod the method
@return <code>true</code> if it is implemented in a super class | [
"Is",
"a",
"method",
"implemented",
"in",
"a",
"super",
"class"
] | f008ea588eec721c45f568bf1db5074fbcbcfced | https://github.com/siom79/japicmp/blob/f008ea588eec721c45f568bf1db5074fbcbcfced/japicmp/src/main/java/japicmp/compat/CompatibilityChanges.java#L538-L555 | train |
JakeWharton/RxRelay | src/main/java/com/jakewharton/rxrelay2/SerializedRelay.java | SerializedRelay.emitLoop | private void emitLoop() {
for (;;) {
AppendOnlyLinkedArrayList<T> q;
synchronized (this) {
q = queue;
if (q == null) {
emitting = false;
return;
}
queue = null;
}
... | java | private void emitLoop() {
for (;;) {
AppendOnlyLinkedArrayList<T> q;
synchronized (this) {
q = queue;
if (q == null) {
emitting = false;
return;
}
queue = null;
}
... | [
"private",
"void",
"emitLoop",
"(",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"AppendOnlyLinkedArrayList",
"<",
"T",
">",
"q",
";",
"synchronized",
"(",
"this",
")",
"{",
"q",
"=",
"queue",
";",
"if",
"(",
"q",
"==",
"null",
")",
"{",
"emitting",
... | Loops until all notifications in the queue has been processed. | [
"Loops",
"until",
"all",
"notifications",
"in",
"the",
"queue",
"has",
"been",
"processed",
"."
] | 67231debeb87eabbacb3bbacebd5353637b32327 | https://github.com/JakeWharton/RxRelay/blob/67231debeb87eabbacb3bbacebd5353637b32327/src/main/java/com/jakewharton/rxrelay2/SerializedRelay.java#L62-L75 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Genotype.java | Genotype.geneCount | public int geneCount() {
int count = 0;
for (int i = 0, n = _chromosomes.length(); i < n; ++i) {
count += _chromosomes.get(i).length();
}
return count;
} | java | public int geneCount() {
int count = 0;
for (int i = 0, n = _chromosomes.length(); i < n; ++i) {
count += _chromosomes.get(i).length();
}
return count;
} | [
"public",
"int",
"geneCount",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"_chromosomes",
".",
"length",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"count",
"+=",
"_chromosomes",
... | Return the number of genes this genotype consists of. This is the sum of
the number of genes of the genotype chromosomes.
@return Return the number of genes this genotype consists of. | [
"Return",
"the",
"number",
"of",
"genes",
"this",
"genotype",
"consists",
"of",
".",
"This",
"is",
"the",
"sum",
"of",
"the",
"number",
"of",
"genes",
"of",
"the",
"genotype",
"chromosomes",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Genotype.java#L226-L232 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/stat/MinMax.java | MinMax.accept | @Override
public void accept(final C object) {
_min = min(_comparator, _min, object);
_max = max(_comparator, _max, object);
++_count;
} | java | @Override
public void accept(final C object) {
_min = min(_comparator, _min, object);
_max = max(_comparator, _max, object);
++_count;
} | [
"@",
"Override",
"public",
"void",
"accept",
"(",
"final",
"C",
"object",
")",
"{",
"_min",
"=",
"min",
"(",
"_comparator",
",",
"_min",
",",
"object",
")",
";",
"_max",
"=",
"max",
"(",
"_comparator",
",",
"_max",
",",
"object",
")",
";",
"++",
"_... | Accept the element for min-max calculation.
@param object the element to use for min-max calculation | [
"Accept",
"the",
"element",
"for",
"min",
"-",
"max",
"calculation",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/MinMax.java#L73-L78 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/IntegerChromosome.java | IntegerChromosome.toArray | public int[] toArray(final int[] array) {
final int[] a = array.length >= length() ? array : new int[length()];
for (int i = length(); --i >= 0;) {
a[i] = intValue(i);
}
return a;
} | java | public int[] toArray(final int[] array) {
final int[] a = array.length >= length() ? array : new int[length()];
for (int i = length(); --i >= 0;) {
a[i] = intValue(i);
}
return a;
} | [
"public",
"int",
"[",
"]",
"toArray",
"(",
"final",
"int",
"[",
"]",
"array",
")",
"{",
"final",
"int",
"[",
"]",
"a",
"=",
"array",
".",
"length",
">=",
"length",
"(",
")",
"?",
"array",
":",
"new",
"int",
"[",
"length",
"(",
")",
"]",
";",
... | Returns an int array containing all of the elements in this chromosome
in proper sequence. If the chromosome fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the length of
this chromosome.
@since 3.0
@param array the array into which the elements of this chromosomes are t... | [
"Returns",
"an",
"int",
"array",
"containing",
"all",
"of",
"the",
"elements",
"in",
"this",
"chromosome",
"in",
"proper",
"sequence",
".",
"If",
"the",
"chromosome",
"fits",
"in",
"the",
"specified",
"array",
"it",
"is",
"returned",
"therein",
".",
"Otherwi... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/IntegerChromosome.java#L169-L176 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/math/DoubleAdder.java | DoubleAdder.add | public DoubleAdder add(final double[] values) {
for (int i = values.length; --i >= 0;) {
add(values[i]);
}
return this;
} | java | public DoubleAdder add(final double[] values) {
for (int i = values.length; --i >= 0;) {
add(values[i]);
}
return this;
} | [
"public",
"DoubleAdder",
"add",
"(",
"final",
"double",
"[",
"]",
"values",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"values",
".",
"length",
";",
"--",
"i",
">=",
"0",
";",
")",
"{",
"add",
"(",
"values",
"[",
"i",
"]",
")",
";",
"}",
"return",
... | Add the given values to this adder.
@param values the values to add.
@return {@code this} adder, for command chaining | [
"Add",
"the",
"given",
"values",
"to",
"this",
"adder",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/math/DoubleAdder.java#L116-L122 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/image/Polygon.java | Polygon.draw | public void draw(final Graphics2D g, final int width, final int height) {
g.setColor(new Color(_data[0], _data[1], _data[2], _data[3]));
final GeneralPath path = new GeneralPath();
path.moveTo(_data[4]*width, _data[5]*height);
for (int j = 1; j < _length; ++j) {
path.lineTo(_data[4 + j*2]*width, _data[5 + j... | java | public void draw(final Graphics2D g, final int width, final int height) {
g.setColor(new Color(_data[0], _data[1], _data[2], _data[3]));
final GeneralPath path = new GeneralPath();
path.moveTo(_data[4]*width, _data[5]*height);
for (int j = 1; j < _length; ++j) {
path.lineTo(_data[4 + j*2]*width, _data[5 + j... | [
"public",
"void",
"draw",
"(",
"final",
"Graphics2D",
"g",
",",
"final",
"int",
"width",
",",
"final",
"int",
"height",
")",
"{",
"g",
".",
"setColor",
"(",
"new",
"Color",
"(",
"_data",
"[",
"0",
"]",
",",
"_data",
"[",
"1",
"]",
",",
"_data",
"... | Draw the Polygon to the buffer of the given size. | [
"Draw",
"the",
"Polygon",
"to",
"the",
"buffer",
"of",
"the",
"given",
"size",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/Polygon.java#L107-L117 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/image/Polygon.java | Polygon.newRandom | public static Polygon newRandom(final int length, final Random random) {
require.positive(length);
final Polygon p = new Polygon(length);
p._data[0] = random.nextFloat(); // r
p._data[1] = random.nextFloat(); // g
p._data[2] = random.nextFloat(); // b
p._data[3] = max(0.2F, random.nextFloat()*random.nextFl... | java | public static Polygon newRandom(final int length, final Random random) {
require.positive(length);
final Polygon p = new Polygon(length);
p._data[0] = random.nextFloat(); // r
p._data[1] = random.nextFloat(); // g
p._data[2] = random.nextFloat(); // b
p._data[3] = max(0.2F, random.nextFloat()*random.nextFl... | [
"public",
"static",
"Polygon",
"newRandom",
"(",
"final",
"int",
"length",
",",
"final",
"Random",
"random",
")",
"{",
"require",
".",
"positive",
"(",
"length",
")",
";",
"final",
"Polygon",
"p",
"=",
"new",
"Polygon",
"(",
"length",
")",
";",
"p",
".... | Creates a new random Polygon of the given length. | [
"Creates",
"a",
"new",
"random",
"Polygon",
"of",
"the",
"given",
"length",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/Polygon.java#L122-L138 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.