| 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.engine.SessionLocal; |
| 9 |
import org.h2.message.DbException; |
| 10 |
import org.h2.result.Row; |
| 11 |
import org.h2.table.IndexColumn; |
| 12 |
import org.h2.table.VirtualTable; |
| 13 |
|
| 14 |
/** |
| 15 |
* An base class for indexes of virtual tables. |
| 16 |
*/ |
| 17 |
public abstract class VirtualTableIndex extends Index { |
| 18 |
|
| 19 |
protected VirtualTableIndex(VirtualTable table, String name, IndexColumn[] columns) { |
| 20 |
super(table, 0, name, columns, 0, IndexType.createNonUnique(true)); |
| 21 |
} |
| 22 |
|
| 23 |
@Override |
| 24 |
public void close(SessionLocal session) { |
| 25 |
// nothing to do |
| 26 |
} |
| 27 |
|
| 28 |
@Override |
| 29 |
public void add(SessionLocal session, Row row) { |
| 30 |
throw DbException.getUnsupportedException("Virtual table"); |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
public void remove(SessionLocal session, Row row) { |
| 35 |
throw DbException.getUnsupportedException("Virtual table"); |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public void remove(SessionLocal session) { |
| 40 |
throw DbException.getUnsupportedException("Virtual table"); |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public void truncate(SessionLocal session) { |
| 45 |
throw DbException.getUnsupportedException("Virtual table"); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public boolean needRebuild() { |
| 50 |
return false; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public void checkRename() { |
| 55 |
throw DbException.getUnsupportedException("Virtual table"); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public long getRowCount(SessionLocal session) { |
| 60 |
return table.getRowCount(session); |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public long getRowCountApproximation(SessionLocal session) { |
| 65 |
return table.getRowCountApproximation(session); |
| 66 |
} |
| 67 |
|
| 68 |
} |