private boolean exists(SqlJetDb db, long wcId, String localRelPath) throws SqlJetException { ISqlJetTable table = db.getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor cursor = table.lookup(null, wcId, localRelPath); try { return !cursor.eof(); } finally { cursor.close(); } }
private boolean exists(SqlJetDb db, long wcId, String localRelPath) throws SqlJetException { ISqlJetTable table = db.getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor cursor = table.lookup(null, wcId, localRelPath); try { return !cursor.eof(); } finally { cursor.close(); } } }
@Override public void execute(SqlJetDb db) throws SqlJetException { ISqlJetTable table = db.getTable(INVOKER_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), transactionId, phase, databaseId); try { if (!cursor.eof()) { cursor.updateByFieldNames(Collections.<String, Object>singletonMap(RESULT_COLUMN, result)); } } finally { close(cursor); } } };
public void beforeInsert(SqlJetConflictAction conflictAction, ISqlJetTable table, Map<String, Object> newValues) throws SqlJetException { if (conflictAction == SqlJetConflictAction.REPLACE) { Object o1 = newValues.get(NODES__Fields.wc_id.toString()); Object o2 = newValues.get(NODES__Fields.local_relpath.toString()); Object o3 = newValues.get(NODES__Fields.op_depth.toString()); ISqlJetCursor cursor = table.lookup(null, new Object[] {o1, o2, o3}); try { if (!cursor.eof()) { changeRefCount(cursor.getString(NODES__Fields.checksum.toString()), -1); } } finally { cursor.close(); } } String newChecksumValue = (String) newValues.get(NODES__Fields.checksum.toString()); changeRefCount(newChecksumValue, 1); }
@Override public Set<String> execute(SqlJetDb database) throws SqlJetException { Set<String> set = new TreeSet<>(); ISqlJetTable table = database.getTable(STATE_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName()); try { if (!cursor.eof()) { do { set.add(cursor.getString(DATABASE_COLUMN)); } while (cursor.next()); } return set; } finally { close(cursor); } } };
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { try { if (error == null && !getTriggerValues().isEmpty()) { Map<String, Object> values = new HashMap<String, Object>(); ISqlJetTable pristineTable = db.getTable(SVNWCDbSchema.PRISTINE.toString()); for (String checksum : getTriggerValues().keySet()) { long delta = getTriggerValues().get(checksum); if (delta == 0) { continue; } ISqlJetCursor cursor = pristineTable.lookup(null, checksum); if (cursor != null && !cursor.eof()) { long refcount = cursor.getInteger(SVNWCDbSchema.PRISTINE__Fields.refcount.toString()); refcount += delta; if (refcount < 0) { refcount = 0; } values.put(SVNWCDbSchema.PRISTINE__Fields.refcount.toString(), refcount); cursor.updateByFieldNames(values); } cursor.close(); } } } finally { checksumTriggerValues = null; } }
@Override public void execute(SqlJetDb db) throws SqlJetException { ISqlJetTable table = db.getTable(STATE_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), event.getSource()); try { if (!cursor.eof()) { cursor.delete(); } } finally { close(cursor); } } };
private String getNodeReposRelpath(long wcId, String path) throws SVNException { ISqlJetCursor cursor = null; try { cursor = getTable().lookup(null, wcId, path); if (!cursor.eof()) { return cursor.getString(NODES__Fields.repos_path.toString()); } } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } finally { if (cursor != null) { try { cursor.close(); } catch (SqlJetException e) { } } } return null; }
cursor = pTable.lookup(null, checksum); try { if (!cursor.eof()) {
public Long getMaxOpDepth(Long wcId, String localRelpath) throws SVNException { ISqlJetCursor c = null; try { c = getTable().lookup(null, wcId, localRelpath); c = c.reverse(); if (!c.eof()) { long rowDepth = c.getInteger(SVNWCDbSchema.NODES__Fields.op_depth.toString()); if (rowDepth >= minDepth) { return rowDepth; } } } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } finally { try { c.close(); } catch (SqlJetException e) { } } return null; }
public void transaction(SVNSqlJetDb db) throws SqlJetException, SVNException { try { db.beginTransaction(SqlJetTransactionMode.WRITE); final ISqlJetTable table = db.getDb().getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor c = table.lookup(null, wcRoot.getWcId(), SVNFileUtil.getFilePath(localRelpath)); c = c.reverse(); if (!c.eof()) { final Map<String, Object> updateValues = new HashMap<String, Object>(); updateValues.put(SVNWCDbSchema.NODES__Fields.translated_size.toString(), translatedSize); updateValues.put(SVNWCDbSchema.NODES__Fields.last_mod_time.toString(), lastModTime); c.updateByFieldNames(updateValues); } c.close(); db.commit(); } catch (SqlJetException e) { db.rollback(); throw e; } catch (SVNException e) { db.rollback(); throw e; } } }
@Override public void delete(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); while (!cursor.eof()) { cursor.delete(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to delete: " + fullname, e); } }
@Override public State get(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); if (!cursor.eof()) { State state = read(cursor); cursor.close(); return state; } } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to get " + fullname, e); } return null; }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
protected ISqlJetCursor openCursor() throws SVNException { try { Object[] where = getWhere(); if (isPathScoped() && isPathScopeInIndex()) { where = new Object[] {where[0], getPathScope()}; return getTable().scope(getIndexName(), where, null); } return getTable().lookup(getIndexName(), where); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); return null; } }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
@Override public void update(State state) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, state.fullname); while (!cursor.eof()) { cursor.update(getData(state)); cursor.next(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to update: " + state, e); } }