public void close() throws SqlJetException { if (table != null) { table = null; } if (cursor != null) { cursor.close(); cursor = null; } }
FSRepresentationCacheRecord(ISqlJetCursor cursor) throws SqlJetException { final int fieldsCount = cursor.getFieldsCount(); if (fieldsCount == 0) { return; if (!cursor.isNull(HASH_FIELD)) { myHash = cursor.getString(HASH_FIELD); if (!cursor.isNull(REVISION_FIELD)) { myRevision = cursor.getInteger(REVISION_FIELD); if (!cursor.isNull(OFFSET_FIELD)) { myOffset = cursor.getInteger(OFFSET_FIELD); if (!cursor.isNull(SIZE_FIELD)) { mySize = cursor.getInteger(SIZE_FIELD); if (!cursor.isNull(EXPANDED_SIZE_FIELD)) { myExpandedSize = cursor.getInteger(EXPANDED_SIZE_FIELD);
private State read(ISqlJetCursor cursor) { try { String fullname = cursor.getString(StateTable.COL_FULL_NAME); String version = null; if (!cursor.isNull(StateTable.COL_VERSION)) version = cursor.getString(StateTable.COL_VERSION); return new State(fullname, version); } catch (SqlJetException e) { logger.error("unable to read", e); return null; } }
ISqlJetCursor cursor = nodesTable.open(); try { while(!cursor.eof()) { long opDepth = cursor.getInteger(NODES__Fields.op_depth.toString()); if (opDepth == 0) { String checksum = cursor.getString(NODES__Fields.checksum.toString()); if (refcountTable.containsKey(checksum)) { refcountTable.put(checksum, refcountTable.get(checksum) + 1); cursor.next(); cursor.close(); cursor = pTable.lookup(null, checksum); try { if (!cursor.eof()) { long refCount = cursor.getInteger(PRISTINE__Fields.refcount.toString()); if (refCount != refcountTable.get(checksum)) { Map<String, Object> value = new HashMap<String, Object>(); cursor.updateByFieldNames(value); cursor.close();
public void beforeUpdate(ISqlJetCursor cursor, Map<String, Object> newValues) throws SqlJetException { ISqlJetTable table = db.getDb().getTemporaryDatabase().getTable(SVNWCDbSchema.REVERT_LIST.toString()); Map<String, Object> rowValues = new HashMap<String, Object>(); rowValues.put(REVERT_LIST__Fields.local_relpath.toString(), cursor.getValue(ACTUAL_NODE__Fields.local_relpath.toString())); rowValues.put(REVERT_LIST__Fields.actual.toString(), 1); rowValues.put(REVERT_LIST__Fields.conflict_data.toString(), cursor.getBlobAsArray(ACTUAL_NODE__Fields.conflict_data.toString())); if (!cursor.isNull(ACTUAL_NODE__Fields.properties.toString()) || !cursor.isNull(ACTUAL_NODE__Fields.tree_conflict_data.toString())) { rowValues.put(REVERT_LIST__Fields.notify.toString(), 1); } else if (!exists(db.getDb().getTemporaryDatabase(), cursor.getInteger(ACTUAL_NODE__Fields.wc_id.toString()), cursor.getString(ACTUAL_NODE__Fields.local_relpath.toString()))) { rowValues.put(REVERT_LIST__Fields.notify.toString(), 1); } else { rowValues.put(REVERT_LIST__Fields.notify.toString(), null); } table.insertByFieldNamesOr(SqlJetConflictAction.REPLACE, rowValues); }
if (!cursor.eof()) byte[] transactionId = cursor.getBlobAsArray(TRANSACTION_COLUMN); byte phase = (byte) cursor.getInteger(PHASE_COLUMN); byte exceptionType = (byte) cursor.getInteger(EXCEPTION_COLUMN); map.put(SQLiteStateManager.this.listener.createInvocationEvent(transactionId, phase, exceptionType), new HashMap<String, InvokerEvent>()); while (cursor.next()); cursor.close(); if (!cursor.eof()) byte[] transactionId = cursor.getBlobAsArray(TRANSACTION_COLUMN); byte phase = (byte) cursor.getInteger(PHASE_COLUMN); DurabilityEvent event = SQLiteStateManager.this.listener.createEvent(transactionId, phase); Map<String, InvokerEvent> invokers = map.get(event); if (invokers != null) String databaseId = cursor.getString(DATABASE_COLUMN); InvokerEvent invokerEvent = SQLiteStateManager.this.eventFactory.createInvokerEvent(event.getTransactionId(), event.getPhase(), databaseId); if (!cursor.isNull(RESULT_COLUMN)) byte[] result = cursor.getBlobAsArray(RESULT_COLUMN); invokerEvent.setResult(Objects.deserialize(result, InvokerResult.class)); while (cursor.next());
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; }
while(!actulaNode.eof()) { final String conflictOld = actulaNode.getString(ACTUAL_NODE__Fields.conflict_old.toString()); final String conflictWorking = actulaNode.getString(ACTUAL_NODE__Fields.conflict_working.toString()); final String conflictNew = actulaNode.getString(ACTUAL_NODE__Fields.conflict_new.toString()); final String propReject = actulaNode.getString(ACTUAL_NODE__Fields.prop_reject.toString()); final byte[] treeConflictData = actulaNode.getBlobAsArray(ACTUAL_NODE__Fields.tree_conflict_data.toString()); actulaNode.next(); continue; final String localRelpath = actulaNode.getString(ACTUAL_NODE__Fields.local_relpath.toString()); final SVNSkel conflictData = SvnWcDbConflicts.convertToConflictSkel(wcRootAbsPath, db, localRelpath, conflictOld, conflictWorking, conflictNew, propReject, treeConflictData); newRowValues.put(ACTUAL_NODE__Fields.prop_reject.toString(), null); newRowValues.put(ACTUAL_NODE__Fields.tree_conflict_data.toString(), null); actulaNode.updateByFieldNames(newRowValues); actulaNode.next();
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; } }
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; }
@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); } }
@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); } } };
@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); } }
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; } } }