use of org.exist.util.FixedByteArray in project exist by eXist-db.
the class BFileRecoverTest method add.
@Test
public void add() throws EXistException, IOException, BTreeException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager mgr = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
broker.flush();
broker.sync(Sync.MAJOR);
final BFile collectionsDb = (BFile) ((NativeBroker) broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
BrokerPool.FORCE_CORRUPTION = true;
try (final Txn txn = mgr.beginTransaction()) {
for (int i = 1; i < 1001; i++) {
String value = "test" + i;
byte[] data = value.getBytes(UTF_8);
collectionsDb.put(txn, new Value(data), new FixedByteArray(data, 0, data.length), true);
}
byte[] replacement = "new value".getBytes(UTF_8);
for (int i = 1; i < 101; i++) {
String value = "test" + i;
byte[] data = value.getBytes(UTF_8);
collectionsDb.put(txn, new Value(data), new FixedByteArray(replacement, 0, replacement.length), true);
}
mgr.commit(txn);
}
Writer writer = new StringWriter();
collectionsDb.dump(writer);
}
}
use of org.exist.util.FixedByteArray in project exist by eXist-db.
the class StoreValueLoggable method read.
@Override
public void read(ByteBuffer in) {
super.read(in);
page = in.getInt();
tid = in.getShort();
final int len = in.getShort();
final byte[] data = new byte[len];
in.get(data);
value = new FixedByteArray(data, 0, len);
}
use of org.exist.util.FixedByteArray in project exist by eXist-db.
the class OverflowAppendLoggable method read.
@Override
public void read(ByteBuffer in) {
super.read(in);
pageNum = in.getInt();
chunkSize = in.getInt();
final byte[] b = new byte[chunkSize];
in.get(b);
data = new FixedByteArray(b);
}
use of org.exist.util.FixedByteArray in project exist by eXist-db.
the class BFileOverflowTest method add.
@Test
public void add() throws EXistException, IOException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager mgr = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
broker.flush();
broker.sync(Sync.MAJOR);
final BFile collectionsDb = (BFile) ((NativeBroker) broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
BrokerPool.FORCE_CORRUPTION = true;
final Value key = new Value("test".getBytes());
try (final Txn txn = mgr.beginTransaction()) {
byte[] data = "_HELLO_YOU_".getBytes();
collectionsDb.put(txn, key, new FixedByteArray(data, 0, data.length), true);
for (int i = 1; i < 101; i++) {
String value = "_HELLO_" + i;
data = value.getBytes(UTF_8);
collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
}
mgr.commit(txn);
}
// start a new transaction that will not be committed and thus undone
final Txn txn = mgr.beginTransaction();
for (int i = 1001; i < 2001; i++) {
String value = "_HELLO_" + i;
final byte[] data = value.getBytes(UTF_8);
collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
}
collectionsDb.remove(txn, key);
pool.getJournalManager().get().flush(true, false);
}
}
Aggregations