private void importRelations(long id) { int relN = (Integer) decode(); for (int i = 0; i < relN; i++) { String relName = (String) decode(); RelationInternals rel = (RelationInternals) relation(relName); int linksN = (Integer) decode(); for (int j = 0; j < linksN; j++) { long linkTo = (Long) decode(); rel.fill(id, linkTo); } } }
public synchronized byte[] exportRecord(long id) { SER_HELPER.clear(); exportColumns(id); exportRelations(id); SER_HELPER.flip(); byte[] bytes = new byte[SER_HELPER.limit()]; SER_HELPER.get(bytes); // System.out.println("EXPORTING BYTES " + bytes.length); return bytes; }
@Override public Object read(long id) { return exportRecord(id); }
private void importColumns(long id) { String fullName = (String) decode(); int colN = (Integer) decode(); Table<Object> table = table(fullName); TableInternals<?> table2 = (TableInternals<?>) table; for (int i = 0; i < colN; i++) { String colName = (String) decode(); Object colVal = decode(); table2.fill(id, colName, colVal); } }
public synchronized void importRecord(long id, byte[] bytes) { SER_HELPER.clear(); SER_HELPER.put(bytes); SER_HELPER.flip(); boolean importTableData = (Boolean) decode(); if (importTableData) { importColumns(id); } importRelations(id); }
@SuppressWarnings("unchecked") @Override public <T> T get(long id) { return (T) address(id).table.get(id); }
public RWRelation relation(String name) { return relation(null, name, null); }
public OhmDBImpl() { super(new DefaultLinkMatcher()); dbRef = new WeakReference<Db>(this); this.store = new NoDataStore(this); addShutdownHook(); }
@Override public void commit(Transaction transaction) { Check.arg(this.transaction == transaction, "Invalid transaction!"); db.commit(); TransactionInternals internals = (TransactionInternals) transaction; internals.getStoreTx().commit(); this.transaction = null; stats.commits++; lockManager.globalWriteUnlock(); }
public static Db newInstance(String filename) { Throwable err = null; for (int i = 0; i < 3; i++) { try { return filename != null ? new OhmDBImpl(filename) : new OhmDBImpl(); } catch (Exception e) { e.printStackTrace(); err = e; U.sleep(1000); } } throw Errors.rte("Cannot initialize the database!", err); }
private void deleteInTx(DatastoreTransaction tx, long id) { insider.deleting(clazz, id); E entity = get_(id); doTriggers(beforeDelete, TriggerAction.BEFORE_DELETE, id, entity, null); stats.deletes++; int row = row(id); // TODO check - changelog if not deleted rels? db.deleteRelsInTx(id, tx); // CHANGE #1 size--; // CHANGE #2 deletedCount++; // CHANGE #3 currentlyDeleted.add(row); // CHANGE #4 idColl.delete(id); // CHANGE #5 ids.remove(id); // CHANGE #6 changelog.add(TableChange.delete(id, row)); // CHANGELOG // TODO also delete old (renamed) columns? for (PropertyInfo prop : props) { deleteCell(tx, id, row, prop); } doTriggers(afterDelete, TriggerAction.AFTER_DELETE, id, entity, null); insider.deleted(clazz, id); }
public synchronized void importRecord(long id, byte[] bytes) { SER_HELPER.clear(); SER_HELPER.put(bytes); SER_HELPER.flip(); boolean importTableData = (Boolean) decode(); if (importTableData) { importColumns(id); } importRelations(id); }
private void importColumns(long id) { String fullName = (String) decode(); int colN = (Integer) decode(); Table<Object> table = table(fullName); TableInternals<?> table2 = (TableInternals<?>) table; for (int i = 0; i < colN; i++) { String colName = (String) decode(); Object colVal = decode(); table2.fill(id, colName, colVal); } }
@SuppressWarnings("unchecked") @Override public <T> T get(long id) { return (T) address(id).table.get(id); }
public RWRelation relation(String name) { return relation(null, name, null); }
public OhmDBImpl() { super(new DefaultLinkMatcher()); dbRef = new WeakReference<Db>(this); this.store = new NoDataStore(this); addShutdownHook(); }
@Override public void commit(Transaction transaction) { Check.arg(this.transaction == transaction, "Invalid transaction!"); db.commit(); TransactionInternals internals = (TransactionInternals) transaction; internals.getStoreTx().commit(); this.transaction = null; stats.commits++; lockManager.globalWriteUnlock(); }
public static Db newInstance(String filename) { Throwable err = null; for (int i = 0; i < 3; i++) { try { return filename != null ? new OhmDBImpl(filename) : new OhmDBImpl(); } catch (Exception e) { e.printStackTrace(); err = e; U.sleep(1000); } } throw Errors.rte("Cannot initialize the database!", err); }
private void deleteInTx(DatastoreTransaction tx, long id) { insider.deleting(clazz, id); E entity = get_(id); doTriggers(beforeDelete, TriggerAction.BEFORE_DELETE, id, entity, null); stats.deletes++; int row = row(id); // TODO check - changelog if not deleted rels? db.deleteRelsInTx(id, tx); // CHANGE #1 size--; // CHANGE #2 deletedCount++; // CHANGE #3 currentlyDeleted.add(row); // CHANGE #4 idColl.delete(id); // CHANGE #5 ids.remove(id); // CHANGE #6 changelog.add(TableChange.delete(id, row)); // CHANGELOG // TODO also delete old (renamed) columns? for (PropertyInfo prop : props) { deleteCell(tx, id, row, prop); } doTriggers(afterDelete, TriggerAction.AFTER_DELETE, id, entity, null); insider.deleted(clazz, id); }
public synchronized void importRecord(long id, byte[] bytes) { SER_HELPER.clear(); SER_HELPER.put(bytes); SER_HELPER.flip(); boolean importTableData = (Boolean) decode(); if (importTableData) { importColumns(id); } importRelations(id); }