| 1 |
/* |
| 2 |
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (https://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.index; |
| 7 |
|
| 8 |
import org.h2.command.query.AllColumnsForPlan; |
| 9 |
import org.h2.engine.SessionLocal; |
| 10 |
import org.h2.result.Row; |
| 11 |
import org.h2.result.SearchRow; |
| 12 |
import org.h2.result.SortOrder; |
| 13 |
import org.h2.table.DualTable; |
| 14 |
import org.h2.table.IndexColumn; |
| 15 |
import org.h2.table.TableFilter; |
| 16 |
import org.h2.value.Value; |
| 17 |
|
| 18 |
/** |
| 19 |
* An index for the DUAL table. |
| 20 |
*/ |
| 21 |
public class DualIndex extends VirtualTableIndex { |
| 22 |
|
| 23 |
public DualIndex(DualTable table) { |
| 24 |
super(table, "DUAL_INDEX", new IndexColumn[0]); |
| 25 |
} |
| 26 |
|
| 27 |
@Override |
| 28 |
public Cursor find(SessionLocal session, SearchRow first, SearchRow last) { |
| 29 |
return new DualCursor(); |
| 30 |
} |
| 31 |
|
| 32 |
@Override |
| 33 |
public double getCost(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, |
| 34 |
AllColumnsForPlan allColumnsSet) { |
| 35 |
return 1d; |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public String getCreateSQL() { |
| 40 |
return null; |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public boolean canGetFirstOrLast() { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public Cursor findFirstOrLast(SessionLocal session, boolean first) { |
| 50 |
return new SingleRowCursor(Row.get(Value.EMPTY_VALUES, 1)); |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public String getPlanSQL() { |
| 55 |
return "dual index"; |
| 56 |
} |
| 57 |
|
| 58 |
} |