Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions vertx-sql-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,58 +62,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>benchmarks</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble-benchmarks</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>org.openjdk.jmh.Main</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/test/assembly/benchmarks.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import io.vertx.sqlclient.Row;
import io.vertx.sqlclient.RowIterator;
import io.vertx.sqlclient.RowSet;
import io.vertx.sqlclient.impl.accumulator.ArrayListRowAccumulator;
import io.vertx.sqlclient.impl.accumulator.RowAccumulator;

import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collector;

Expand All @@ -38,9 +39,7 @@ class RowSetImpl<R> extends SqlResultBase<RowSet<R>> implements RowSet<R> {
static <U> Collector<Row, RowSetImpl<U>, RowSet<U>> collector(Function<Row, U> mapper) {
return Collector.of(
RowSetImpl::new,
(set, row) -> {
set.add(mapper.apply(row));
},
(set, row) -> set.add(mapper.apply(row)),
(set1, set2) -> null, // Shall not be invoked as this is sequential
(set) -> set
);
Expand All @@ -52,65 +51,38 @@ static <U> Function<RowSet<U>, RowSetImpl<U>> factory() {
return rs -> (RowSetImpl<U>) rs;
}

private R firstRow;
private RowAccumulator<R> rowAccumulator;
private List<R> rowAccumulator = Collections.emptyList();

@Override
public RowSet<R> value() {
return this;
}

private void add(R row) {
if (rowAccumulator != null) {
rowAccumulator.accept(row);
} else if (firstRow != null) {
rowAccumulator = new ArrayListRowAccumulator<>();
rowAccumulator.accept(firstRow);
rowAccumulator.accept(row);
firstRow = null;
} else {
firstRow = row;
if (rowAccumulator.isEmpty()) {
rowAccumulator = new ArrayList<>();
}
rowAccumulator.add(row);
}

@Override
public RowIterator<R> iterator() {
return rowAccumulator != null ? rowAccumulator.iterator() : SingletonRowIterator.createFor(firstRow);
Iterator<R> iter = rowAccumulator.iterator();
return new RowIterator<R>() {
@Override
public boolean hasNext() {
return iter.hasNext();
}

@Override
public R next() {
return iter.next();
}
};
}

@Override
public RowSetImpl<R> next() {
return (RowSetImpl<R>) super.next();
}

private static final class SingletonRowIterator<ROW> implements RowIterator<ROW> {

static final SingletonRowIterator<Object> EMPTY_INSTANCE = new SingletonRowIterator<>(null);

ROW row;

SingletonRowIterator(ROW row) {
this.row = row;
}

@SuppressWarnings("unchecked")
static <X> SingletonRowIterator<X> createFor(X row) {
return row != null ? new SingletonRowIterator<>(row) : (SingletonRowIterator<X>) EMPTY_INSTANCE;
}

@Override
public boolean hasNext() {
return row != null;
}

@Override
public ROW next() {
if (row != null) {
ROW res = row;
row = null;
return res;
}
throw new NoSuchElementException();
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading