提交 679b07b0 authored 作者: Thomas Mueller's avatar Thomas Mueller

boolean getX > isX

上级 9cbd604d
...@@ -127,7 +127,7 @@ public class Optimizer { ...@@ -127,7 +127,7 @@ public class Optimizer {
double costPart = -1.0; double costPart = -1.0;
int bestPart = -1; int bestPart = -1;
for (int j = 0; j < filters.length; j++) { for (int j = 0; j < filters.length; j++) {
if (!filters[j].getUsed()) { if (!filters[j].isUsed()) {
if (i == filters.length - 1) { if (i == filters.length - 1) {
bestPart = j; bestPart = j;
break; break;
......
...@@ -239,7 +239,7 @@ public class Select extends Query { ...@@ -239,7 +239,7 @@ public class Select extends Query {
ObjectArray<Index> indexes = topTableFilter.getTable().getIndexes(); ObjectArray<Index> indexes = topTableFilter.getTable().getIndexes();
for (int i = 0; indexes != null && i < indexes.size(); i++) { for (int i = 0; indexes != null && i < indexes.size(); i++) {
Index index = indexes.get(i); Index index = indexes.get(i);
if (index.getIndexType().getScan()) { if (index.getIndexType().isScan()) {
continue; continue;
} }
if (isGroupSortedIndex(topTableFilter, index)) { if (isGroupSortedIndex(topTableFilter, index)) {
...@@ -414,7 +414,7 @@ public class Select extends Query { ...@@ -414,7 +414,7 @@ public class Select extends Query {
// can't use the scan index // can't use the scan index
continue; continue;
} }
if (index.getIndexType().getHash()) { if (index.getIndexType().isHash()) {
continue; continue;
} }
IndexColumn[] indexCols = index.getIndexColumns(); IndexColumn[] indexCols = index.getIndexColumns();
...@@ -748,10 +748,10 @@ public class Select extends Query { ...@@ -748,10 +748,10 @@ public class Select extends Query {
boolean ascending = columnIndex.getIndexColumns()[0].sortType == SortOrder.ASCENDING; boolean ascending = columnIndex.getIndexColumns()[0].sortType == SortOrder.ASCENDING;
Index current = topTableFilter.getIndex(); Index current = topTableFilter.getIndex();
// if another index is faster // if another index is faster
if (columnIndex.canFindNext() && ascending && (current == null || current.getIndexType().getScan() || columnIndex == current)) { if (columnIndex.canFindNext() && ascending && (current == null || current.getIndexType().isScan() || columnIndex == current)) {
IndexType type = columnIndex.getIndexType(); IndexType type = columnIndex.getIndexType();
// hash indexes don't work, and unique single column indexes don't work // hash indexes don't work, and unique single column indexes don't work
if (!type.getHash() && (!type.getUnique() || columnIndex.getColumns().length > 1)) { if (!type.isHash() && (!type.isUnique() || columnIndex.getColumns().length > 1)) {
topTableFilter.setIndex(columnIndex); topTableFilter.setIndex(columnIndex);
isDistinctQuery = true; isDistinctQuery = true;
} }
...@@ -762,7 +762,7 @@ public class Select extends Query { ...@@ -762,7 +762,7 @@ public class Select extends Query {
if (sort != null && !isQuickAggregateQuery && !isGroupQuery) { if (sort != null && !isQuickAggregateQuery && !isGroupQuery) {
Index index = getSortIndex(); Index index = getSortIndex();
Index current = topTableFilter.getIndex(); Index current = topTableFilter.getIndex();
if (index != null && (current.getIndexType().getScan() || current == index)) { if (index != null && (current.getIndexType().isScan() || current == index)) {
topTableFilter.setIndex(index); topTableFilter.setIndex(index);
if (!distinct || isDistinctQuery) { if (!distinct || isDistinctQuery) {
// sort using index would not work correctly for distinct result sets // sort using index would not work correctly for distinct result sets
...@@ -774,7 +774,7 @@ public class Select extends Query { ...@@ -774,7 +774,7 @@ public class Select extends Query {
if (SysProperties.OPTIMIZE_GROUP_SORTED && !isQuickAggregateQuery && isGroupQuery && getGroupByExpressionCount() > 0) { if (SysProperties.OPTIMIZE_GROUP_SORTED && !isQuickAggregateQuery && isGroupQuery && getGroupByExpressionCount() > 0) {
Index index = getGroupSortedIndex(); Index index = getGroupSortedIndex();
Index current = topTableFilter.getIndex(); Index current = topTableFilter.getIndex();
if (index != null && (current.getIndexType().getScan() || current == index)) { if (index != null && (current.getIndexType().isScan() || current == index)) {
topTableFilter.setIndex(index); topTableFilter.setIndex(index);
isGroupSortedQuery = true; isGroupSortedQuery = true;
} }
......
...@@ -52,7 +52,7 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable< ...@@ -52,7 +52,7 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable<
public Constraint(Schema schema, int id, String name, Table table) { public Constraint(Schema schema, int id, String name, Table table) {
initSchemaObjectBase(schema, id, name, Trace.CONSTRAINT); initSchemaObjectBase(schema, id, name, Trace.CONSTRAINT);
this.table = table; this.table = table;
this.setTemporary(table.getTemporary()); this.setTemporary(table.isTemporary());
} }
/** /**
......
...@@ -207,7 +207,7 @@ public class ConstraintReferential extends Constraint { ...@@ -207,7 +207,7 @@ public class ConstraintReferential extends Constraint {
public void setRefTable(Table refTable) { public void setRefTable(Table refTable) {
this.refTable = refTable; this.refTable = refTable;
if (refTable.getTemporary()) { if (refTable.isTemporary()) {
setTemporary(true); setTemporary(true);
} }
} }
......
...@@ -637,7 +637,7 @@ public class Database implements DataHandler { ...@@ -637,7 +637,7 @@ public class Database implements DataHandler {
if (pageStore != null) { if (pageStore != null) {
headPos = pageStore.getSystemTableHeadPos(); headPos = pageStore.getSystemTableHeadPos();
} }
meta = mainSchema.createTable("SYS", 0, cols, persistent, persistent, false, headPos, systemSession); meta = mainSchema.createTable("SYS", 0, cols, false, persistent, persistent, false, headPos, systemSession);
IndexColumn[] pkCols = IndexColumn.wrap(new Column[] { columnId }); IndexColumn[] pkCols = IndexColumn.wrap(new Column[] { columnId });
metaIdIndex = meta.addIndex(systemSession, "SYS_ID", 0, pkCols, IndexType.createPrimaryKey( metaIdIndex = meta.addIndex(systemSession, "SYS_ID", 0, pkCols, IndexType.createPrimaryKey(
false, false), Index.EMPTY_HEAD, null); false, false), Index.EMPTY_HEAD, null);
...@@ -709,13 +709,13 @@ public class Database implements DataHandler { ...@@ -709,13 +709,13 @@ public class Database implements DataHandler {
for (Table obj : getAllTablesAndViews()) { for (Table obj : getAllTablesAndViews()) {
if (obj instanceof TableView) { if (obj instanceof TableView) {
TableView view = (TableView) obj; TableView view = (TableView) obj;
if (view.getInvalid()) { if (view.isInvalid()) {
try { try {
view.recompile(session); view.recompile(session);
} catch (SQLException e) { } catch (SQLException e) {
// ignore // ignore
} }
if (!view.getInvalid()) { if (!view.isInvalid()) {
recompileSuccessful = true; recompileSuccessful = true;
} }
} }
...@@ -728,7 +728,7 @@ public class Database implements DataHandler { ...@@ -728,7 +728,7 @@ public class Database implements DataHandler {
for (Table obj : getAllTablesAndViews()) { for (Table obj : getAllTablesAndViews()) {
if (obj instanceof TableView) { if (obj instanceof TableView) {
TableView view = (TableView) obj; TableView view = (TableView) obj;
if (!view.getInvalid()) { if (!view.isInvalid()) {
try { try {
view.recompile(systemSession); view.recompile(systemSession);
} catch (SQLException e) { } catch (SQLException e) {
...@@ -810,7 +810,7 @@ public class Database implements DataHandler { ...@@ -810,7 +810,7 @@ public class Database implements DataHandler {
private synchronized void addMeta(Session session, DbObject obj) throws SQLException { private synchronized void addMeta(Session session, DbObject obj) throws SQLException {
int id = obj.getId(); int id = obj.getId();
if (id > 0 && !starting && !obj.getTemporary()) { if (id > 0 && !starting && !obj.isTemporary()) {
Row r = meta.getTemplateRow(); Row r = meta.getTemplateRow();
MetaRecord rec = new MetaRecord(obj); MetaRecord rec = new MetaRecord(obj);
rec.setRecord(r); rec.setRecord(r);
...@@ -918,7 +918,7 @@ public class Database implements DataHandler { ...@@ -918,7 +918,7 @@ public class Database implements DataHandler {
HashMap<String, DbObject> map = getMap(obj.getType()); HashMap<String, DbObject> map = getMap(obj.getType());
if (obj.getType() == DbObject.USER) { if (obj.getType() == DbObject.USER) {
User user = (User) obj; User user = (User) obj;
if (user.getAdmin() && systemUser.getName().equals(Constants.DBA_NAME)) { if (user.isAdmin() && systemUser.getName().equals(Constants.DBA_NAME)) {
systemUser.rename(user.getName()); systemUser.rename(user.getName());
} }
} }
...@@ -1304,7 +1304,6 @@ public class Database implements DataHandler { ...@@ -1304,7 +1304,6 @@ public class Database implements DataHandler {
if ((i & 1) != (dataFile ? 1 : 0)) { if ((i & 1) != (dataFile ? 1 : 0)) {
i++; i++;
} }
while (storageMap.get(i) != null || objectIds.get(i)) { while (storageMap.get(i) != null || objectIds.get(i)) {
i++; i++;
if ((i & 1) != (dataFile ? 1 : 0)) { if ((i & 1) != (dataFile ? 1 : 0)) {
...@@ -1677,21 +1676,21 @@ public class Database implements DataHandler { ...@@ -1677,21 +1676,21 @@ public class Database implements DataHandler {
int type = obj.getType(); int type = obj.getType();
if (type == DbObject.TABLE_OR_VIEW) { if (type == DbObject.TABLE_OR_VIEW) {
Table table = (Table) obj; Table table = (Table) obj;
if (table.getTemporary() && !table.getGlobalTemporary()) { if (table.isTemporary() && !table.isGlobalTemporary()) {
session.removeLocalTempTable(table); session.removeLocalTempTable(table);
return; return;
} }
} else if (type == DbObject.INDEX) { } else if (type == DbObject.INDEX) {
Index index = (Index) obj; Index index = (Index) obj;
Table table = index.getTable(); Table table = index.getTable();
if (table.getTemporary() && !table.getGlobalTemporary()) { if (table.isTemporary() && !table.isGlobalTemporary()) {
session.removeLocalTempTableIndex(index); session.removeLocalTempTableIndex(index);
return; return;
} }
} else if (type == DbObject.CONSTRAINT) { } else if (type == DbObject.CONSTRAINT) {
Constraint constraint = (Constraint) obj; Constraint constraint = (Constraint) obj;
Table table = constraint.getTable(); Table table = constraint.getTable();
if (table.getTemporary() && !table.getGlobalTemporary()) { if (table.isTemporary() && !table.isGlobalTemporary()) {
session.removeLocalTempTableConstraint(constraint); session.removeLocalTempTableConstraint(constraint);
return; return;
} }
......
...@@ -196,7 +196,7 @@ public interface DbObject { ...@@ -196,7 +196,7 @@ public interface DbObject {
* *
* @return true if is temporary * @return true if is temporary
*/ */
boolean getTemporary(); boolean isTemporary();
/** /**
* Tell this object that it is temporary or not. * Tell this object that it is temporary or not.
......
...@@ -155,7 +155,7 @@ public abstract class DbObjectBase implements DbObject { ...@@ -155,7 +155,7 @@ public abstract class DbObjectBase implements DbObject {
setModified(); setModified();
} }
public boolean getTemporary() { public boolean isTemporary() {
return temporary; return temporary;
} }
......
...@@ -83,7 +83,7 @@ public class Engine { ...@@ -83,7 +83,7 @@ public class Engine {
} }
} }
} }
if (opened && (user == null || !user.getAdmin())) { if (opened && (user == null || !user.isAdmin())) {
// reset - because the user is not an admin, and has no // reset - because the user is not an admin, and has no
// right to listen to exceptions // right to listen to exceptions
database.setEventListener(null); database.setEventListener(null);
......
...@@ -1008,7 +1008,7 @@ public class Session extends SessionWithState { ...@@ -1008,7 +1008,7 @@ public class Session extends SessionWithState {
this.undoLogEnabled = b; this.undoLogEnabled = b;
} }
public boolean getUndoLogEnabled() { public boolean isUndoLogEnabled() {
return undoLogEnabled; return undoLogEnabled;
} }
...@@ -1053,7 +1053,7 @@ public class Session extends SessionWithState { ...@@ -1053,7 +1053,7 @@ public class Session extends SessionWithState {
/** /**
* Remember the result set and close it as soon as the transaction is * Remember the result set and close it as soon as the transaction is
* committed (if it needs to be closed). This is done to delete temporary * committed (if it needs to be closed). This is done to delete temporary
* files as soon as possible. * files as soon as possible, and free object ids of temporary tables.
* *
* @param result the temporary result set * @param result the temporary result set
*/ */
......
...@@ -41,7 +41,7 @@ public class User extends RightOwner { ...@@ -41,7 +41,7 @@ public class User extends RightOwner {
this.admin = admin; this.admin = admin;
} }
public boolean getAdmin() { public boolean isAdmin() {
return admin; return admin;
} }
...@@ -117,7 +117,7 @@ public class User extends RightOwner { ...@@ -117,7 +117,7 @@ public class User extends RightOwner {
return; return;
} }
if (!isRightGrantedRecursive(table, rightMask)) { if (!isRightGrantedRecursive(table, rightMask)) {
if (table.getTemporary() && !table.getGlobalTemporary()) { if (table.isTemporary() && !table.isGlobalTemporary()) {
// the owner has all rights on local temporary tables // the owner has all rights on local temporary tables
return; return;
} }
......
...@@ -114,7 +114,7 @@ public class ConditionIn extends Condition { ...@@ -114,7 +114,7 @@ public class ConditionIn extends Condition {
if (areAllValues(independent)) { if (areAllValues(independent)) {
if (left instanceof ExpressionColumn) { if (left instanceof ExpressionColumn) {
Column column = ((ExpressionColumn) left).getColumn(); Column column = ((ExpressionColumn) left).getColumn();
boolean nullable = column.getNullable(); boolean nullable = column.isNullable();
CompareMode mode = session.getDatabase().getCompareMode(); CompareMode mode = session.getDatabase().getCompareMode();
for (int i = 0; i < values.size(); i++) { for (int i = 0; i < values.size(); i++) {
Expression e = values.get(i); Expression e = values.get(i);
......
...@@ -229,7 +229,7 @@ public class ExpressionColumn extends Expression { ...@@ -229,7 +229,7 @@ public class ExpressionColumn extends Expression {
} }
public int getNullable() { public int getNullable() {
return column.getNullable() ? Column.NULLABLE : Column.NOT_NULLABLE; return column.isNullable() ? Column.NULLABLE : Column.NOT_NULLABLE;
} }
public boolean isEverything(ExpressionVisitor visitor) { public boolean isEverything(ExpressionVisitor visitor) {
......
...@@ -204,7 +204,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -204,7 +204,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
int index = column.getColumnId(); int index = column.getColumnId();
int mask = masks[index]; int mask = masks[index];
if ((mask & IndexCondition.EQUALITY) == IndexCondition.EQUALITY) { if ((mask & IndexCondition.EQUALITY) == IndexCondition.EQUALITY) {
if (i == columns.length - 1 && getIndexType().getUnique()) { if (i == columns.length - 1 && getIndexType().isUnique()) {
cost = getLookupCost(rowCount) + 1; cost = getLookupCost(rowCount) + 1;
break; break;
} }
...@@ -319,7 +319,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -319,7 +319,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
public String getCreateSQLForCopy(Table table, String quotedName) { public String getCreateSQLForCopy(Table table, String quotedName) {
StringBuilder buff = new StringBuilder("CREATE "); StringBuilder buff = new StringBuilder("CREATE ");
buff.append(indexType.getSQL()); buff.append(indexType.getSQL());
if (!indexType.getPrimaryKey()) { if (!indexType.isPrimaryKey()) {
buff.append(' ').append(quotedName); buff.append(' ').append(quotedName);
} }
buff.append(" ON ").append(table.getSQL()); buff.append(" ON ").append(table.getSQL());
......
...@@ -60,7 +60,7 @@ public class BtreeLeaf extends BtreePage { ...@@ -60,7 +60,7 @@ public class BtreeLeaf extends BtreePage {
SearchRow row = pageData.get(i); SearchRow row = pageData.get(i);
int comp = index.compareRows(row, newRow); int comp = index.compareRows(row, newRow);
if (comp == 0) { if (comp == 0) {
if (index.indexType.getUnique()) { if (index.indexType.isUnique()) {
if (!index.containsNullAndAllowMultipleNull(newRow)) { if (!index.containsNullAndAllowMultipleNull(newRow)) {
throw index.getDuplicateKeyException(); throw index.getDuplicateKeyException();
} }
......
...@@ -78,7 +78,7 @@ public class BtreeNode extends BtreePage { ...@@ -78,7 +78,7 @@ public class BtreeNode extends BtreePage {
SearchRow row = getData(i); SearchRow row = getData(i);
int comp = index.compareRows(row, newRow); int comp = index.compareRows(row, newRow);
if (comp == 0) { if (comp == 0) {
if (index.indexType.getUnique()) { if (index.indexType.isUnique()) {
if (!index.containsNullAndAllowMultipleNull(newRow)) { if (!index.containsNullAndAllowMultipleNull(newRow)) {
throw index.getDuplicateKeyException(); throw index.getDuplicateKeyException();
} }
...@@ -187,7 +187,7 @@ public class BtreeNode extends BtreePage { ...@@ -187,7 +187,7 @@ public class BtreeNode extends BtreePage {
IntArray children = new IntArray(); IntArray children = new IntArray();
splitPoint++; splitPoint++;
int max = pageData.size(); int max = pageData.size();
if (SysProperties.CHECK && index.getDatabase().getLogIndexChanges() && !getDeleted()) { if (SysProperties.CHECK && index.getDatabase().getLogIndexChanges() && !isDeleted()) {
// page must have been deleted already before calling // page must have been deleted already before calling
// getSplitPoint() // getSplitPoint()
Message.throwInternalError(); Message.throwInternalError();
......
...@@ -93,7 +93,7 @@ public class IndexType { ...@@ -93,7 +93,7 @@ public class IndexType {
* *
* @return true if it is a hash index * @return true if it is a hash index
*/ */
public boolean getHash() { public boolean isHash() {
return hash; return hash;
} }
...@@ -102,7 +102,7 @@ public class IndexType { ...@@ -102,7 +102,7 @@ public class IndexType {
* *
* @return true if it is persistent * @return true if it is persistent
*/ */
public boolean getPersistent() { public boolean isPersistent() {
return persistent; return persistent;
} }
...@@ -111,7 +111,7 @@ public class IndexType { ...@@ -111,7 +111,7 @@ public class IndexType {
* *
* @return true if it references a primary key constraint * @return true if it references a primary key constraint
*/ */
public boolean getPrimaryKey() { public boolean isPrimaryKey() {
return primaryKey; return primaryKey;
} }
...@@ -120,7 +120,7 @@ public class IndexType { ...@@ -120,7 +120,7 @@ public class IndexType {
* *
* @return true if it is * @return true if it is
*/ */
public boolean getUnique() { public boolean isUnique() {
return unique; return unique;
} }
...@@ -153,7 +153,7 @@ public class IndexType { ...@@ -153,7 +153,7 @@ public class IndexType {
* *
* @return true if it is * @return true if it is
*/ */
public boolean getScan() { public boolean isScan() {
return scan; return scan;
} }
......
...@@ -125,7 +125,7 @@ public class MultiVersionCursor implements Cursor { ...@@ -125,7 +125,7 @@ public class MultiVersionCursor implements Cursor {
} }
int sessionId = deltaRow.getSessionId(); int sessionId = deltaRow.getSessionId();
boolean isThisSession = sessionId == session.getId(); boolean isThisSession = sessionId == session.getId();
boolean isDeleted = deltaRow.getDeleted(); boolean isDeleted = deltaRow.isDeleted();
if (isThisSession && isDeleted) { if (isThisSession && isDeleted) {
needNewDelta = true; needNewDelta = true;
continue; continue;
......
...@@ -289,8 +289,8 @@ public class MultiVersionIndex implements Index { ...@@ -289,8 +289,8 @@ public class MultiVersionIndex implements Index {
return base.getName(); return base.getName();
} }
public boolean getTemporary() { public boolean isTemporary() {
return base.getTemporary(); return base.isTemporary();
} }
public void rename(String newName) throws SQLException { public void rename(String newName) throws SQLException {
......
...@@ -55,7 +55,7 @@ public class ScanCursor implements Cursor { ...@@ -55,7 +55,7 @@ public class ScanCursor implements Cursor {
continue; continue;
} }
row = delta.next(); row = delta.next();
if (!row.getDeleted() || row.getSessionId() == session.getId()) { if (!row.isDeleted() || row.getSessionId() == session.getId()) {
continue; continue;
} }
} else { } else {
......
...@@ -50,7 +50,7 @@ public class ScanIndex extends BaseIndex implements RowIndex { ...@@ -50,7 +50,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
sessionRowCount = New.hashMap(); sessionRowCount = New.hashMap();
} }
tableData = table; tableData = table;
if (!database.isPersistent() || id < 0 || !indexType.getPersistent()) { if (!database.isPersistent() || id < 0 || !indexType.isPersistent()) {
return; return;
} }
this.storage = database.getStorage(table, id, true); this.storage = database.getStorage(table, id, true);
......
...@@ -53,7 +53,7 @@ public class TreeIndex extends BaseIndex { ...@@ -53,7 +53,7 @@ public class TreeIndex extends BaseIndex {
Row r = n.row; Row r = n.row;
int compare = compareRows(row, r); int compare = compareRows(row, r);
if (compare == 0) { if (compare == 0) {
if (indexType.getUnique()) { if (indexType.isUnique()) {
if (!containsNullAndAllowMultipleNull(row)) { if (!containsNullAndAllowMultipleNull(row)) {
throw getDuplicateKeyException(); throw getDuplicateKeyException();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论