database.persistentStoreCollection.getStore(this);
this.store = store;
TextCache cache = null;
TextFileReader reader = null;
try {
cache = (TextCache) database.logger.openTextFilePersistence(this,
dataSource, withReadOnlyData, isReversed);
store.setCache(cache);
reader = cache.getTextFileReader();
// read and insert all the rows from the source file
Row row = null;
long nextpos = 0;
if (cache.isIgnoreFirstLine()) {
nextpos += reader.readHeaderLine();
cache.setHeaderInitialise(reader.getHeaderLine());
}
while (true) {
RowInputInterface rowIn = reader.readObject(nextpos);
if (rowIn == null) {
break;
}
row = (Row) store.get(rowIn);
if (row == null) {
break;
}
Object[] data = row.getData();
nextpos = (int) row.getPos() + row.getStorageSize();
systemUpdateIdentityValue(data);
enforceRowConstraints(session, data);
store.indexRow(session, row);
}
} catch (Throwable t) {
int linenumber = reader == null ? 0
: reader.getLineNumber();
clearAllData(session);
if (cache != null) {
database.logger.closeTextCache(this);