提交 f4021327 authored 作者: noelgrandin's avatar noelgrandin

make NonUniqueHashIndex directly subclass BaseIndex. There is no point in…

make NonUniqueHashIndex directly subclass BaseIndex. There is no point in sub-classing HashIndex if it is going to override all of the logic anyhow.
上级 c3e7abca
......@@ -25,7 +25,7 @@ public class HashIndex extends BaseIndex {
/**
* The index of the indexed column.
*/
protected final int indexColumn;
private final int indexColumn;
private final RegularTable tableData;
private ValueHashMap<Long> rows;
......
......@@ -11,6 +11,8 @@ import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.Row;
import org.h2.result.SearchRow;
import org.h2.result.SortOrder;
import org.h2.table.Column;
import org.h2.table.IndexColumn;
import org.h2.table.RegularTable;
import org.h2.util.New;
......@@ -22,14 +24,19 @@ import org.h2.value.Value;
*
* @author Sergi Vladykin
*/
public class NonUniqueHashIndex extends HashIndex {
public class NonUniqueHashIndex extends BaseIndex {
/**
* The index of the indexed column.
*/
private final int indexColumn;
private ValueHashMap<ArrayList<Long>> rows;
private final RegularTable tableData;
private long rowCount;
public NonUniqueHashIndex(RegularTable table, int id, String indexName, IndexColumn[] columns, IndexType indexType) {
super(table, id, indexName, columns, indexType);
initBaseIndex(table, id, indexName, columns, indexType);
this.indexColumn = columns[0].column.getColumnId();
this.tableData = table;
reset();
}
......@@ -98,4 +105,57 @@ public class NonUniqueHashIndex extends HashIndex {
return rowCount;
}
@Override
public long getDiskSpaceUsed() {
return 0;
}
@Override
public void close(Session session) {
// nothing to do
}
@Override
public void remove(Session session) {
// nothing to do
}
@Override
public double getCost(Session session, int[] masks, SortOrder sortOrder) {
for (Column column : columns) {
int index = column.getColumnId();
int mask = masks[index];
if ((mask & IndexCondition.EQUALITY) != IndexCondition.EQUALITY) {
return Long.MAX_VALUE;
}
}
return 2;
}
@Override
public void checkRename() {
// ok
}
@Override
public boolean needRebuild() {
return true;
}
@Override
public boolean canGetFirstOrLast() {
return false;
}
@Override
public Cursor findFirstOrLast(Session session, boolean first) {
throw DbException.getUnsupportedException("HASH");
}
@Override
public boolean canScan() {
return false;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论