Thanks Hiram
I'm using bellow code to open (or create it, if necessary) a file. But
I noticed the file is recreated on every restart.
Thereafter, I lose my data. An important details is: eventually I'm
not able to call TxPageFile.close() (when the user can kill the java
process) .
Do you have any suggestion ?
Regards,
Rodolfo
final File db = new File(filePath);
final boolean dbAlreadyExists = db.exists();
log.info(filePath + (dbAlreadyExists ? " ja existe." : " nao existe.
Criando novo arquivo..."));
// Opening a transactional page file.
this.factory = new TxPageFileFactory();
if (!dbAlreadyExists) {
this.factory.setMappingSegementSize(8*1024*1024) ;
}
this.factory.setFile(new File(filePath));
this.factory.open();
this.pageFile = factory.getTxPageFile();
this.indexFactory = new BTreeIndexFactory<String, T>();
Transaction tx = pageFile.tx();
if (!dbAlreadyExists) {
this.root = indexFactory.create(tx);
} else {
this.root = indexFactory.open(tx);
}
tx.commit();
pageFile.flush() ;