use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class TextTable method getHeader.
public String getHeader() {
PersistentStore store = database.persistentStoreCollection.getStore(this);
TextCache cache = (TextCache) store.getCache();
String header = cache == null ? null : cache.getHeader();
return header == null ? null : StringConverter.toQuotedString(header, '\"', true);
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class TransactionManager method mergeRolledBackTransaction.
/**
* merge a given list of transaction rollback action with given timestamp
*/
void mergeRolledBackTransaction(Object[] list, int start, int limit) {
for (int i = start; i < limit; i++) {
RowAction rowact = (RowAction) list[i];
if (rowact == null || rowact.type == RowActionBase.ACTION_NONE || rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
continue;
}
Row row = rowact.memoryRow;
if (row == null) {
PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
row = (Row) store.get(rowact.getPos(), false);
}
if (row == null) {
continue;
}
synchronized (row) {
rowact.mergeRollback(row);
}
}
// } catch (Throwable t) {
// System.out.println("throw in merge");
// t.printStackTrace();
// }
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class Table method deleteNoCheckFromLog.
/**
* For log statements. Delete a single row.
*/
public void deleteNoCheckFromLog(Session session, Object[] data) {
Row row = null;
PersistentStore store = session.sessionData.getRowStore(this);
if (hasPrimaryKey()) {
RowIterator it = getPrimaryIndex().findFirstRow(session, store, data, primaryKeyColsSequence);
row = it.getNextRow();
} else if (bestIndex == null) {
RowIterator it = rowIterator(session);
while (true) {
row = it.getNextRow();
if (row == null) {
break;
}
if (IndexAVL.compareRows(row.getData(), data, defaultColumnMap, colTypes) == 0) {
break;
}
}
} else {
RowIterator it = bestIndex.findFirstRow(session, store, data);
while (true) {
row = it.getNextRow();
if (row == null) {
break;
}
Object[] rowdata = row.getData();
// reached end of range
if (bestIndex.compareRowNonUnique(data, bestIndex.getColumns(), rowdata) != 0) {
row = null;
break;
}
if (IndexAVL.compareRows(rowdata, data, defaultColumnMap, colTypes) == 0) {
break;
}
}
}
if (row == null) {
return;
}
deleteNoCheck(session, row);
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class Table method getIndexRootsArray.
/**
* Return the list of file pointers to root nodes for this table's
* indexes.
*/
public final int[] getIndexRootsArray() {
PersistentStore store = database.persistentStoreCollection.getStore(this);
int[] roots = new int[getIndexCount()];
for (int i = 0; i < getIndexCount(); i++) {
CachedObject accessor = store.getAccessor(indexList[i]);
roots[i] = accessor == null ? -1 : accessor.getPos();
}
return roots;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class TextTable method connect.
/**
* connects to the data source
*/
private void connect(Session session, boolean withReadOnlyData) {
// Open new cache:
if ((dataSource.length() == 0) || isConnected) {
// nothing to do
return;
}
PersistentStore store = database.persistentStoreCollection.getStore(this);
this.store = store;
DataFileCache cache = null;
try {
cache = (TextCache) database.logger.openTextCache(this, dataSource, withReadOnlyData, isReversed);
store.setCache(cache);
// read and insert all the rows from the source file
Row row = null;
int nextpos = 0;
if (((TextCache) cache).ignoreFirst) {
nextpos += ((TextCache) cache).readHeaderLine();
}
while (true) {
row = (Row) store.get(nextpos, false);
if (row == null) {
break;
}
Object[] data = row.getData();
nextpos = row.getPos() + row.getStorageSize();
((RowAVLDiskData) row).setNewNodes();
systemUpdateIdentityValue(data);
enforceRowConstraints(session, data);
for (int i = 0; i < indexList.length; i++) {
indexList[i].insert(null, store, row);
}
}
} catch (Exception e) {
int linenumber = cache == null ? 0 : ((TextCache) cache).getLineNumber();
clearAllData(session);
if (cache != null) {
database.logger.closeTextCache(this);
store.release();
}
// source and cache or have an empty source and null cache.
throw Error.error(ErrorCode.TEXT_FILE, 0, new Object[] { new Integer(linenumber), e.getMessage() });
}
isConnected = true;
isReadOnly = withReadOnlyData;
}
Aggregations