Skip to content

Commit

Permalink
1.5.1 - Refactoring Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
landawn committed Feb 17, 2019
1 parent fe7a835 commit b53e8d8
Show file tree
Hide file tree
Showing 13 changed files with 628 additions and 412 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<classpathentry kind="lib" path="lib/neo4j-ogm-core-2.0.0-M03.jar"/>
<classpathentry kind="lib" path="lib/neo4j-ogm-http-driver-2.0.0-M03.jar"/>
<classpathentry kind="lib" path="lib/javaee-api-7.0.jar"/>
<classpathentry kind="lib" path="lib/abacus-util-1.5.jar" sourcepath="C:/Users/haiyangl/AppData/Local/Temp/decompiler/source/abacus-util-1.3.29-sources.jar"/>
<classpathentry kind="lib" path="lib/abacus-util-1.5.1.jar" sourcepath="C:/Users/haiyangl/AppData/Local/Temp/decompiler/source/abacus-util-1.3.29-sources.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/okhttp-3.13.1.jar" sourcepath="C:/Users/haiyangl/AppData/Local/Temp/decompiler/source/okhttp-3.2.0-sources.jar"/>
<classpathentry kind="lib" path="lib/okhttp-urlconnection-3.2.0.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.5
### 1.5.1

* Change the stream implementation: Streams will be automatically closed after execution(any terminal method is executed).

Expand Down
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,33 +180,33 @@ A general programming library in Java/Android. It's easy to learn and simple to
[RemoteExecutor](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/RemoteExecutor_view.html).

* More:
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/IEEE754rUtil.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/f.html),
[Iterables](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Iterables.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.5/com/landawn/abacus/util/Traverser.html)(from Apache commons, Google Guava...) ...
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/IEEE754rUtil.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/f.html),
[Iterables](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Iterables.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.5.1/com/landawn/abacus/util/Traverser.html)(from Apache commons, Google Guava...) ...


## Download/Installation & [Changes](https://github.com/landawn/AbacusUtil/blob/master/CHANGES.md):
Expand All @@ -216,22 +216,22 @@ A general programming library in Java/Android. It's easy to learn and simple to
* Gradle:
```gradle
// JDK 1.8 or above:
compile 'com.landawn:abacus-util:1.5'
compile 'com.landawn:abacus-util:1.5.1'
// JDK 1.7:
compile 'com.landawn:abacus-util-jdk7:1.5'
compile 'com.landawn:abacus-util-jdk7:1.5.1'
// Android (Java 1.7):
compile 'abacus-android-jdk7:1.5'
compile 'abacus-android-jdk7:1.5.1'
// Android-SE (Java 1.7) - small edition without Stream/Matrix/Sheet/...:
compile 'abacus-android-se-jdk7:1.5'
compile 'abacus-android-se-jdk7:1.5.1'
// Android (Java 1.8 or above):
compile 'com.landawn:abacus-android:1.5'
compile 'com.landawn:abacus-android:1.5.1'
// Android-SE (Java 1.8 or above) - small edition without Stream/Matrix/Sheet/...:
compile 'com.landawn:abacus-android-se:1.5'
compile 'com.landawn:abacus-android-se:1.5.1'
```
### Functional Programming:
(It's very important to learn Lambdas and Stream APIs in Java 8 to get the best user experiences with the APIs provided in AbacusUtil)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
90 changes: 45 additions & 45 deletions src/com/landawn/abacus/util/AsyncSQLExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.Callable;

Expand All @@ -26,6 +25,7 @@
import com.landawn.abacus.util.SQLExecutor.JdbcSettings;
import com.landawn.abacus.util.SQLExecutor.ResultExtractor;
import com.landawn.abacus.util.SQLExecutor.StatementSetter;
import com.landawn.abacus.util.stream.Stream;

/**
* Asynchronous <code>SQLExecutor</code>.
Expand Down Expand Up @@ -1704,98 +1704,98 @@ public DataSet call() throws Exception {
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final Class<T> targetClass, final String sql, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> stream(final Class<T> targetClass, final String sql, final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(targetClass, sql, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final Class<T> targetClass, final String sql,
final StatementSetter statementSetter, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> stream(final Class<T> targetClass, final String sql, final StatementSetter statementSetter,
final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(targetClass, sql, statementSetter, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final Class<T> targetClass, final String sql, final JdbcSettings jdbcSettings,
public final <T> ContinuableFuture<Stream<T>> stream(final Class<T> targetClass, final String sql, final JdbcSettings jdbcSettings,
final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(targetClass, sql, jdbcSettings, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final Class<T> targetClass, final String sql,
final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> stream(final Class<T> targetClass, final String sql, final StatementSetter statementSetter,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(targetClass, sql, statementSetter, jdbcSettings, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final String sql,
final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> stream(final String sql, final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter,
final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(sql, recordGetter, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final String sql, final StatementSetter statementSetter,
public final <T> ContinuableFuture<Stream<T>> stream(final String sql, final StatementSetter statementSetter,
final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(sql, statementSetter, recordGetter, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final String sql,
final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter, final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> stream(final String sql, final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(sql, recordGetter, jdbcSettings, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> stream(final String sql, final StatementSetter statementSetter,
public final <T> ContinuableFuture<Stream<T>> stream(final String sql, final StatementSetter statementSetter,
final JdbcUtil.BiRecordGetter<T, RuntimeException> recordGetter, final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.stream(sql, statementSetter, recordGetter, jdbcSettings, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> streamAll(final Class<T> targetClass, final String sql,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> streamAll(final Class<T> targetClass, final String sql, final JdbcSettings jdbcSettings,
final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.streamAll(targetClass, sql, jdbcSettings, parameters);
}
});
Expand All @@ -1811,22 +1811,22 @@ public ExceptionalStream<T, SQLException> call() throws Exception {
* @return
*/
@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> streamAll(final Class<T> targetClass, final String sql,
final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> streamAll(final Class<T> targetClass, final String sql, final StatementSetter statementSetter,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.streamAll(targetClass, sql, statementSetter, jdbcSettings, parameters);
}
});
}

@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> streamAll(final Class<T> targetClass, final List<String> sqls,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> streamAll(final Class<T> targetClass, final List<String> sqls, final JdbcSettings jdbcSettings,
final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.streamAll(targetClass, sqls, jdbcSettings, parameters);
}
});
Expand All @@ -1842,11 +1842,11 @@ public ExceptionalStream<T, SQLException> call() throws Exception {
* @return
*/
@SafeVarargs
public final <T> ContinuableFuture<ExceptionalStream<T, SQLException>> streamAll(final Class<T> targetClass, final List<String> sqls,
final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<ExceptionalStream<T, SQLException>>() {
public final <T> ContinuableFuture<Stream<T>> streamAll(final Class<T> targetClass, final List<String> sqls, final StatementSetter statementSetter,
final JdbcSettings jdbcSettings, final Object... parameters) {
return asyncExecutor.execute(new Callable<Stream<T>>() {
@Override
public ExceptionalStream<T, SQLException> call() throws Exception {
public Stream<T> call() throws Exception {
return sqlExecutor.streamAll(targetClass, sqls, statementSetter, jdbcSettings, parameters);
}
});
Expand Down
Loading

0 comments on commit b53e8d8

Please sign in to comment.