Search in sources :

Example 1 with DataSource

use of com.google.gerrit.server.query.DataSource in project gerrit by GerritCodeReview.

the class IndexedChangeQuery method read.

@Override
public ResultSet<ChangeData> read() throws OrmException {
    final DataSource<ChangeData> currSource = source;
    final ResultSet<ChangeData> rs = currSource.read();
    return new ResultSet<ChangeData>() {

        @Override
        public Iterator<ChangeData> iterator() {
            return Iterables.transform(rs, cd -> {
                fromSource.put(cd, currSource);
                return cd;
            }).iterator();
        }

        @Override
        public List<ChangeData> toList() {
            List<ChangeData> r = rs.toList();
            for (ChangeData cd : r) {
                fromSource.put(cd, currSource);
            }
            return r;
        }

        @Override
        public void close() {
            rs.close();
        }
    };
}
Also used : Iterables(com.google.common.collect.Iterables) OrmException(com.google.gwtorm.server.OrmException) Change(com.google.gerrit.reviewdb.client.Change) HashMap(java.util.HashMap) IndexedQuery(com.google.gerrit.server.index.IndexedQuery) Matchable(com.google.gerrit.server.query.Matchable) HashSet(java.util.HashSet) IndexConfig(com.google.gerrit.server.index.IndexConfig) CHANGE(com.google.gerrit.server.index.change.ChangeField.CHANGE) ResultSet(com.google.gwtorm.server.ResultSet) DataSource(com.google.gerrit.server.query.DataSource) Map(java.util.Map) ChangeDataSource(com.google.gerrit.server.query.change.ChangeDataSource) ImmutableSet(com.google.common.collect.ImmutableSet) Iterator(java.util.Iterator) Set(java.util.Set) Preconditions.checkState(com.google.common.base.Preconditions.checkState) Predicate(com.google.gerrit.server.query.Predicate) QueryParseException(com.google.gerrit.server.query.QueryParseException) ChangeData(com.google.gerrit.server.query.change.ChangeData) List(java.util.List) PROJECT(com.google.gerrit.server.index.change.ChangeField.PROJECT) QueryOptions(com.google.gerrit.server.index.QueryOptions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) IndexPredicate(com.google.gerrit.server.index.IndexPredicate) ResultSet(com.google.gwtorm.server.ResultSet) ChangeData(com.google.gerrit.server.query.change.ChangeData)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Change (com.google.gerrit.reviewdb.client.Change)1 IndexConfig (com.google.gerrit.server.index.IndexConfig)1 IndexPredicate (com.google.gerrit.server.index.IndexPredicate)1 IndexedQuery (com.google.gerrit.server.index.IndexedQuery)1 QueryOptions (com.google.gerrit.server.index.QueryOptions)1 CHANGE (com.google.gerrit.server.index.change.ChangeField.CHANGE)1 PROJECT (com.google.gerrit.server.index.change.ChangeField.PROJECT)1 DataSource (com.google.gerrit.server.query.DataSource)1 Matchable (com.google.gerrit.server.query.Matchable)1 Predicate (com.google.gerrit.server.query.Predicate)1 QueryParseException (com.google.gerrit.server.query.QueryParseException)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1 ChangeDataSource (com.google.gerrit.server.query.change.ChangeDataSource)1 OrmException (com.google.gwtorm.server.OrmException)1 ResultSet (com.google.gwtorm.server.ResultSet)1 HashMap (java.util.HashMap)1