JDK-8188051-branch javadoc updates JDK-8188051-branch
authorlancea
Thu, 12 Jul 2018 15:23:13 -0400
branchJDK-8188051-branch
changeset 56832 4f7713e6a308
parent 56831 21443aec7aa7
child 56997 c9cbac2979fb
JDK-8188051-branch javadoc updates
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/DataSourceProperty.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Examples.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/OperationGroup.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/RowCountOperation.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Session.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SessionProperty.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SqlColumns.java
src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/package-info.java
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/DataSourceProperty.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/DataSourceProperty.java	Thu Jul 12 15:23:13 2018 -0400
@@ -81,7 +81,7 @@
   public boolean isSensitive();
 
   /**
-   * Configure the {@link DataSource as appropriate for the given {@code value} 
+   * Configure the {@link DataSource} as appropriate for the given {@code value} 
    * of this {@link DataSourceProperty}. This is primarily for the use of user 
    * defined properties.
    *
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Examples.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Examples.java	Thu Jul 12 15:23:13 2018 -0400
@@ -34,6 +34,7 @@
 import java.util.concurrent.Flow;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collector;
 import java.util.stream.Collectors;
 
@@ -256,32 +257,6 @@
     }
   }
   
-  // Control Operation Submission Rate
-    
-  public CompletionStage<Long> insertRecords(DataSource ds, DataInputStream in) {
-    String insert = "insert into tab values (@record)";
-    try (Session session = ds.getSession()) {
-      OperationGroup<Long, Long> group = session.<Long, Long>operationGroup()
-              .independent()
-              .collect(Collectors.summingLong(c -> c));
-      group.submitHoldingForMoreMembers();
-      Semaphore demand = new Semaphore(0);
-      session.requestHook( n -> demand.release((int)n) );
-      while (in.available() > 0) {
-        demand.acquire(1); // user thread blocked by Semaphore, not by ADBA
-        group.<Long>rowCountOperation(insert)
-                    .set("record", in.readUTF(), AdbaType.VARCHAR)
-                    .apply(c -> c.getCount())
-                    .submit();
-      }
-      return group.releaseProhibitingMoreMembers()
-                  .getCompletionStage();
-    }
-    catch (IOException | InterruptedException ex) { 
-      throw new SqlException(ex);
-    }
-  }  
-  
   // ArrayRowCountOperation
   
   public CompletionStage<Long> arrayInsert(DataSource ds, 
@@ -336,6 +311,47 @@
   
   // LocalOperation
   
+  // Control Operation Submission Rate
+    
+  public CompletionStage<Long> insertRecords(DataSource ds, DataInputStream in) {
+    String insert = "insert into tab values (@record)";
+    try (Session session = ds.getSession()) {
+      OperationGroup<Long, Long> group = session.<Long, Long>operationGroup()
+              .independent()
+              .collect(Collectors.summingLong(c -> c));
+      group.submitHoldingForMoreMembers();
+      Semaphore demand = new Semaphore(0);
+      session.requestHook( n -> demand.release((int)n) );
+      while (in.available() > 0) {
+        demand.acquire(1); // user thread blocked by Semaphore, not by ADBA
+        group.<Long>rowCountOperation(insert)
+                    .set("record", in.readUTF(), AdbaType.VARCHAR)
+                    .apply(c -> c.getCount())
+                    .submit();
+      }
+      return group.releaseProhibitingMoreMembers()
+                  .getCompletionStage();
+    }
+    catch (IOException | InterruptedException ex) { 
+      throw new SqlException(ex);
+    }
+  }
+  
+  // Controlling Session creation rate
+  
+  public void ingest(DataInputStream in) throws Exception {
+    DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory");
+    Semaphore demand = new Semaphore(0);
+    DataSource ds = factory.builder()
+            .requestHook( n -> demand.release((int)n) )
+            .build();
+    AtomicLong total = new AtomicLong(0L);
+    do {
+      demand.acquire(1);
+      insertRecords(ds, in).thenAccept(total::addAndGet);
+    } while (true);
+  }
+  
   // SessionProperty
   public enum ExampleSessionProperty implements SessionProperty {
     LANGUAGE;
@@ -367,6 +383,14 @@
     
   }
   
+  public DataSource getDataSource(DataSourceFactory factory) {
+    return factory.builder()
+            .registerSessionProperty(ExampleSessionProperty.LANGUAGE)
+            // or .defaultSessionProperty(ExampleSessionProperty.LANGUAGE, "AMERICAN_AMERICA")
+            // or .sessionProperty(ExampleSessionProperty.LANGUAGE, "FRENCHCANADIAN_CANADA")
+            .build();
+  }
+  
   public Session getSession(DataSource ds) {
     return ds.builder()
             .property(ExampleSessionProperty.LANGUAGE, "FRENCH_FRANCE")
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/OperationGroup.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/OperationGroup.java	Thu Jul 12 15:23:13 2018 -0400
@@ -296,7 +296,7 @@
   /**
    * Return a new {@link ParameterizedRowCountOperation}.
    *
-   * @param <R> the result type of the returned {@link CountOperation}
+   * @param <R> the result type of the returned {@link RowCountOperation}
    * @param sql SQL to be executed. Must return an update count.
    * @return an new {@link ParameterizedRowCountOperation} that is a member of this
    * {@link OperationGroup}
@@ -378,11 +378,11 @@
   public <R extends S> MultiOperation<R> multiOperation(String sql);
 
   /**
-   * Return a new {@link Operation} that ends the database transaction.  This
+   * Return a new {@link Operation} that ends the database transaction. This
    * {@link Operation} is a member of the {@link OperationGroup}. The
-   * transaction is ended with a commit unless the {@link Transaction} has been
-   * {@link Transaction#setRollbackOnly} in which case the transaction is ended
-   * with a rollback.
+   * transaction is ended with a commit unless the {@link TransactionCompletion}
+   * has been {@link TransactionCompletion#setRollbackOnly} in which case the
+   * transaction is ended with a rollback.
    * 
    * <p>
    * An endTransaction Operation may be skipped. To insure that it will not be
@@ -508,14 +508,13 @@
    * If {@code identifier} is not a simple SQL identifier, {@code identifier}
    * will be enclosed in double quotes if not already present. If the datasource
    * does not support double quotes for delimited identifiers, the identifier
-   * should be enclosed by the string returned from
-   * {@link DatabaseMetaData#getIdentifierQuoteString}. If the datasource does
-   * not support delimited identifiers, a
-   * {@code SQLFeatureNotSupportedException} should be thrown.
+   * should be enquoted by whatever mechanism the data source supports. If the
+   * datasource does not support delimited identifiers, an
+   * {@code IllegalArgumentException} should be thrown.
    * <p>
-   * A {@code SQLException} will be thrown if {@code identifier} contains any
-   * characters invalid in a delimited identifier or the identifier length is
-   * invalid for the datasource.
+   * A {@code IllegalArgumentException} will be thrown if {@code identifier}
+   * contains any characters invalid in a delimited identifier or the identifier
+   * length is invalid for the datasource.
    *
    * @implSpec The default implementation uses the following criteria to
    * determine a valid simple SQL identifier:
@@ -577,17 +576,17 @@
    * <tr>
    * <th scope="row">Hello"World</th>
    * <td>false</td>
-   * <td>SQLException</td>
+   * <td>IllegalArgumentException</td>
    * </tr>
    * <tr>
    * <th scope="row">"Hello"World"</th>
    * <td>false</td>
-   * <td>SQLException</td>
+   * <td>IllegalArgumentException</td>
    * </tr>
    * </tbody>
    * </table>
    * </blockquote>
-   * @implNote JDBC driver implementations may need to provide their own
+   * @implNote ADBA driver implementations may need to provide their own
    * implementation of this method in order to meet the requirements of the
    * underlying datasource.
    * @param identifier a SQL identifier. Not null
@@ -668,7 +667,7 @@
    * </tbody>
    * </table>
    * </blockquote>
-   * @implNote JDBC driver implementations may need to provide their own
+   * @implNote ADBA driver implementations may need to provide their own
    * implementation of this method in order to meet the requirements of the
    * underlying datasource.
    * @param identifier a SQL identifier. Not null
@@ -708,7 +707,7 @@
    * </table>
    * </blockquote>
    *
-   * @implNote JDBC driver implementations may need to provide their own
+   * @implNote ADBA driver implementations may need to provide their own
    * implementation of this method in order to meet the requirements of the
    * underlying datasource. An implementation of enquoteNCharLiteral may accept
    * a different set of characters than that accepted by the same drivers
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/RowCountOperation.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/RowCountOperation.java	Thu Jul 12 15:23:13 2018 -0400
@@ -32,7 +32,7 @@
  * An {@link Operation} that returns a count.
  *
  * @param <T> the type of the result of the {@link Operation}
- * @see ParameterizedCountOperation
+ * @see ParameterizedRowCountOperation
  */
 public interface RowCountOperation<T> extends Operation<T> {
 
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Session.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Session.java	Thu Jul 12 15:23:13 2018 -0400
@@ -40,7 +40,7 @@
  * <p>
  * A {@link Session} is independent of any particular data source. Any data 
  * source that meets the specifications set by the {@link Session.Builder} can
- * be used to execute the {@link Operation}s submitted to the {@link Session].
+ * be used to execute the {@link Operation}s submitted to the {@link Session}.
  * An application is expected to create, use, and close {@link Session}s as 
  * needed. An application should hold a {@link Session} only when required by
  * data source semantics. An implementation should cache and reused data source
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SessionProperty.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SessionProperty.java	Thu Jul 12 15:23:13 2018 -0400
@@ -73,7 +73,7 @@
   public Object defaultValue();
 
   /**
-   * Returns true if this {@link SessionProperty} is contains sensitive information
+   * Returns true if this {@link SessionProperty} contains sensitive information
    * such as a password or encryption key.
    *
    * @return true iff this is sensitive
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SqlColumns.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/SqlColumns.java	Thu Jul 12 15:23:13 2018 -0400
@@ -34,13 +34,13 @@
 
 /**
  * Identifies a constructor or static factory method that can be used to construct
- * an instance of the containing type when the type is passed to {@link Result.ResultMap#get}.
+ * an instance of the containing type when the type is passed to {@link Result.Column#get}.
  * The method or constructor must be public.
  * 
  * An instance of this type will be constructed by calling the factory method or
  * constructor. Each element in the value of this annotation is used as a column
  * identifier. The value of that column is passed to the corresponding parameter
- * of the annotated method or constructor. The id argument to {@link Result.ResultMap#get} is 
+ * of the annotated method or constructor. The id argument to {@link Result.Column#get} is 
  * prefixed to the column identifiers.
  * 
  * The following pseudo-code describes how an instance is constructed.
@@ -50,7 +50,7 @@
  *   String[] columns = methodOrConstructor.getAnnotation(SqlColumns.class).value();
  *   Object[] args = new Object[columns.length];
  *   for (String columnName : columns)
- *     args[i] = resultMap.get(prefix + columnName, parameterTypes[i++];
+ *     args[i] = colum.at(prefix + columnName).get(parameterTypes[i++]);
  *   instance = methodOrConstructor.invoke(null, args);</pre>}
  * 
  */
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/package-info.java	Thu Jul 12 15:21:13 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/package-info.java	Thu Jul 12 15:23:13 2018 -0400
@@ -103,8 +103,8 @@
  *
  * <p>
  * A single context in a data source is represented by a {@link Session}. A 
- * {@link Session} is somewhat analogous to a logical {@link java.sql.Connection}.
- * A physical {@link java.sql.Connection} has no representation in this API; if
+ * {@link Session} is somewhat analogous to a logical {@code java.sql.Connection}.
+ * A physical {@code java.sql.Connection} has no representation in this API; if
  * such an entity exists at all it is strictly internal to an implementation.
  * Within this spec this entity is referred to as a "data source resource".
  * </p>
@@ -368,7 +368,7 @@
  * FooSession.Builder. build must return a FooSession</li>
  * <li>FooDataSource must override getSession to return FooSession</li>
  * <li>FooSession must extend FooOperationGroup</li>
- * <li>FooOperationGroup> must override rowCountOperation to return FooRowCountOperation</li>
+ * <li>FooOperationGroup must override rowCountOperation to return FooRowCountOperation</li>
  * <li>FooRowCountOperation must override apply and onError to return FooRowCountOperation</li>
  * </ul>
  * <p>