proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropService.java | DropService | update | class DropService extends SchemaStatement {
private String serviceName;
private boolean ifExists;
public DropService(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_SERVICE;
}
public void setS... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.SERVICE, session);
if (lock == null)
return -1;
Service service = schema.findService(session, serviceName);
if (service == null) {
if (!ifExists) {
t... | 155 | 138 | 293 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropTable.java | DropTable | executeDrop | class DropTable extends SchemaStatement {
private String tableName;
private boolean ifExists;
private int dropAction;
private Table table;
private DropTable next;
public DropTable(ServerSession session, Schema schema) {
super(session, schema);
dropAction = session.getDatabase()... |
// need to get the table again, because it may be dropped already
// meanwhile (dependent object, or same object)
table = schema.findTableOrView(session, tableName);
if (table != null) {
int id = table.getId();
table.setModified();
schema.remove(sessi... | 775 | 138 | 913 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropTrigger.java | DropTrigger | update | class DropTrigger extends SchemaStatement {
private String triggerName;
private boolean ifExists;
public DropTrigger(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_TRIGGER;
}
public void setT... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.TRIGGER, session);
if (lock == null)
return -1;
TriggerObject trigger = schema.findTrigger(session, triggerName);
if (trigger == null) {
if (!ifExists) {
throw DbException.get(ErrorCode.TRI... | 159 | 159 | 318 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropUser.java | DropUser | update | class DropUser extends AuthStatement {
private String userName;
private boolean ifExists;
public DropUser(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.DROP_USER;
}
public void setUserName(String userName) {
th... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
User user = db.findUser(session, userName);
if (user == null) {
if (!ifExists) {
... | 147 | 325 | 472 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropUserDataType.java | DropUserDataType | update | class DropUserDataType extends SchemaStatement {
private String typeName;
private boolean ifExists;
public DropUserDataType(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_DOMAIN;
}
public voi... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.USER_DATATYPE, session);
if (lock == null)
return -1;
UserDataType type = schema.findUserDataType(session, typeName);
if (type == null) {
if (!ifExists) {
... | 161 | 149 | 310 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropView.java | DropView | update | class DropView extends SchemaStatement {
private String viewName;
private boolean ifExists;
private int dropAction;
public DropView(ServerSession session, Schema schema) {
super(session, schema);
dropAction = session.getDatabase().getSettings().dropRestrict ? ConstraintReferential.REST... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.TABLE_OR_VIEW, session);
if (lock == null)
return -1;
Table view = schema.findTableOrView(session, viewName);
if (view == null) {
if (!ifExists) {
throw DbException.get(ErrorCode.VIEW_NOT_F... | 230 | 278 | 508 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/GrantRevoke.java | GrantRevoke | update | class GrantRevoke extends AuthStatement {
private final ArrayList<DbObject> dbObjects = new ArrayList<>();
private int operationType;
private int rightMask;
private ArrayList<String> roleNames;
private Schema schema;
private RightOwner grantee;
public GrantRevoke(ServerSession session) {
... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
if (roleNames != null) {
for (String name : roleNames) {
Role grantedRole = db.findRol... | 1,334 | 299 | 1,633 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/PrepareProcedure.java | PrepareProcedure | update | class PrepareProcedure extends DefinitionStatement {
private String procedureName;
private StatementBase prepared;
public PrepareProcedure(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.PREPARE;
}
public void setProcedu... |
Procedure proc = new Procedure(procedureName, prepared);
prepared.setParameterList(parameters);
prepared.setPrepareAlways(prepareAlways);
prepared.prepare();
session.addProcedure(proc);
return 0;
| 206 | 66 | 272 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/SchemaStatement.java | SchemaStatement | tryAlterTable | class SchemaStatement extends DefinitionStatement {
protected final Schema schema;
/**
* Create a new statement.
*
* @param session the session
* @param schema the schema
*/
public SchemaStatement(ServerSession session, Schema schema) {
super(session);
this.schema ... |
// 先用schema级别的排它锁来避免其他事务也来执行Alter Table操作
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.TABLE_OR_VIEW, session);
if (lock == null)
return null;
// 再用table级别的共享锁来避免其他事务进行Drop Table操作,但是不阻止DML操作
if (!table.trySharedLock(session))
return null;
... | 171 | 119 | 290 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/SetComment.java | SetComment | update | class SetComment extends DefinitionStatement {
private String schemaName;
private String objectName;
private DbObjectType objectType;
private String columnName;
private boolean column;
private Expression expr;
public SetComment(ServerSession session) {
super(session);
}
@O... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveCommentLock(session);
if (lock == null)
return -1;
DbObject object = null;
if (schemaName == null) {
schemaName = session.getCurrentSchemaName... | 314 | 764 | 1,078 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/TruncateTable.java | TruncateTable | update | class TruncateTable extends SchemaStatement {
private Table table;
public TruncateTable(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.TRUNCATE_TABLE;
}
public void setTable(Table table) {
thi... |
session.getUser().checkRight(table, Right.DELETE);
if (!table.canTruncate()) {
throw DbException.get(ErrorCode.CANNOT_TRUNCATE_1, table.getSQL());
}
if (!table.tryExclusiveLock(session))
return -1;
table.truncate(session);
return 0;
| 125 | 99 | 224 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Backup.java | Backup | update | class Backup extends ManipulationStatement {
private String fileName;
private String lastDate;
public Backup(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.BACKUP;
}
@Override
public boolean needRecompile() {
... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
if (!db.isPersistent()) {
throw DbException.get(ErrorCode.DATABASE_IS_NOT_PERSISTENT);
}
Long ld = lastDate != null ? Date.valueOf(lastDate).getTime() : null;
db.backupTo(fileName, ld);
... | 172 | 107 | 279 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Call.java | Call | prepare | class Call extends ManipulationStatement {
private boolean isResultSet;
private Expression expression;
private Expression[] expressions;
public Call(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.CALL;
}
@Override
... |
expression = expression.optimize(session);
expressions = new Expression[] { expression };
isResultSet = expression.getType() == Value.RESULT_SET;
if (isResultSet) {
prepareAlways = true;
}
return this;
| 559 | 68 | 627 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Delete.java | Delete | prepare | class Delete extends UpDel {
public Delete(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.DELETE;
}
@Override
public String getPlanSQL() {
StatementBuilder buff = new StatementBuilder();
buff.append("DELETE "... |
if (condition != null) {
condition.mapColumns(tableFilter, 0);
condition = condition.optimize(session);
condition.createIndexConditions(session, tableFilter);
tableFilter.createColumnIndexes(condition);
}
tableFilter.preparePlan(session, 1);
... | 508 | 84 | 592 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public int getPriority() ,public boolean isCacheable() ,public void setCondition(com.lealone.sql.expression.Expression) ,public void setLimit(com.lealone.sql.expression.Expression) ,public void setTableFilter(com.lealone.sql.optimizer.TableFilter) ,publ... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/ExecuteProcedure.java | ExecuteProcedure | setParameters | class ExecuteProcedure extends ExecuteStatement {
private final Procedure procedure;
public ExecuteProcedure(ServerSession session, Procedure procedure) {
super(session);
this.procedure = procedure;
}
@Override
public boolean isQuery() {
return stmt().isQuery();
}
... |
ArrayList<Parameter> params = stmt().getParameters();
if (params == null)
return;
int size = Math.min(params.size(), expressions.size());
for (int i = 0; i < size; i++) {
Expression expr = expressions.get(i);
Parameter p = params.get(i);
p... | 223 | 104 | 327 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public int getType() ,public void setExpression(int, com.lealone.sql.expression.Expression) <variables>protected final ArrayList<com.lealone.sql.expression.Expression> expressions |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/ExecuteService.java | ExecuteService | prepare | class ExecuteService extends ExecuteStatement {
private final String serviceName;
private final String methodName;
private final Expression[] resultExpressions;
public ExecuteService(ServerSession session, String serviceName, String methodName) {
super(session);
this.serviceName = serv... |
for (int i = 0, size = expressions.size(); i < size; i++) {
Expression e = expressions.get(i).optimize(session);
expressions.set(i, e);
}
return this;
| 459 | 61 | 520 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public int getType() ,public void setExpression(int, com.lealone.sql.expression.Expression) <variables>protected final ArrayList<com.lealone.sql.expression.Expression> expressions |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Explain.java | Explain | query | class Explain extends ManipulationStatement {
private StatementBase command;
private LocalResult result;
private boolean executeCommand;
public Explain(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.EXPLAIN;
}
@Over... |
Column column = new Column("PLAN", Value.STRING);
Database db = session.getDatabase();
ExpressionColumn expr = new ExpressionColumn(db, column);
Expression[] expressions = { expr };
result = new LocalResult(session, expressions, 1);
if (maxRows >= 0) {
String... | 292 | 450 | 742 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Insert.java | YieldableInsert | startInternal | class YieldableInsert extends YieldableMerSert {
public YieldableInsert(Insert statement, AsyncHandler<AsyncResult<Integer>> asyncHandler) {
super(statement, asyncHandler);
}
@Override
protected boolean startInternal() {<FILL_FUNCTION_BODY>}
@Override
prote... |
if (!table.trySharedLock(session))
return true;
session.getUser().checkRight(table, Right.INSERT);
table.fire(session, Trigger.INSERT, true);
return super.startInternal();
| 138 | 59 | 197 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public void addRow(com.lealone.sql.expression.Expression[]) ,public void clearRows() ,public int getPriority() ,public boolean isCacheable() ,public com.lealone.sql.PreparedSQLStatement prepare() ,public void setColumns(com.lealone.db.table.Column[]) ,p... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/MerSert.java | YieldableMerSert | addRow | class YieldableMerSert extends YieldableLoopUpdateBase
implements ResultTarget {
final MerSert statement;
final Table table;
final int listSize;
int index;
YieldableBase<Result> yieldableQuery;
public YieldableMerSert(MerSert statement, AsyncHandler<AsyncRe... |
merSert(createNewRow(values));
if (yieldIfNeeded(updateCount.get() + 1)) {
return true;
}
return false;
| 1,096 | 47 | 1,143 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Merge.java | YieldableMerge | merSert | class YieldableMerge extends YieldableMerSert {
final Merge mergeStatement;
public YieldableMerge(Merge statement, AsyncHandler<AsyncResult<Integer>> asyncHandler) {
super(statement, asyncHandler);
this.mergeStatement = statement;
}
@Override
protected ... |
ArrayList<Parameter> k = mergeStatement.update.getParameters();
for (int i = 0; i < statement.columns.length; i++) {
Column col = statement.columns[i];
Value v = row.getValue(col.getColumnId());
if (v == null)
v = ValueNull.INS... | 233 | 346 | 579 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public void addRow(com.lealone.sql.expression.Expression[]) ,public void clearRows() ,public int getPriority() ,public boolean isCacheable() ,public com.lealone.sql.PreparedSQLStatement prepare() ,public void setColumns(com.lealone.db.table.Column[]) ,p... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/RunScript.java | RunScript | update | class RunScript extends ScriptBase {
/**
* The byte order mark.
* 0xfeff because this is the Unicode char
* represented by the UTF-8 byte order mark (EF BB BF).
*/
private static final char UTF8_BOM = '\uFEFF';
private Charset charset = Constants.UTF8;
public RunScript(ServerSessi... |
session.getUser().checkAdmin();
int count = 0;
try {
openInput();
BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
// if necessary, strip the BOM from the front of the file
reader.mark(1);
if (reader.read... | 299 | 231 | 530 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() ,public void setCipher(java.lang.String) ,public void setCompressionAlgorithm(java.lang.String) ,public void setFileNameExpr(com.lealone.sql.expression.Expression) ,public void setPassword(com.lealone.sql.expression.Expres... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/ScriptBase.java | ScriptBase | openOutput | class ScriptBase extends ManipulationStatement {
/**
* The default name of the script file if .zip compression is used.
*/
private static final String SCRIPT_SQL = "script.sql";
/**
* The output stream.
*/
protected OutputStream out;
/**
* The input stream.
*/
pr... |
String file = getFileName();
if (file == null) {
return;
}
if (isEncrypted()) {
initStore();
out = new FileStorageOutputStream(fileStorage, session.getDatabase(), compressionAlgorithm);
// always use a big buffer, otherwise end-of-block is... | 1,042 | 207 | 1,249 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/SetSession.java | SetSession | update | class SetSession extends SetStatement {
private final SessionSetting setting;
public SetSession(ServerSession session, SessionSetting type) {
super(session);
this.setting = type;
}
@Override
protected String getSettingName() {
return setting.getName();
}
@Override... |
Database database = session.getDatabase();
switch (setting) {
case LOCK_TIMEOUT:
session.setLockTimeout(getAndValidateIntValue());
break;
case QUERY_TIMEOUT:
session.setQueryTimeout(getAndValidateIntValue());
break;
case SCHEMA:
... | 100 | 499 | 599 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public int getType() ,public boolean needRecompile() ,public void setExpression(com.lealone.sql.expression.Expression) ,public void setInt(int) ,public void setString(java.lang.String) ,public void setStringArray(java.lang.String[]) <variables>protected... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/SetStatement.java | SetStatement | databaseChanged | class SetStatement extends ManipulationStatement {
protected Expression expression;
protected String stringValue;
protected String[] stringValueList;
public SetStatement(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.SET;
... |
// the meta data information has changed
db.getNextModificationDataId();
// query caches might be affected as well, for example
// when changing the compatibility mode
db.getNextModificationMetaId();
| 531 | 56 | 587 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/TransactionStatement.java | TransactionStatement | update | class TransactionStatement extends ManipulationStatement {
private final int type;
private String savepointName;
public TransactionStatement(ServerSession session, int type) {
super(session);
this.type = type;
}
@Override
public int getType() {
return type;
}
... |
switch (type) {
case SQLStatement.SET_AUTOCOMMIT_TRUE:
session.setAutoCommit(true);
break;
case SQLStatement.SET_AUTOCOMMIT_FALSE:
session.setAutoCommit(false);
break;
case SQLStatement.BEGIN:
session.begin();
break... | 272 | 334 | 606 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/UpDel.java | UpDel | appendPlanSQL | class UpDel extends ManipulationStatement {
protected TableFilter tableFilter;
protected Expression condition;
/**
* The limit expression as specified in the LIMIT or TOP clause.
*/
protected Expression limitExpr;
public UpDel(ServerSession session) {
super(session);
}
... |
if (condition != null) {
buff.append("\nWHERE ").append(StringUtils.unEnclose(condition.getSQL()));
}
if (limitExpr != null) {
buff.append("\nLIMIT (").append(StringUtils.unEnclose(limitExpr.getSQL())).append(')');
}
| 1,185 | 85 | 1,270 | <methods>public void <init>(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/dml/Update.java | YieldableUpdate | updateRow | class YieldableUpdate extends YieldableUpDel {
final Update statement;
final Column[] columns;
final int[] updateColumnIndexes;
final int columnCount;
public YieldableUpdate(Update statement, AsyncHandler<AsyncResult<Integer>> asyncHandler) {
super(statement, asyncH... |
onPendingOperationStart();
table.updateRow(session, oldRow, newRow, updateColumnIndexes, true).onComplete(ar -> {
if (ar.isSucceeded() && table.fireRow()) {
table.fireAfterRow(session, oldRow, newRow, false);
}
onPendingOperati... | 611 | 93 | 704 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public int getPriority() ,public boolean isCacheable() ,public void setCondition(com.lealone.sql.expression.Expression) ,public void setLimit(com.lealone.sql.expression.Expression) ,public void setTableFilter(com.lealone.sql.optimizer.TableFilter) ,publ... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/executor/YieldableBase.java | YieldableBase | recompileIfNeeded | class YieldableBase<T> implements Yieldable<T> {
protected StatementBase statement;
protected final ServerSession session;
protected final Trace trace;
protected final AsyncHandler<AsyncResult<T>> asyncHandler;
protected AsyncResult<T> asyncResult;
protected long startTimeNanos;
protected b... |
if (statement.needRecompile()) {
statement.setModificationMetaId(0);
String sql = statement.getSQL();
ArrayList<Parameter> oldParams = statement.getParameters();
statement = (StatementBase) session.parseStatement(sql);
long mod = statement.getModifica... | 1,444 | 212 | 1,656 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/executor/YieldableLocalUpdate.java | YieldableLocalUpdate | executeInternal | class YieldableLocalUpdate extends YieldableUpdateBase {
public YieldableLocalUpdate(StatementBase statement,
AsyncHandler<AsyncResult<Integer>> asyncHandler) {
super(statement, asyncHandler);
}
@Override
protected void executeInternal() {<FILL_FUNCTION_BODY>}
} |
session.setStatus(SessionStatus.STATEMENT_RUNNING);
int updateCount = statement.update();
setResult(updateCount);
// 返回的值为负数时,表示当前语句无法正常执行,需要等待其他事务释放锁。
// 当 updateCount<0 时不能再设置为 WAITING 状态,
// 一方面已经设置过了,另一方面如果此时其他事务释放锁了再设置会导致当前语句在后续无法执行。
if (updateCount >= 0) {... | 82 | 150 | 232 | <methods>public void <init>(com.lealone.sql.StatementBase, AsyncHandler<AsyncResult<java.lang.Integer>>) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/executor/YieldableLoopUpdateBase.java | YieldableLoopUpdateBase | handleResult | class YieldableLoopUpdateBase extends YieldableUpdateBase {
protected final AtomicInteger updateCount = new AtomicInteger();
protected int loopCount;
private boolean loopEnd;
private int pendingOperationCount;
public YieldableLoopUpdateBase(StatementBase statement,
AsyncHandler<AsyncRe... |
if (loopEnd && pendingOperationCount <= 0) {
setResult(updateCount.get());
session.setStatus(SessionStatus.STATEMENT_COMPLETED);
}
| 425 | 47 | 472 | <methods>public void <init>(com.lealone.sql.StatementBase, AsyncHandler<AsyncResult<java.lang.Integer>>) <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/Alias.java | Alias | getColumnName | class Alias extends Expression {
private final String alias;
private Expression expr;
private final boolean aliasColumnName;
public Alias(Expression expression, String alias, boolean aliasColumnName) {
this.expr = expression;
this.alias = alias;
this.aliasColumnName = aliasColu... |
if (!(expr instanceof ExpressionColumn) || aliasColumnName) {
return super.getColumnName();
}
return expr.getColumnName();
| 538 | 42 | 580 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/ExpressionList.java | ExpressionList | getValue | class ExpressionList extends Expression {
private final Expression[] list;
public ExpressionList(Expression[] list) {
this.list = list;
}
public Expression[] getList() {
return list;
}
@Override
public Value getValue(ServerSession session) {<FILL_FUNCTION_BODY>}
@Ove... |
Value[] v = new Value[list.length];
for (int i = 0; i < list.length; i++) {
v[i] = list[i].getValue(session);
}
return ValueArray.get(v);
| 638 | 63 | 701 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/Parameter.java | Parameter | getNullable | class Parameter extends Expression implements CommandParameter {
private Value value;
private Column column;
private final int index;
public Parameter(int index) {
this.index = index;
}
@Override
public String getSQL() {
return "?" + (index + 1);
}
@Override
p... |
if (column != null) {
return column.isNullable() ? Column.NULLABLE : Column.NOT_NULLABLE;
}
return super.getNullable();
| 814 | 45 | 859 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/SelectOrderBy.java | SelectOrderBy | getSQL | class SelectOrderBy {
/**
* The order by expression.
*/
public Expression expression;
/**
* The column index expression. This can be a column index number (1 meaning
* the first column of the select list) or a parameter (the parameter is a
* number representing the column index nu... |
StringBuilder buff = new StringBuilder();
if (expression != null) {
buff.append(expression.getSQL());
} else {
buff.append(columnIndexExpr.getSQL());
}
if (descending) {
buff.append(" DESC");
}
if (nullsFirst) {
buf... | 192 | 127 | 319 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/ValueExpression.java | ValueExpression | getExpressionColumns | class ValueExpression extends Expression {
/**
* The expression represents ValueNull.INSTANCE.
*/
private static final Object NULL = new ValueExpression(ValueNull.INSTANCE);
/**
* This special expression represents the default value. It is used for
* UPDATE statements of the form SET C... |
if (getType() == Value.ARRAY) {
return getExpressionColumns(session, (ValueArray) getValue(session));
}
return super.getExpressionColumns(session);
| 786 | 49 | 835 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/Wildcard.java | Wildcard | getSQL | class Wildcard extends Expression {
private final String schema;
private final String table;
public Wildcard(String schema, String table) {
this.schema = schema;
this.table = table;
}
@Override
public boolean isWildcard() {
return true;
}
@Override
public ... |
if (table == null) {
return "*";
}
return StringUtils.quoteIdentifier(table) + ".*";
| 478 | 36 | 514 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/ACount.java | ACount | optimize | class ACount extends BuiltInAggregate {
public ACount(int type, Expression on, Select select, boolean distinct) {
super(type, on, select, distinct);
}
@Override
public Expression optimize(ServerSession session) {<FILL_FUNCTION_BODY>}
@Override
protected AggregateData createAggregateDa... |
super.optimize(session);
dataType = Value.LONG;
scale = 0;
precision = ValueLong.PRECISION;
displaySize = ValueLong.DISPLAY_SIZE;
return this;
| 467 | 59 | 526 | <methods>public void <init>(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public R accept(ExpressionVisitor<R>) ,public int getAType() ,public com.lealone.sql.expression.aggregate.AggregateData getAggregateData() ,public int getCost() ,public int getDisplaySize() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/ACountAll.java | ACountAll | optimize | class ACountAll extends BuiltInAggregate {
public ACountAll(int type, Expression on, Select select, boolean distinct) {
super(type, on, select, distinct);
// 在Parser.readAggregate那里确保使用COUNT_ALL时distinct是false
if (distinct) {
throw DbException.getInternalError();
}
}... |
super.optimize(session);
dataType = Value.LONG;
scale = 0;
precision = ValueLong.PRECISION;
displaySize = ValueLong.DISPLAY_SIZE;
return this;
| 319 | 59 | 378 | <methods>public void <init>(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public R accept(ExpressionVisitor<R>) ,public int getAType() ,public com.lealone.sql.expression.aggregate.AggregateData getAggregateData() ,public int getCost() ,public int getDisplaySize() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/AGroupConcat.java | AGroupConcat | initOrder | class AGroupConcat extends BuiltInAggregate {
private Expression groupConcatSeparator;
private ArrayList<SelectOrderBy> groupConcatOrderList;
private SortOrder groupConcatSort;
public AGroupConcat(int type, Expression on, Select select, boolean distinct) {
super(type, on, select, distinct);
... |
int size = groupConcatOrderList.size();
int[] index = new int[size];
int[] sortType = new int[size];
for (int i = 0; i < size; i++) {
SelectOrderBy o = groupConcatOrderList.get(i);
index[i] = i + 1;
int order = o.descending ? SortOrder.DESCENDING : So... | 1,524 | 142 | 1,666 | <methods>public void <init>(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public R accept(ExpressionVisitor<R>) ,public int getAType() ,public com.lealone.sql.expression.aggregate.AggregateData getAggregateData() ,public int getCost() ,public int getDisplaySize() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/AHistogram.java | AggregateDataHistogram | getValue | class AggregateDataHistogram extends AggregateData {
private long count;
private ValueHashMap<AggregateDataHistogram> distinctValues;
@Override
public void add(ServerSession session, Value v) {
if (distinctValues == null) {
distinctValues = ValueHashMap.newI... |
ValueArray[] values = new ValueArray[distinctValues.size()];
int i = 0;
for (Value dv : distinctValues.keys()) {
AggregateDataHistogram d = distinctValues.get(dv);
values[i] = ValueArray.get(new Value[] { dv, ValueLong.get(d.count) });
... | 217 | 228 | 445 | <methods>public void <init>(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public R accept(ExpressionVisitor<R>) ,public int getAType() ,public com.lealone.sql.expression.aggregate.AggregateData getAggregateData() ,public int getCost() ,public int getDisplaySize() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/ASelectivity.java | ASelectivity | optimize | class ASelectivity extends BuiltInAggregate {
public ASelectivity(int type, Expression on, Select select, boolean distinct) {
super(type, on, select, distinct);
}
@Override
public Expression optimize(ServerSession session) {<FILL_FUNCTION_BODY>}
@Override
protected AggregateData creat... |
super.optimize(session);
dataType = Value.INT;
scale = 0;
precision = ValueInt.PRECISION;
displaySize = ValueInt.DISPLAY_SIZE;
return this;
| 592 | 58 | 650 | <methods>public void <init>(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public R accept(ExpressionVisitor<R>) ,public int getAType() ,public com.lealone.sql.expression.aggregate.AggregateData getAggregateData() ,public int getCost() ,public int getDisplaySize() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/Aggregate.java | Aggregate | create | class Aggregate extends Expression {
/**
* The aggregate type for COUNT(*).
*/
public static final int COUNT_ALL = 0;
/**
* The aggregate type for COUNT(expression).
*/
public static final int COUNT = 1;
/**
* The aggregate type for GROUP_CONCAT(...).
*/
public s... |
switch (type) {
case Aggregate.COUNT:
return new ACount(type, on, select, distinct);
case Aggregate.COUNT_ALL:
return new ACountAll(type, on, select, distinct);
case Aggregate.GROUP_CONCAT:
return new AGroupConcat(type, on, select, distinct);
... | 1,324 | 168 | 1,492 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/BuiltInAggregate.java | BuiltInAggregate | getSQL | class BuiltInAggregate extends Aggregate {
protected final int type;
protected final boolean distinct;
protected Expression on;
protected int scale;
protected long precision;
protected int displaySize;
/**
* Create a new aggregate object.
*
* @param type the aggregate type
... |
if (distinct) {
return text + "(DISTINCT " + on.getSQL() + ")";
}
return text + StringUtils.enclose(on.getSQL());
| 1,458 | 51 | 1,509 | <methods>public void <init>(com.lealone.sql.query.Select) ,public R accept(ExpressionVisitor<R>) ,public static com.lealone.sql.expression.aggregate.Aggregate create(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public static int getAggregateType(java.lang.String) ,public com.lealo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/aggregate/JavaAggregate.java | JavaAggregate | updateAggregate | class JavaAggregate extends com.lealone.sql.expression.aggregate.Aggregate {
private final UserAggregate userAggregate;
private final Expression[] args;
private int[] argTypes;
private Connection userConnection;
private Aggregate aggregate;
public JavaAggregate(UserAggregate userAggregate, Ex... |
HashMap<Expression, Object> group = select.getCurrentGroup();
if (group == null) {
// this is a different level (the enclosing query)
return;
}
int groupRowId = select.getCurrentGroupRowId();
if (lastGroupRowId == groupRowId) {
// already vis... | 894 | 313 | 1,207 | <methods>public void <init>(com.lealone.sql.query.Select) ,public R accept(ExpressionVisitor<R>) ,public static com.lealone.sql.expression.aggregate.Aggregate create(int, com.lealone.sql.expression.Expression, com.lealone.sql.query.Select, boolean) ,public static int getAggregateType(java.lang.String) ,public com.lealo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/condition/ConditionExists.java | ConditionExists | updateAggregate | class ConditionExists extends Condition {
private final Query query;
public ConditionExists(Query query) {
this.query = query;
}
public Query getQuery() {
return query;
}
@Override
public Value getValue(ServerSession session) {
query.setSession(session);
R... |
// TODO exists: is it allowed that the subquery contains aggregates?
// probably not
// select id from test group by id having exists (select * from test2
// where id=count(test.id))
| 301 | 55 | 356 | <methods>public int getDisplaySize() ,public long getPrecision() ,public int getScale() ,public int getType() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/condition/ConditionIn.java | ConditionIn | optimize | class ConditionIn extends Condition {
private final Database database;
private Expression left;
private final ArrayList<Expression> valueList;
private int queryLevel;
/**
* Create a new IN(..) condition.
*
* @param database the database
* @param left the expression before IN
... |
left = left.optimize(session);
boolean constant = left.isConstant();
if (constant && left == ValueExpression.getNull()) {
return left;
}
boolean allValuesConstant = true;
boolean allValuesNull = true;
int size = valueList.size();
for (int i = ... | 962 | 381 | 1,343 | <methods>public int getDisplaySize() ,public long getPrecision() ,public int getScale() ,public int getType() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/condition/ConditionInConstantSet.java | ConditionInConstantSet | getValue | class ConditionInConstantSet extends Condition {
private Expression left;
private int queryLevel;
private final ArrayList<Expression> valueList;
private final HashSet<Value> valueSet;
/**
* Create a new IN(..) condition.
*
* @param session the session
* @param left the expressi... |
Value x = left.getValue(session);
if (x == ValueNull.INSTANCE) {
return x;
}
boolean result = valueSet.contains(x);
if (!result) {
boolean setHasNull = valueSet.contains(ValueNull.INSTANCE);
if (setHasNull) {
return ValueNull.I... | 825 | 106 | 931 | <methods>public int getDisplaySize() ,public long getPrecision() ,public int getScale() ,public int getType() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/condition/ConditionInSelect.java | ConditionInSelect | getValue | class ConditionInSelect extends Condition {
private final Database database;
private Expression left;
private final Query query;
private final boolean all;
private final int compareType;
private SubQueryResult rows;
public ConditionInSelect(Database database, Expression left, Query query, ... |
if (rows == null) {
query.setSession(session);
rows = new SubQueryResult(query, 0);
session.addTemporaryResult(rows);
} else {
rows.reset();
}
Value l = left.getValue(session);
if (rows.getRowCount() == 0) {
return Valu... | 914 | 327 | 1,241 | <methods>public int getDisplaySize() ,public long getPrecision() ,public int getScale() ,public int getType() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/condition/ConditionNot.java | ConditionNot | optimize | class ConditionNot extends Condition {
private Expression condition;
public ConditionNot(Expression condition) {
this.condition = condition;
}
public Expression getCondition() {
return condition;
}
@Override
public Expression getNotIfPossible(ServerSession session) {
... |
Expression e2 = condition.getNotIfPossible(session);
if (e2 != null) {
return e2.optimize(session);
}
Expression expr = condition.optimize(session);
if (expr.isConstant()) {
Value v = expr.getValue(session);
if (v == ValueNull.INSTANCE) {
... | 416 | 144 | 560 | <methods>public int getDisplaySize() ,public long getPrecision() ,public int getScale() ,public int getType() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/BuiltInFunction.java | BuiltInFunction | getNullOrValue | class BuiltInFunction extends Function {
protected final Database database;
protected final FunctionInfo info;
private ArrayList<Expression> varArgs;
protected int dataType, scale;
protected long precision = PRECISION_UNKNOWN;
protected int displaySize;
protected BuiltInFunction(Database d... |
if (i >= args.length) {
return null;
}
Value v = values[i];
if (v == null && args[i] != null) {
v = values[i] = args[i].getValue(session);
}
return v;
| 1,798 | 73 | 1,871 | <methods>public non-sealed void <init>() ,public static void deregisterFunctionFactory(com.lealone.sql.expression.function.FunctionFactory) ,public void doneWithParameters() ,public com.lealone.sql.expression.Expression[] getArgs() ,public static com.lealone.sql.expression.function.Function getFunction(com.lealone.db.D... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/BuiltInFunctionFactory.java | BuiltInFunctionFactory | createFunction | class BuiltInFunctionFactory implements FunctionFactory {
public static final BuiltInFunctionFactory INSTANCE = new BuiltInFunctionFactory();
public static void register() {
Function.registerFunctionFactory(INSTANCE);
}
@Override
public void init() {
DateTimeFunction.init();
... |
if (info.type < StringFunction.ASCII)
return new NumericFunction(database, info);
if (info.type < DateTimeFunction.CURDATE)
return new StringFunction(database, info);
if (info.type < SystemFunction.DATABASE)
return new DateTimeFunction(database, info);
... | 142 | 117 | 259 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/Function.java | Function | addFunction | class Function extends Expression {
protected static final int VAR_ARGS = -1;
protected static final long PRECISION_UNKNOWN = -1;
private static final HashMap<String, FunctionInfo> FUNCTIONS = new HashMap<>();
private static final CopyOnWriteArrayList<FunctionFactory> FACTORIES = new CopyOnWriteArrayL... |
FunctionInfo info = new FunctionInfo();
info.name = name;
info.type = type;
info.parameterCount = parameterCount;
info.dataType = dataType;
info.nullIfParameterIsNull = nullIfParameterIsNull;
info.deterministic = deterministic;
FUNCTIONS.put(name, info);
... | 1,478 | 94 | 1,572 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/FunctionIndex.java | FunctionCursor | get | class FunctionCursor implements Cursor {
private final Result result;
private Value[] values;
private Row row;
FunctionCursor(Result result) {
this.result = result;
}
@Override
public Row get() {<FILL_FUNCTION_BODY>}
@Override
publi... |
if (values == null) {
return null;
}
if (row == null) {
row = new Row(values, 1);
}
return row;
| 143 | 49 | 192 | <methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public int compareRows(com.lealone.db.result.SearchRow, com.lealone.db.result.SearchRow) ,public com.lealone.db.index.Cursor find(com.lealone.db.session.ServerSessio... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/FunctionTable.java | FunctionTable | getResult | class FunctionTable extends Table {
private final Function function;
private final Expression functionExpr;
private LocalResult cachedResult;
private Value cachedValue;
public FunctionTable(Schema schema, ServerSession session, Function function) {
super(schema, 0, function.getName(), fals... |
ValueResultSet v = getValueResultSet(session);
if (v == null) {
return null;
}
if (cachedResult != null && cachedValue == v) {
cachedResult.reset();
return cachedResult;
}
ResultSet rs = v.getResultSet();
LocalResult result = L... | 982 | 147 | 1,129 | <methods>public void <init>(com.lealone.db.schema.Schema, int, java.lang.String, boolean, boolean) ,public void addConstraint(com.lealone.db.constraint.Constraint) ,public void addDependencies(Set<com.lealone.db.DbObject>) ,public com.lealone.db.index.Index addIndex(com.lealone.db.session.ServerSession, java.lang.Strin... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/function/TableFunction.java | TableFunction | getSimpleResultSet | class TableFunction extends BuiltInFunction {
public static final int TABLE = 300, TABLE_DISTINCT = 301;
public static void init() {
addFunctionWithNull("TABLE", TABLE, VAR_ARGS, Value.RESULT_SET);
addFunctionWithNull("TABLE_DISTINCT", TABLE_DISTINCT, VAR_ARGS, Value.RESULT_SET);
}
pr... |
int columnCount = rs.getVisibleColumnCount();
SimpleResultSet simple = new SimpleResultSet();
for (int i = 0; i < columnCount; i++) {
String name = rs.getColumnName(i);
int sqlType = DataType.convertTypeToSQLType(rs.getColumnType(i));
int precision = MathUtil... | 1,127 | 238 | 1,365 | <methods>public R accept(ExpressionVisitor<R>) ,public void doneWithParameters() ,public int getCost() ,public int getDisplaySize() ,public int getFunctionType() ,public java.lang.String getName() ,public long getPrecision() ,public java.lang.String getSQL() ,public int getScale() ,public int getType() ,public com.leal... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/subquery/SubQuery.java | SubQuery | getExpression | class SubQuery extends Expression {
private final Query query;
private Expression expression;
public SubQuery(Query query) {
this.query = query;
}
@Override
public Value getValue(ServerSession session) {
query.setSession(session);
Result result = query.query(2);
... |
if (expression == null) {
ArrayList<Expression> expressions = query.getExpressions();
int columnCount = query.getColumnCount();
if (columnCount == 1) {
expression = expressions.get(0);
} else {
Expression[] list = new Expression[co... | 565 | 134 | 699 | <methods>public non-sealed void <init>() ,public R accept(ExpressionVisitor<R>) ,public void addFilterConditions(com.lealone.sql.optimizer.TableFilter, boolean) ,public void createIndexConditions(com.lealone.db.session.ServerSession, com.lealone.sql.optimizer.TableFilter) ,public java.lang.String getAlias() ,public boo... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/subquery/SubQueryResult.java | SubQueryResult | initDistinctRows | class SubQueryResult extends DelegatedResult {
protected ValueHashMap<Value[]> distinctRows;
protected int rowCount = -1;
public SubQueryResult(Query query, int maxRows) {
result = query.query(maxRows);
}
public boolean containsDistinct(Value[] values) {
if (result instanceof Loca... |
if (distinctRows == null) {
rowCount = 0;
distinctRows = ValueHashMap.newInstance();
int visibleColumnCount = getVisibleColumnCount();
ArrayList<Value[]> rowList = new ArrayList<>();
while (next()) {
rowCount++;
Value[... | 246 | 203 | 449 | <methods>public non-sealed void <init>() ,public void close() ,public com.lealone.db.value.Value[] currentRow() ,public java.lang.String getAlias(int) ,public java.lang.String getColumnName(int) ,public long getColumnPrecision(int) ,public int getColumnScale(int) ,public int getColumnType(int) ,public int getDisplaySiz... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/BooleanExpressionVisitor.java | BooleanExpressionVisitor | visitAGroupConcat | class BooleanExpressionVisitor extends ExpressionVisitorBase<Boolean> {
@Override
public Boolean visitExpression(Expression e) {
return true;
}
@Override
public Boolean visitAlias(Alias e) {
return e.getNonAliasExpression().accept(this);
}
@Override
public Boolean visi... |
if (!visitAggregate(e)) {
return false;
}
if (e.getGroupConcatSeparator() != null && !e.getGroupConcatSeparator().accept(this)) {
return false;
}
if (e.getGroupConcatOrderList() != null) {
for (int i = 0, size = e.getGroupConcatOrderList().siz... | 1,329 | 163 | 1,492 | <methods>public non-sealed void <init>() ,public int getQueryLevel() ,public ExpressionVisitorBase<java.lang.Boolean> incrementQueryLevel(int) ,public void setQueryLevel(int) <variables>private int queryLevel |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/DependenciesVisitor.java | DependenciesVisitor | visitQuery | class DependenciesVisitor extends VoidExpressionVisitor {
private Set<DbObject> dependencies;
public DependenciesVisitor(Set<DbObject> dependencies) {
this.dependencies = dependencies;
}
public void addDependency(DbObject obj) {
dependencies.add(obj);
}
public Set<DbObject> g... |
super.visitQuery(query);
for (int i = 0, size = query.getFilters().size(); i < size; i++) {
TableFilter f = query.getFilters().get(i);
Table table = f.getTable();
addDependency(table);
table.addDependencies(dependencies);
}
return null;
... | 325 | 92 | 417 | <methods>public non-sealed void <init>() ,public java.lang.Void visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Void visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Void visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Void visitCompa... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/DeterministicVisitor.java | DeterministicVisitor | visitJavaAggregate | class DeterministicVisitor extends BooleanExpressionVisitor {
@Override
public Boolean visitRownum(Rownum e) {
return false;
}
@Override
public Boolean visitSequenceValue(SequenceValue e) {
return false;
}
@Override
public Boolean visitVariable(Variable e) {
re... |
// TODO optimization: some functions are deterministic, but we don't
// know (no setting for that)
return false;
| 235 | 35 | 270 | <methods>public non-sealed void <init>() ,public java.lang.Boolean visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Boolean visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Boolean visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Boolea... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/ExpressionVisitorBase.java | ExpressionVisitorBase | incrementQueryLevel | class ExpressionVisitorBase<R> implements ExpressionVisitor<R> {
private int queryLevel;
@Override
public ExpressionVisitorBase<R> incrementQueryLevel(int offset) {<FILL_FUNCTION_BODY>}
public void setQueryLevel(int queryLevel) {
this.queryLevel = queryLevel;
}
@Override
public i... |
ExpressionVisitorBase<R> c = copy();
c.setQueryLevel(getQueryLevel() + offset);
return c;
| 138 | 37 | 175 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/MapColumnsVisitor.java | MapColumnsVisitor | visitJavaAggregate | class MapColumnsVisitor extends VoidExpressionVisitor {
private ColumnResolver resolver;
private int level;
public MapColumnsVisitor(ColumnResolver resolver, int level) {
this.resolver = resolver;
this.level = level;
}
@Override
public Void visitExpressionColumn(ExpressionColu... |
// 聚合函数不能嵌套
if (resolver.getState() == ColumnResolver.STATE_IN_AGGREGATE) {
throw DbException.get(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, e.getSQL());
}
int state = resolver.getState();
resolver.setState(ColumnResolver.STATE_IN_AGGREGATE);
try {
... | 772 | 148 | 920 | <methods>public non-sealed void <init>() ,public java.lang.Void visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Void visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Void visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Void visitCompa... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/MaxModificationIdVisitor.java | MaxModificationIdVisitor | visitQuery | class MaxModificationIdVisitor extends VoidExpressionVisitor {
private long maxDataModificationId;
public long getMaxDataModificationId() {
return maxDataModificationId;
}
public void setMaxDataModificationId(long maxDataModificationId) {
if (maxDataModificationId > this.maxDataModifi... |
super.visitQuery(query);
for (int i = 0, size = query.getFilters().size(); i < size; i++) {
TableFilter f = query.getFilters().get(i);
long m = f.getTable().getMaxDataModificationId();
setMaxDataModificationId(m);
}
return null;
| 240 | 92 | 332 | <methods>public non-sealed void <init>() ,public java.lang.Void visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Void visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Void visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Void visitCompa... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/OptimizableVisitor.java | OptimizableVisitor | visitJavaAggregate | class OptimizableVisitor extends BooleanExpressionVisitor {
private final Table table;
public OptimizableVisitor(Table table) {
this.table = table;
}
@Override
public Boolean visitRownum(Rownum e) {
return false;
}
@Override
public Boolean visitExpressionColumn(Expres... |
// user defined aggregate functions can not be optimized
return false;
| 182 | 19 | 201 | <methods>public non-sealed void <init>() ,public java.lang.Boolean visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Boolean visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Boolean visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Boolea... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/expression/visitor/VoidExpressionVisitor.java | VoidExpressionVisitor | visitFunction | class VoidExpressionVisitor extends ExpressionVisitorBase<Void> {
@Override
public Void visitExpression(Expression e) {
return null;
}
@Override
public Void visitAlias(Alias e) {
return e.getNonAliasExpression().accept(this);
}
@Override
public Void visitExpressionColu... |
for (Expression e2 : e.getArgs()) {
if (e2 != null)
e2.accept(this);
}
return null;
| 1,493 | 44 | 1,537 | <methods>public non-sealed void <init>() ,public int getQueryLevel() ,public ExpressionVisitorBase<java.lang.Void> incrementQueryLevel(int) ,public void setQueryLevel(int) <variables>private int queryLevel |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/optimizer/Permutations.java | Permutations | moveIndex | class Permutations<T> {
private final T[] in;
private final T[] out;
private final int n, m;
private final int[] index;
private boolean hasNext = true;
private Permutations(T[] in, T[] out, int m) {
this.n = in.length;
this.m = m;
if (n < m || m < 0) {
DbExc... |
// find the index of the first element that dips
int i = rightmostDip();
if (i < 0) {
hasNext = false;
return;
}
// find the least greater element to the right of the dip
int leastToRightIndex = i + 1;
for (int j = i + 2; j < n; j++) {
... | 1,043 | 246 | 1,289 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/optimizer/Plan.java | Plan | calculateCost | class Plan {
private final TableFilter[] filters;
private final HashMap<TableFilter, PlanItem> planItems = new HashMap<>();
private final TableFilter[] allFilters;
/**
* Create a query plan with the given order.
*
* @param filters the tables of the query
* @param count the number o... |
double cost = 1;
boolean invalidPlan = false;
int level = 1;
for (TableFilter tableFilter : allFilters) {
PlanItem item = tableFilter.getBestPlanItem(session, level++);
planItems.put(tableFilter, item);
cost += cost * item.cost;
setEvaluat... | 607 | 198 | 805 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/optimizer/TableIterator.java | TableIterator | tryLockRow | class TableIterator {
private final ServerSession session;
private final TableFilter tableFilter;
private final Table table;
private Row oldRow;
private Cursor cursor;
public TableIterator(ServerSession session, TableFilter tableFilter) {
this.session = session;
this.tableFilte... |
Row oldRow = getRow();
if (oldRow == null) { // 已经删除了
return -1;
}
int ret = table.tryLockRow(session, oldRow, lockColumns);
if (ret < 0) { // 已经删除了
return -1;
} else if (ret == 0) { // 被其他事务锁住了
this.oldRow = oldRow;
return... | 395 | 153 | 548 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QAggregate.java | QAggregate | run | class QAggregate extends QOperator {
QAggregate(Select select) {
super(select);
select.currentGroup = new HashMap<>();
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
} |
while (next()) {
boolean yield = yieldIfNeeded(++loopCount);
if (conditionEvaluator.getBooleanValue()) {
if (select.isForUpdate && !tryLockRow()) {
return; // 锁记录失败
}
rowCount++;
select.currentGroupRowId... | 67 | 231 | 298 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QAggregateQuick.java | QAggregateQuick | run | class QAggregateQuick extends QOperator {
QAggregateQuick(Select select) {
super(select);
}
@Override
public void start() {
// 什么都不需要做
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
} |
Value[] row = createRow();
result.addRow(row);
rowCount = 1;
loopEnd = true;
| 80 | 35 | 115 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QDistinct.java | QDistinct | run | class QDistinct extends QOperator {
private final Index index;
private final int[] columnIds;
private final int size;
private Cursor cursor;
QDistinct(Select select) {
super(select);
index = select.getTopTableFilter().getIndex();
columnIds = index.getColumnIds();
si... |
while (next()) {
if (select.isForUpdate && !tryLockRow()) {
return; // 锁记录失败
}
boolean yield = yieldIfNeeded(++loopCount);
SearchRow found = cursor.getSearchRow();
Value[] row = new Value[size];
for (int i = 0; i < size; i+... | 184 | 163 | 347 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QFlat.java | QFlat | run | class QFlat extends QOperator {
QFlat(Select select) {
super(select);
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
} |
while (next()) {
boolean yield = yieldIfNeeded(++loopCount);
if (conditionEvaluator.getBooleanValue()) {
if (select.isForUpdate && !tryLockRow()) {
return; // 锁记录失败
}
Value[] row = createRow();
result.ad... | 55 | 130 | 185 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QGroup.java | QGroup | addGroupRow | class QGroup extends QOperator {
private final ValueHashMap<HashMap<Expression, Object>> groups;
QGroup(Select select) {
super(select);
select.currentGroup = null;
groups = ValueHashMap.newInstance();
}
public ValueHashMap<HashMap<Expression, Object>> getGroups() {
ret... |
Value[] row = new Value[columnCount];
for (int i = 0; select.groupIndex != null && i < select.groupIndex.length; i++) {
row[select.groupIndex[i]] = keyValues[i];
}
for (int i = 0; i < columnCount; i++) {
if (select.groupByExpression != null && select.groupByExpre... | 999 | 201 | 1,200 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QGroupSorted.java | QGroupSorted | run | class QGroupSorted extends QOperator {
private Value[] previousKeyValues;
QGroupSorted(Select select) {
super(select);
select.currentGroup = null;
}
public Value[] getPreviousKeyValues() {
return previousKeyValues;
}
@Override
public void run() {<FILL_FUNCTION_BOD... |
while (next()) {
boolean yield = yieldIfNeeded(++loopCount);
if (conditionEvaluator.getBooleanValue()) {
if (select.isForUpdate && !tryLockRow()) {
return; // 锁记录失败
}
rowCount++;
Value[] keyValues = QGro... | 98 | 266 | 364 | <methods>public void <init>(com.lealone.sql.query.Select) ,public boolean canBreakLoop() ,public void copyStatusTo(com.lealone.sql.query.QOperator) ,public com.lealone.sql.expression.evaluator.ExpressionEvaluator createConditionEvaluator(com.lealone.sql.expression.Expression) ,public com.lealone.db.value.Value[] create... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QOperator.java | QOperator | start | class QOperator implements Operator {
protected final Select select;
protected final ServerSession session;
protected final ExpressionEvaluator conditionEvaluator;
protected final TableIterator tableIterator;
protected int columnCount;
protected ResultTarget target;
protected ResultTarget ... |
limitRows = maxRows;
// 并不会按offset先跳过前面的行数,而是limitRows加上offset,读够limitRows+offset行,然后再从result中跳
// 因为可能需要排序,offset是相对于最后的结果来说的,而不是排序前的结果
// limitRows must be long, otherwise we get an int overflow
// if limitRows is at or near Integer.MAX_VALUE
// limitRows is never 0 he... | 1,030 | 237 | 1,267 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/QueryResultCache.java | QueryResultCache | sameParamsAsLast | class QueryResultCache {
private final Select select;
private final ServerSession session;
private boolean noCache;
private int lastLimit;
private long lastEvaluated;
private Value[] lastParameters;
private LocalResult lastResult;
private boolean cacheableChecked;
QueryResultCache... |
if (params == null && lastParameters == null)
return true;
if (params != null && lastParameters != null) {
if (params.length != lastParameters.length)
return false;
for (int i = 0; i < params.length; i++) {
Value a = lastParameters[i],... | 810 | 143 | 953 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/query/YieldableSelect.java | YieldableSelect | executeInternal | class YieldableSelect extends YieldableQueryBase {
private final Select select;
private final ResultTarget target;
private final int olapThreshold;
private boolean olapDisabled;
private Operator queryOperator;
public YieldableSelect(Select select, int maxRows, boolean scrollable,
A... |
while (true) {
session.setStatus(SessionStatus.STATEMENT_RUNNING);
try {
queryOperator.run();
} catch (RuntimeException e) {
if (DbObjectLock.LOCKED_EXCEPTION == e) {
queryOperator.onLockedException();
} els... | 1,636 | 273 | 1,909 | <methods>public void <init>(com.lealone.sql.StatementBase, int, boolean, AsyncHandler<AsyncResult<com.lealone.db.result.Result>>) <variables>protected final non-sealed int maxRows,protected final non-sealed boolean scrollable |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/BoundSqlInterceptorChain.java | BoundSqlInterceptorChain | _doBoundSql | class BoundSqlInterceptorChain implements BoundSqlInterceptor.Chain {
private final BoundSqlInterceptor.Chain original;
private final List<BoundSqlInterceptor> interceptors;
private int index = 0;
private boolean executable;
public BoundSqlInterceptorChain(BoundSqlInterceptor.Chain original, L... |
if (this.interceptors == null || this.interceptors.size() == this.index) {
return this.original != null ? this.original.doBoundSql(type, boundSql, cacheKey) : boundSql;
} else {
return this.interceptors.get(this.index++).boundSql(type, boundSql, cacheKey, this);
}
| 334 | 96 | 430 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/PageHelper.java | PageHelper | setProperties | class PageHelper extends PageMethod implements Dialect, BoundSqlInterceptor.Chain {
private PageParams pageParams;
private PageAutoDialect autoDialect;
private PageBoundSqlInterceptors pageBoundSqlInterceptors;
private ForkJoinPool asyncCountService;
@Override
... |
setStaticProperties(properties);
pageParams = new PageParams();
autoDialect = new PageAutoDialect();
pageBoundSqlInterceptors = new PageBoundSqlInterceptors();
pageParams.setProperties(properties);
autoDialect.setProperties(properties);
pageBoundSqlInterceptors.s... | 1,381 | 316 | 1,697 | <methods>public non-sealed void <init>() ,public static void clearPage() ,public static long count(com.github.pagehelper.ISelect) ,public static Page<T> getLocalPage() ,public static Page<E> offsetPage(int, int) ,public static Page<E> offsetPage(int, int, boolean) ,public static void orderBy(java.lang.String) ,public s... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/PageSerializable.java | PageSerializable | toString | class PageSerializable<T> implements Serializable {
private static final long serialVersionUID = 1L;
//总记录数
protected long total;
//结果集
protected List<T> list;
public PageSerializable() {
}
@SuppressWarnings("unchecked")
public PageSerializable(List<? extends T> list) {
... |
return "PageSerializable{" +
"total=" + total +
", list=" + list +
'}';
| 306 | 35 | 341 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/QueryInterceptor.java | QueryInterceptor | intercept | class QueryInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {<FILL_FUNCTION_BODY>}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties prope... |
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowBounds = (RowBounds) args[2];
ResultHandler resultHandler = (ResultHandler) args[3];
Executor executor = (Executor) invocation.getTarget();
... | 97 | 277 | 374 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/cache/CacheFactory.java | CacheFactory | createCache | class CacheFactory {
/**
* 创建 SQL 缓存
*
* @param sqlCacheClass
* @return
*/
public static <K, V> Cache<K, V> createCache(String sqlCacheClass, String prefix, Properties properties) {<FILL_FUNCTION_BODY>}
} |
if (StringUtil.isEmpty(sqlCacheClass)) {
try {
Class.forName("com.google.common.cache.Cache");
return new GuavaCache<K, V>(properties, prefix);
} catch (Throwable t) {
return new SimpleCache<K, V>(properties, prefix);
}
... | 82 | 254 | 336 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/cache/SimpleCache.java | SimpleCache | get | class SimpleCache<K, V> implements Cache<K, V> {
private final org.apache.ibatis.cache.Cache CACHE;
public SimpleCache(Properties properties, String prefix) {
CacheBuilder cacheBuilder = new CacheBuilder("SQL_CACHE");
String typeClass = properties.getProperty(prefix + ".typeClass");
if... |
Object value = CACHE.getObject(key);
if (value != null) {
return (V) value;
}
return null;
| 503 | 43 | 546 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/AbstractRowBoundsDialect.java | AbstractRowBoundsDialect | beforeCount | class AbstractRowBoundsDialect extends AbstractDialect {
@Override
public boolean skip(MappedStatement ms, Object parameterObject, RowBounds rowBounds) {
return rowBounds == RowBounds.DEFAULT;
}
@Override
public boolean beforeCount(MappedStatement ms, Object parameterObject, RowBounds rowB... |
if(rowBounds instanceof PageRowBounds){
PageRowBounds pageRowBounds = (PageRowBounds)rowBounds;
return pageRowBounds.getCount() == null || pageRowBounds.getCount();
}
return false;
| 410 | 59 | 469 | <methods>public non-sealed void <init>() ,public java.lang.String getCountSql(org.apache.ibatis.mapping.MappedStatement, org.apache.ibatis.mapping.BoundSql, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.cache.CacheKey) ,public void setProperties(java.util.Properties) <variables>protected com.... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/auto/DataSourceAutoDialect.java | DataSourceAutoDialect | extractDialectKey | class DataSourceAutoDialect<Ds extends DataSource> implements AutoDialect<String> {
protected Class dataSourceClass;
public DataSourceAutoDialect() {
Type genericSuperclass = getClass().getGenericSuperclass();
dataSourceClass = (Class) ((ParameterizedType) genericSuperclass).getActualTypeArgume... |
if (dataSourceClass.isInstance(dataSource)) {
return getJdbcUrl((Ds) dataSource);
}
return null;
| 227 | 40 | 267 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/auto/DataSourceNegotiationAutoDialect.java | DataSourceNegotiationAutoDialect | extractDialectKey | class DataSourceNegotiationAutoDialect implements AutoDialect<String> {
private static final List<DataSourceAutoDialect> AUTO_DIALECTS = new ArrayList<DataSourceAutoDialect>();
private Map<String, DataSourceAutoDialect> urlMap = new ConcurrentHashMap<String, DataSourceAutoDialect>();
... |
for (DataSourceAutoDialect autoDialect : AUTO_DIALECTS) {
String dialectKey = autoDialect.extractDialectKey(ms, dataSource, properties);
if (dialectKey != null) {
if (!urlMap.containsKey(dialectKey)) {
urlMap.put(dialectKey, autoDialect);
... | 583 | 149 | 732 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/auto/DefaultAutoDialect.java | DefaultAutoDialect | extractDialectKey | class DefaultAutoDialect implements AutoDialect<String> {
public static final AutoDialect<String> DEFAULT = new DefaultAutoDialect();
@Override
public String extractDialectKey(MappedStatement ms, DataSource dataSource, Properties properties) {<FILL_FUNCTION_BODY>}
@Override
public AbstractHelperD... |
Connection conn = null;
try {
conn = dataSource.getConnection();
return conn.getMetaData().getURL();
} catch (SQLException e) {
throw new PageException(e);
} finally {
if (conn != null) {
try {
String cl... | 205 | 146 | 351 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/AS400Dialect.java | AS400Dialect | processPageParameter | class AS400Dialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap,
Page page, BoundSql boundSql, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
return sql + "... |
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
pageKey.update(page.getStartRow());
pageKey.update(page.getPageSize());
handleParameter(boundSql, ms, long.class, int.class);
return paramMap;
| 121 | 103 | 224 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/CirroDataDialect.java | CirroDataDialect | getPageSql | class CirroDataDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow() + 1);
paramMap.put(PAGEPARAMETER_SECOND, pa... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 16);
sqlBuilder.append(sql);
sqlBuilder.append("\n LIMIT ( ?, ? )");
return sqlBuilder.toString();
| 213 | 54 | 267 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/Db2Dialect.java | Db2Dialect | getPageSql | class Db2Dialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow() + 1);
paramMap.put(PAGEPARAMETER_SECOND, page.ge... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 140);
sqlBuilder.append("SELECT * FROM (SELECT TMP_PAGE.*,ROWNUMBER() OVER() AS PAGEHELPER_ROW_ID FROM ( \n");
sqlBuilder.append(sql);
sqlBuilder.append("\n ) AS TMP_PAGE) TMP_PAGE WHERE PAGEHELPER_ROW_ID BETWEEN ? AND ?");
... | 213 | 120 | 333 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/FirebirdDialect.java | FirebirdDialect | getPageSql | class FirebirdDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.g... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 64);
sqlBuilder.append(sql);
sqlBuilder.append("\n OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ");
pageKey.update(page.getPageSize());
return sqlBuilder.toString();
| 206 | 77 | 283 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/HerdDBDialect.java | HerdDBDialect | getPageSql | class HerdDBDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.get... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 14);
sqlBuilder.append(sql);
if (page.getStartRow() == 0) {
sqlBuilder.append("\n LIMIT ? ");
} else {
sqlBuilder.append("\n LIMIT ?, ? ");
}
return sqlBuilder.toString();
| 392 | 85 | 477 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/HsqldbDialect.java | HsqldbDialect | processPageParameter | class HsqldbDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
... |
paramMap.put(PAGEPARAMETER_FIRST, page.getPageSize());
paramMap.put(PAGEPARAMETER_SECOND, page.getStartRow());
//处理pageKey
pageKey.update(page.getPageSize());
pageKey.update(page.getStartRow());
//处理参数配置
if (boundSql.getParameterMappings() != null) {
... | 193 | 282 | 475 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/InformixDialect.java | InformixDialect | processPageParameter | class InformixDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
... |
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
//处理pageKey
pageKey.update(page.getStartRow());
pageKey.update(page.getPageSize());
//处理参数配置
if (boundSql.getParameterMappings() != null) {
... | 227 | 292 | 519 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/MySqlDialect.java | MySqlDialect | getPageSql | class MySqlDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.getP... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 14);
sqlBuilder.append(sql);
if (page.getStartRow() == 0) {
sqlBuilder.append("\n LIMIT ? ");
} else {
sqlBuilder.append("\n LIMIT ?, ? ");
}
return sqlBuilder.toString();
| 403 | 85 | 488 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/Oracle9iDialect.java | Oracle9iDialect | getPageSql | class Oracle9iDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getEndRow());
paramMap.put(PAGEPARAMETER_SECOND, page.get... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 120);
sqlBuilder.append("SELECT * FROM ( ");
sqlBuilder.append(" SELECT TMP_PAGE.*, ROWNUM PAGEHELPER_ROW_ID FROM ( \n");
sqlBuilder.append(sql);
sqlBuilder.append("\n ) TMP_PAGE WHERE ROWNUM <= ? ");
sqlBuilder... | 207 | 126 | 333 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/OracleDialect.java | OracleDialect | processPageParameter | class OracleDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
... |
paramMap.put(PAGEPARAMETER_FIRST, page.getEndRow());
paramMap.put(PAGEPARAMETER_SECOND, page.getStartRow());
//处理pageKey
pageKey.update(page.getEndRow());
pageKey.update(page.getStartRow());
//处理参数配置
handleParameter(boundSql, ms, long.class, long.class);
... | 228 | 110 | 338 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/OscarDialect.java | OscarDialect | processPageParameter | class OscarDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
@Override
public String getPageSql(String sql, Page page, CacheKey pageKey) {
... |
paramMap.put(PAGEPARAMETER_FIRST, page.getPageSize() );
paramMap.put(PAGEPARAMETER_SECOND, (int) page.getStartRow() );
//处理pageKey
pageKey.update(page.getStartRow());
pageKey.update(page.getPageSize());
//处理参数配置
if (boundSql.getParameterMappings() != null) {
... | 181 | 311 | 492 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/PostgreSqlDialect.java | PostgreSqlDialect | getPageSql | class PostgreSqlDialect extends AbstractHelperDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
paramMap.put(PAGEPARAMETER_FIRST, page... |
StringBuilder sqlStr = new StringBuilder(sql.length() + 17);
sqlStr.append(sql);
if (page.getStartRow() == 0) {
sqlStr.append(" LIMIT ?");
} else {
sqlStr.append(" LIMIT ? OFFSET ?");
}
return sqlStr.toString();
| 454 | 86 | 540 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/SqlServer2012Dialect.java | SqlServer2012Dialect | getPageSql | class SqlServer2012Dialect extends SqlServerDialect {
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
paramMap.put(PAGEPARAMETER_SECOND, page.g... |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 64);
sqlBuilder.append(sql);
sqlBuilder.append("\n OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ");
pageKey.update(page.getPageSize());
return sqlBuilder.toString();
| 210 | 77 | 287 | <methods>public non-sealed void <init>() ,public java.lang.String getCountSql(org.apache.ibatis.mapping.MappedStatement, org.apache.ibatis.mapping.BoundSql, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.cache.CacheKey) ,public java.lang.String getPageSql(java.lang.String, Page#RAW, org.apache... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.