提交 0b2d3a56 authored 作者: Andrei Tokar's avatar Andrei Tokar

code review comments addressed

上级 f0084cac
...@@ -908,8 +908,7 @@ public class Database implements DataHandler { ...@@ -908,8 +908,7 @@ public class Database implements DataHandler {
int id = obj.getId(); int id = obj.getId();
if (id > 0 && !starting && !obj.isTemporary()) { if (id > 0 && !starting && !obj.isTemporary()) {
Row r = meta.getTemplateRow(); Row r = meta.getTemplateRow();
MetaRecord rec = new MetaRecord(obj); MetaRecord.populateRowFromDBObject(obj, r);
rec.setRecord(r);
objectIds.set(id); objectIds.set(id);
if (SysProperties.CHECK) { if (SysProperties.CHECK) {
verifyMetaLocked(session); verifyMetaLocked(session);
......
...@@ -37,19 +37,6 @@ public class MetaRecord implements Comparable<MetaRecord> { ...@@ -37,19 +37,6 @@ public class MetaRecord implements Comparable<MetaRecord> {
sql = r.getValue(3).getString(); sql = r.getValue(3).getString();
} }
MetaRecord(DbObject obj) {
id = obj.getId();
objectType = obj.getType();
sql = obj.getCreateSQL();
}
void setRecord(SearchRow r) {
r.setValue(0, ValueInt.get(id));
r.setValue(1, ValueInt.get(0));
r.setValue(2, ValueInt.get(objectType));
r.setValue(3, ValueString.get(sql));
}
/** /**
* Execute the meta data statement. * Execute the meta data statement.
* *
......
...@@ -254,11 +254,25 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -254,11 +254,25 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override @Override
public void update(Session session, Row oldRow, Row newRow) { public void update(Session session, Row oldRow, Row newRow) {
if (compareRows(oldRow, newRow ) != 0) { if (!rowsAreEqual(oldRow, newRow)) {
super.update(session, oldRow, newRow); super.update(session, oldRow, newRow);
} }
} }
private boolean rowsAreEqual(SearchRow rowOne, SearchRow rowTwo) {
if (rowOne == rowTwo) {
return true;
}
for (int index : columnIds) {
Value v1 = rowOne.getValue(index);
Value v2 = rowTwo.getValue(index);
if (v1 == null ? v2 != null : !v1.equals(v2)) {
break;
}
}
return rowOne.getKey() == rowTwo.getKey();
}
@Override @Override
public Cursor find(Session session, SearchRow first, SearchRow last) { public Cursor find(Session session, SearchRow first, SearchRow last) {
return find(session, first, false, last); return find(session, first, false, last);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论