use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class MVPrimaryIndex method find.
@Override
public Cursor find(Session session, SearchRow first, SearchRow last) {
ValueLong min, max;
if (first == null) {
min = ValueLong.MIN;
} else if (mainIndexColumn < 0) {
min = ValueLong.get(first.getKey());
} else {
ValueLong v = (ValueLong) first.getValue(mainIndexColumn);
if (v == null) {
min = ValueLong.get(first.getKey());
} else {
min = v;
}
}
if (last == null) {
max = ValueLong.MAX;
} else if (mainIndexColumn < 0) {
max = ValueLong.get(last.getKey());
} else {
ValueLong v = (ValueLong) last.getValue(mainIndexColumn);
if (v == null) {
max = ValueLong.get(last.getKey());
} else {
max = v;
}
}
TransactionMap<Value, Value> map = getMap(session);
return new MVStoreCursor(session, map.entryIterator(min, max));
}
use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class MVPrimaryIndex method remove.
@Override
public void remove(Session session) {
TransactionMap<Value, Value> map = getMap(session);
if (!map.isClosed()) {
Transaction t = session.getTransaction();
t.removeMap(map);
}
}
use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class MVPrimaryIndex method getRow.
@Override
public Row getRow(Session session, long key) {
TransactionMap<Value, Value> map = getMap(session);
Value v = map.get(ValueLong.get(key));
if (v == null) {
throw DbException.get(ErrorCode.ROW_NOT_FOUND_IN_PRIMARY_INDEX, getSQL() + ": " + key);
}
ValueArray array = (ValueArray) v;
Row row = session.createRow(array.getList(), 0);
row.setKey(key);
return row;
}
use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class MVSpatialIndex method add.
@Override
public void add(Session session, Row row) {
TransactionMap<SpatialKey, Value> map = getMap(session);
SpatialKey key = getKey(row);
if (key.isNull()) {
return;
}
if (indexType.isUnique()) {
// this will detect committed entries only
RTreeCursor cursor = spatialMap.findContainedKeys(key);
Iterator<SpatialKey> it = map.wrapIterator(cursor, false);
while (it.hasNext()) {
SpatialKey k = it.next();
if (k.equalsIgnoringId(key)) {
throw getDuplicateKeyException(key.toString());
}
}
}
try {
map.put(key, ValueLong.get(0));
} catch (IllegalStateException e) {
throw mvTable.convertException(e);
}
if (indexType.isUnique()) {
// check if there is another (uncommitted) entry
RTreeCursor cursor = spatialMap.findContainedKeys(key);
Iterator<SpatialKey> it = map.wrapIterator(cursor, true);
while (it.hasNext()) {
SpatialKey k = it.next();
if (k.equalsIgnoringId(key)) {
if (map.isSameTransaction(k)) {
continue;
}
map.remove(key);
if (map.get(k) != null) {
// committed
throw getDuplicateKeyException(k.toString());
}
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, table.getName());
}
}
}
}
use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class MVSpatialIndex method remove.
@Override
public void remove(Session session) {
TransactionMap<SpatialKey, Value> map = getMap(session);
if (!map.isClosed()) {
Transaction t = session.getTransaction();
t.removeMap(map);
}
}
Aggregations