private E get_(long id) { E entity = newEntity(); get_(id, entity); return entity; }
private E get_(long id) { E entity = newEntity(); get_(id, entity); return entity; }
private E get_(long id) { E entity = newEntity(); get_(id, entity); return entity; }
private void doUpdate(long id, DatastoreTransaction tx, E entity) { E old = newEntity(), old2 = newEntity(), post = newEntity(); get_(id, old, old2); doTriggers(beforeUpdate, TriggerAction.BEFORE_UPDATE, id, old, entity); for (int i = 0; i < tmpIndices.length && tmpIndices[i] != null; i++) { tmpIndices[i] = null; } for (PropertyInfo pr : props) { Object val = pr.get(entity); setCell(tx, id, pr, val, tmpIndices); } doTriggers(afterUpdate, TriggerAction.AFTER_UPDATE, id, old, entity); get_(id, post); // old might be changed by triggers, so use old2 as protection doComplexIndices(tmpIndices, old2, post, id); }
@Override public void forEach(long[] ids, Visitor<E> visitor) { E entity = newEntity(); for (long id : ids) { get_(id, entity); if (visitor.visit(entity)) { update(entity); } } }
private void doUpdate(long id, DatastoreTransaction tx, E entity) { E old = newEntity(), old2 = newEntity(), post = newEntity(); get_(id, old, old2); doTriggers(beforeUpdate, TriggerAction.BEFORE_UPDATE, id, old, entity); for (int i = 0; i < tmpIndices.length && tmpIndices[i] != null; i++) { tmpIndices[i] = null; } for (PropertyInfo pr : props) { Object val = pr.get(entity); setCell(tx, id, pr, val, tmpIndices); } doTriggers(afterUpdate, TriggerAction.AFTER_UPDATE, id, old, entity); get_(id, post); // old might be changed by triggers, so use old2 as protection doComplexIndices(tmpIndices, old2, post, id); }
private void doUpdate(long id, DatastoreTransaction tx, E entity) { E old = newEntity(), old2 = newEntity(), post = newEntity(); get_(id, old, old2); doTriggers(beforeUpdate, TriggerAction.BEFORE_UPDATE, id, old, entity); for (int i = 0; i < tmpIndices.length && tmpIndices[i] != null; i++) { tmpIndices[i] = null; } for (PropertyInfo pr : props) { Object val = pr.get(entity); setCell(tx, id, pr, val, tmpIndices); } doTriggers(afterUpdate, TriggerAction.AFTER_UPDATE, id, old, entity); get_(id, post); // old might be changed by triggers, so use old2 as protection doComplexIndices(tmpIndices, old2, post, id); }
@Override public void forEach(long[] ids, Visitor<E> visitor) { E entity = newEntity(); for (long id : ids) { get_(id, entity); if (visitor.visit(entity)) { update(entity); } } }
@Override public long insert(Map<String, Object> properties) { try { // WRITE LOCK locker.globalWriteLock(); E entity = newEntity(); if (properties != null) { for (Entry<String, Object> entry : properties.entrySet()) { PropertyInfo prop = info.getProperties().get(entry.getKey()); prop.set(entity, entry.getValue()); } } return insertRow(entity); } finally { // WRITE UNLOCK locker.globalWriteUnlock(); } }
@Override public void forEach(long[] ids, Visitor<E> visitor) { E entity = newEntity(); for (long id : ids) { get_(id, entity); if (visitor.visit(entity)) { update(entity); } } }
@Override public long insert(Map<String, Object> properties) { try { // WRITE LOCK locker.globalWriteLock(); E entity = newEntity(); if (properties != null) { for (Entry<String, Object> entry : properties.entrySet()) { PropertyInfo prop = info.getProperties().get(entry.getKey()); prop.set(entity, entry.getValue()); } } return insertRow(entity); } finally { // WRITE UNLOCK locker.globalWriteUnlock(); } }
@Override public long insert(Map<String, Object> properties) { try { // WRITE LOCK locker.globalWriteLock(); E entity = newEntity(); if (properties != null) { for (Entry<String, Object> entry : properties.entrySet()) { PropertyInfo prop = info.getProperties().get(entry.getKey()); prop.set(entity, entry.getValue()); } } return insertRow(entity); } finally { // WRITE UNLOCK locker.globalWriteUnlock(); } }
public TableImpl(OhmDBImpl db, Class<E> clazz, DataStore store, IdColl ids, Transactor transactor, OhmDBStats stats, LockManager lockManager) { this.db = db; this.idColl = ids; this.transactor = transactor; this.stats = stats; this.locker = lockManager; this.info = introspector.describe(clazz); this.clazz = clazz; this.store = store; this.size = 0; this.rows = 0; this.props = info.getProps(); this.idtor = info.getIdtor(); this.constr = findConstructor(); this.queryHelper = newEntity(); init(); }
public TableImpl(OhmDBImpl db, Class<E> clazz, DataStore store, IdColl ids, Transactor transactor, OhmDBStats stats, LockManager lockManager) { this.db = db; this.idColl = ids; this.transactor = transactor; this.stats = stats; this.locker = lockManager; this.info = introspector.describe(clazz); this.clazz = clazz; this.store = store; this.size = 0; this.rows = 0; this.props = info.getProps(); this.idtor = info.getIdtor(); this.constr = findConstructor(); this.queryHelper = newEntity(); init(); }
public TableImpl(OhmDBImpl db, Class<E> clazz, DataStore store, IdColl ids, Transactor transactor, OhmDBStats stats, LockManager lockManager) { this.db = db; this.idColl = ids; this.transactor = transactor; this.stats = stats; this.locker = lockManager; this.info = introspector.describe(clazz); this.clazz = clazz; this.store = store; this.size = 0; this.rows = 0; this.props = info.getProps(); this.idtor = info.getIdtor(); this.constr = findConstructor(); this.queryHelper = newEntity(); init(); }
@Override public E get(long id) { try { // READ LOCK locker.globalReadLock(); checkId(id); insider.getting(clazz, id); E entity = newEntity(); doTriggers(beforeRead, TriggerAction.BEFORE_READ, id, null, entity); get_(id, entity); doTriggers(afterRead, TriggerAction.AFTER_READ, id, null, entity); insider.got(clazz, id, entity); return entity; } finally { // READ UNLOCK locker.globalReadUnlock(); } }
@Override public E get(long id) { try { // READ LOCK locker.globalReadLock(); checkId(id); insider.getting(clazz, id); E entity = newEntity(); doTriggers(beforeRead, TriggerAction.BEFORE_READ, id, null, entity); get_(id, entity); doTriggers(afterRead, TriggerAction.AFTER_READ, id, null, entity); insider.got(clazz, id, entity); return entity; } finally { // READ UNLOCK locker.globalReadUnlock(); } }
@SuppressWarnings("unchecked") private <T> IndexerImpl<E, T> complexIndex(Object[] columns, final Mapper<E, ?> mapper) { Index index = makeIndex(); ComplexIndex<E> complexIndex = new ComplexIndexImpl<E>((Mapper<E, Object>) mapper, index); for (Object col : columns) { String colName = jokerator.decode(col); prop(colName).addComplexIndex(complexIndex); } allComplexIndices = U.expand(allComplexIndices, complexIndex); E entity = newEntity(); for (long id : ids()) { get_(id, entity); complexIndex.add(entity, id); } return new IndexerImpl<E, T>(complexIndex, index); }
@SuppressWarnings("unchecked") private <T> IndexerImpl<E, T> complexIndex(Object[] columns, final Mapper<E, ?> mapper) { Index index = makeIndex(); ComplexIndex<E> complexIndex = new ComplexIndexImpl<E>((Mapper<E, Object>) mapper, index); for (Object col : columns) { String colName = jokerator.decode(col); prop(colName).addComplexIndex(complexIndex); } allComplexIndices = U.expand(allComplexIndices, complexIndex); E entity = newEntity(); for (long id : ids()) { get_(id, entity); complexIndex.add(entity, id); } return new IndexerImpl<E, T>(complexIndex, index); }
@SuppressWarnings("unchecked") private <T> IndexerImpl<E, T> complexIndex(Object[] columns, final Mapper<E, ?> mapper) { Index index = makeIndex(); ComplexIndex<E> complexIndex = new ComplexIndexImpl<E>((Mapper<E, Object>) mapper, index); for (Object col : columns) { String colName = jokerator.decode(col); prop(colName).addComplexIndex(complexIndex); } allComplexIndices = U.expand(allComplexIndices, complexIndex); E entity = newEntity(); for (long id : ids()) { get_(id, entity); complexIndex.add(entity, id); } return new IndexerImpl<E, T>(complexIndex, index); }