use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project torodb by torodb.
the class MemoryData method openWriteTransaction.
@SuppressFBWarnings(value = { "UL_UNRELEASED_LOCK" })
public MdWriteTransaction openWriteTransaction() {
Lock writeLock = lock.writeLock();
writeLock.lock();
try {
return new MdWriteTransaction(data, indexes, () -> idGenerator.incrementAndGet(), this::onCommit, writeLock);
} catch (Throwable ex) {
writeLock.unlock();
throw ex;
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project torodb by torodb.
the class AbstractReadInterface method getCollectionDidsAndProjectionWithFieldsInBatch.
@SuppressFBWarnings(value = { "OBL_UNSATISFIED_OBLIGATION", "ODR_OPEN_DATABASE_RESOURCE" }, justification = "ResultSet is wrapped in a Cursor<Tuple2<Integer, KVValue<?>>>. " + "It's iterated and closed in caller code")
private Cursor<Tuple2<Integer, KvValue<?>>> getCollectionDidsAndProjectionWithFieldsInBatch(DSLContext dsl, MetaDatabase metaDatabase, MetaCollection metaCol, MetaDocPart metaDocPart, MetaField metaField, Collection<KvValue<?>> values) throws SQLException {
String statement = getReadCollectionDidsAndProjectionWithFieldInStatement(metaDatabase.getIdentifier(), metaDocPart.getIdentifier(), metaField.getIdentifier(), values.size());
Connection connection = dsl.configuration().connectionProvider().acquire();
try {
PreparedStatement preparedStatement = connection.prepareStatement(statement);
int parameterIndex = 1;
for (KvValue<?> value : values) {
sqlHelper.setPreparedStatementValue(preparedStatement, parameterIndex, metaField.getType(), value);
parameterIndex++;
}
return new AbstractCursor<Tuple2<Integer, KvValue<?>>>(errorHandler, preparedStatement.executeQuery()) {
@Override
protected Tuple2<Integer, KvValue<?>> read(ResultSet resultSet) throws SQLException {
return new Tuple2<>(resultSet.getInt(1), sqlHelper.getResultSetKvValue(metaField.getType(), dataTypeProvider.getDataType(metaField.getType()), resultSet, 2));
}
};
} finally {
dsl.configuration().connectionProvider().release(connection);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project torodb by torodb.
the class AbstractReadInterface method getCollectionDidsWithFieldEqualsTo.
@Override
@SuppressFBWarnings(value = { "OBL_UNSATISFIED_OBLIGATION", "ODR_OPEN_DATABASE_RESOURCE" }, justification = "ResultSet is wrapped in a Cursor<Integer>. It's iterated and closed in caller code")
public Cursor<Integer> getCollectionDidsWithFieldEqualsTo(DSLContext dsl, MetaDatabase metaDatabase, MetaCollection metaCol, MetaDocPart metaDocPart, MetaField metaField, KvValue<?> value) throws SQLException {
assert metaDatabase.getMetaCollectionByIdentifier(metaCol.getIdentifier()) != null;
assert metaCol.getMetaDocPartByIdentifier(metaDocPart.getIdentifier()) != null;
assert metaDocPart.getMetaFieldByIdentifier(metaField.getIdentifier()) != null;
String statement = getReadCollectionDidsWithFieldEqualsToStatement(metaDatabase.getIdentifier(), metaDocPart.getIdentifier(), metaField.getIdentifier());
Connection connection = dsl.configuration().connectionProvider().acquire();
try {
PreparedStatement preparedStatement = connection.prepareStatement(statement);
sqlHelper.setPreparedStatementValue(preparedStatement, 1, metaField.getType(), value);
return new DefaultDidCursor(errorHandler, preparedStatement.executeQuery());
} finally {
dsl.configuration().connectionProvider().release(connection);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project torodb by torodb.
the class AbstractReadInterface method getCollectionDidsWithFieldsInBatch.
@SuppressFBWarnings(value = { "OBL_UNSATISFIED_OBLIGATION", "ODR_OPEN_DATABASE_RESOURCE" }, justification = "ResultSet is wrapped in a Cursor<Integer>. It's iterated and closed in caller code")
private Cursor<Integer> getCollectionDidsWithFieldsInBatch(DSLContext dsl, MetaDatabase metaDatabase, MetaCollection metaCol, MetaDocPart metaDocPart, Multimap<MetaField, KvValue<?>> valuesMultimap) throws SQLException {
@SuppressWarnings("checkstyle:LineLength") Provider<Stream<Map.Entry<MetaField, Collection<KvValue<?>>>>> valuesMultimapSortedStreamProvider = () -> valuesMultimap.asMap().entrySet().stream().sorted((e1, e2) -> e1.getKey().getIdentifier().compareTo(e2.getKey().getIdentifier()));
String statement = getReadCollectionDidsWithFieldInStatement(metaDatabase.getIdentifier(), metaDocPart.getIdentifier(), valuesMultimapSortedStreamProvider.get().map(e -> new Tuple2<String, Integer>(e.getKey().getIdentifier(), e.getValue().size())));
Connection connection = dsl.configuration().connectionProvider().acquire();
try {
PreparedStatement preparedStatement = connection.prepareStatement(statement);
int parameterIndex = 1;
Iterator<Map.Entry<MetaField, Collection<KvValue<?>>>> valuesMultimapSortedIterator = valuesMultimapSortedStreamProvider.get().iterator();
while (valuesMultimapSortedIterator.hasNext()) {
Map.Entry<MetaField, Collection<KvValue<?>>> valuesMultimapEntry = valuesMultimapSortedIterator.next();
for (KvValue<?> value : valuesMultimapEntry.getValue()) {
sqlHelper.setPreparedStatementValue(preparedStatement, parameterIndex, valuesMultimapEntry.getKey().getType(), value);
parameterIndex++;
}
}
return new DefaultDidCursor(errorHandler, preparedStatement.executeQuery());
} finally {
dsl.configuration().connectionProvider().release(connection);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project torodb by torodb.
the class MvccMetainfoRepository method startSnapshotStage.
@Override
@Nonnull
@SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", "UL_UNRELEASED_LOCK" })
public SnapshotStage startSnapshotStage() {
ReadLock readLock = lock.readLock();
LOGGER.trace("Trying to create a {}", MvccSnapshotStage.class);
readLock.lock();
SnapshotStage snapshotStage = null;
try {
snapshotStage = new MvccSnapshotStage(readLock);
LOGGER.trace("{} created", MvccSnapshotStage.class);
} finally {
if (snapshotStage == null) {
LOGGER.error("Error while trying to create a {}", MvccMergerStage.class);
readLock.unlock();
}
}
assert snapshotStage != null;
return snapshotStage;
}
Aggregations