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

code review comments addressed

上级 f0084cac
......@@ -908,8 +908,7 @@ public class Database implements DataHandler {
int id = obj.getId();
if (id > 0 && !starting && !obj.isTemporary()) {
Row r = meta.getTemplateRow();
MetaRecord rec = new MetaRecord(obj);
rec.setRecord(r);
MetaRecord.populateRowFromDBObject(obj, r);
objectIds.set(id);
if (SysProperties.CHECK) {
verifyMetaLocked(session);
......
......@@ -37,19 +37,6 @@ public class MetaRecord implements Comparable<MetaRecord> {
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.
*
......
......@@ -254,11 +254,25 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override
public void update(Session session, Row oldRow, Row newRow) {
if (compareRows(oldRow, newRow ) != 0) {
if (!rowsAreEqual(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
public Cursor find(Session session, SearchRow first, SearchRow last) {
return find(session, first, false, last);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论