git commit: PHOENIX-1254 Add REGEXP_SPLIT function

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/3.0 a2d8b5297 - a56b2f48c


PHOENIX-1254 Add REGEXP_SPLIT function

Add REGEXP_SPLIT function to create VARCHAR_ARRAYs from a VARCHAR
by splitting on a regular expression pattern.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a56b2f48
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a56b2f48
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a56b2f48

Branch: refs/heads/3.0
Commit: a56b2f48cce073aedb8a531229d4563a501ab6e6
Parents: a2d8b52
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 09:30:19 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:07:01 2014 +0200

--
 .../phoenix/end2end/RegexpSplitFunctionIT.java  | 210 +++
 .../phoenix/expression/ExpressionType.java  |   6 +-
 .../function/RegexpSplitFunction.java   | 127 +++
 3 files changed, 341 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a56b2f48/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java
new file mode 100644
index 000..73f1828
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.sql.Array;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@Category(HBaseManagedTimeTest.class)
+public class RegexpSplitFunctionIT extends BaseHBaseManagedTimeIT {
+
+private void initTable(Connection conn, String val) throws SQLException {
+initTable(conn, val, ,);
+}
+
+private void initTable(Connection conn, String val, String separator) 
throws SQLException {
+String ddl = CREATE TABLE SPLIT_TEST ( +
+ID INTEGER NOT NULL PRIMARY KEY, +
+VAL VARCHAR, +
+SEP VARCHAR, +
+ARR VARCHAR ARRAY);
+conn.createStatement().execute(ddl);
+String dml = UPSERT INTO SPLIT_TEST (ID, SEP, VAL) VALUES (?, ?, ?);
+PreparedStatement stmt = conn.prepareStatement(dml);
+stmt.setInt(1, 1);
+if (separator == null) {
+stmt.setNull(2, Types.VARCHAR);
+} else {
+stmt.setString(2, separator);
+}
+if (val == null) {
+stmt.setNull(3, Types.VARCHAR);
+} else {
+stmt.setString(3, val);
+}
+stmt.execute();
+conn.commit();
+}
+
+@Test
+public void testSplit_ArrayReference() throws SQLException {
+Connection conn = DriverManager.getConnection(getUrl());
+initTable(conn, ONE,TWO,THREE);
+
+ResultSet rs = conn.createStatement().executeQuery(
+SELECT REGEXP_SPLIT(VAL, ',')[1] FROM SPLIT_TEST);
+assertTrue(rs.next());
+assertEquals(ONE, rs.getString(1));
+assertFalse(rs.next());
+}
+
+@Test
+public void testSplit_InFilter() throws SQLException {
+Connection conn = DriverManager.getConnection(getUrl());
+initTable(conn, ONE,TWO,THREE);
+
+ResultSet rs = conn.createStatement().executeQuery(
+SELECT ID FROM SPLIT_TEST WHERE (REGEXP_SPLIT(VAL, ','))[1] = 
'ONE');
+

git commit: PHOENIX-1250 Remove use of Closeables.closeQuietly

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/4.0 45e2891ce - 89262f2be


PHOENIX-1250 Remove use of Closeables.closeQuietly

Remove the use of Guava's Closeables.closeQuietly to allow using
Phoenix within a client-side application that has a more recent
version of Guava. After this commit, Phoenix can be built against
Guava 18.0 (although full integration tests will not work because
HBase/Hadoop still rely on an older version of Guava internally).


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/89262f2b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/89262f2b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/89262f2b

Branch: refs/heads/4.0
Commit: 89262f2be4c6bf6b63b6e57364141a2a2d5d673e
Parents: 45e2891
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 11:58:33 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:17:41 2014 +0200

--
 phoenix-core/pom.xml|  4 ++
 .../apache/phoenix/cache/ServerCacheClient.java |  4 +-
 .../phoenix/cache/aggcache/SpillFile.java   |  2 +-
 .../phoenix/cache/aggcache/SpillManager.java|  2 +-
 .../cache/aggcache/SpillableGroupByCache.java   |  2 +-
 .../apache/phoenix/compile/FromCompiler.java|  2 +-
 .../GroupedAggregateRegionObserver.java |  3 +-
 .../phoenix/iterate/TableResultIterator.java|  2 +-
 .../query/ConnectionQueryServicesImpl.java  |  7 ++-
 .../org/apache/phoenix/util/Closeables.java | 46 +---
 .../apache/phoenix/flume/sink/PhoenixSink.java  |  7 +--
 pom.xml |  5 +++
 12 files changed, 62 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/89262f2b/phoenix-core/pom.xml
--
diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index ff3f5d8..0a8b61b 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -325,6 +325,10 @@
   groupIdorg.apache.commons/groupId
   artifactIdcommons-csv/artifactId
 /dependency
+dependency
+  groupIdcom.google.code.findbugs/groupId
+  artifactIdjsr305/artifactId
+/dependency
   /dependencies
 
   profiles

http://git-wip-us.apache.org/repos/asf/phoenix/blob/89262f2b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 301c452..f4be508 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -17,8 +17,6 @@
  */
 package org.apache.phoenix.cache;
 
-import static com.google.common.io.Closeables.closeQuietly;
-
 import java.io.Closeable;
 import java.io.IOException;
 import java.sql.SQLException;
@@ -319,7 +317,7 @@ public class ServerCacheClient {
LOG.warn(Unable to remove hash cache for  + 
remainingOnServers, lastThrowable);
}
} finally {
-   closeQuietly(iterateOverTable);
+   Closeables.closeQuietly(iterateOverTable);
}
 }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/89262f2b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
index 31ad5ce..8dd64d0 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
@@ -28,11 +28,11 @@ import java.nio.channels.FileChannel.MapMode;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.phoenix.util.Closeables;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
 
 /**
  * This class abstracts a SpillFile It is a accessible on a per page basis

http://git-wip-us.apache.org/repos/asf/phoenix/blob/89262f2b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
index 3f4bf35..2fbea5c 100644
--- 

git commit: PHOENIX-1250 Remove use of Closeables.closeQuietly

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/master 89c2f2741 - 3034b6583


PHOENIX-1250 Remove use of Closeables.closeQuietly

Remove the use of Guava's Closeables.closeQuietly to allow using
Phoenix within a client-side application that has a more recent
version of Guava. After this commit, Phoenix can be built against
Guava 18.0 (although full integration tests will not work because
HBase/Hadoop still rely on an older version of Guava internally).


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3034b658
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3034b658
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3034b658

Branch: refs/heads/master
Commit: 3034b6583b7af3a5356ee77bba5028dc243c0bb4
Parents: 89c2f27
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 11:58:33 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:16:36 2014 +0200

--
 phoenix-core/pom.xml|  4 ++
 .../apache/phoenix/cache/ServerCacheClient.java |  4 +-
 .../phoenix/cache/aggcache/SpillFile.java   |  2 +-
 .../phoenix/cache/aggcache/SpillManager.java|  2 +-
 .../cache/aggcache/SpillableGroupByCache.java   |  2 +-
 .../apache/phoenix/compile/FromCompiler.java|  2 +-
 .../GroupedAggregateRegionObserver.java |  3 +-
 .../phoenix/iterate/TableResultIterator.java|  2 +-
 .../query/ConnectionQueryServicesImpl.java  |  7 ++-
 .../org/apache/phoenix/util/Closeables.java | 46 +---
 .../apache/phoenix/flume/sink/PhoenixSink.java  |  7 +--
 pom.xml |  5 +++
 12 files changed, 62 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3034b658/phoenix-core/pom.xml
--
diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index d5774ea..eb1004b 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -325,6 +325,10 @@
   groupIdorg.apache.commons/groupId
   artifactIdcommons-csv/artifactId
 /dependency
+dependency
+  groupIdcom.google.code.findbugs/groupId
+  artifactIdjsr305/artifactId
+/dependency
   /dependencies
 
   profiles

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3034b658/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 301c452..f4be508 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -17,8 +17,6 @@
  */
 package org.apache.phoenix.cache;
 
-import static com.google.common.io.Closeables.closeQuietly;
-
 import java.io.Closeable;
 import java.io.IOException;
 import java.sql.SQLException;
@@ -319,7 +317,7 @@ public class ServerCacheClient {
LOG.warn(Unable to remove hash cache for  + 
remainingOnServers, lastThrowable);
}
} finally {
-   closeQuietly(iterateOverTable);
+   Closeables.closeQuietly(iterateOverTable);
}
 }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3034b658/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
index 31ad5ce..8dd64d0 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillFile.java
@@ -28,11 +28,11 @@ import java.nio.channels.FileChannel.MapMode;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.phoenix.util.Closeables;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
 
 /**
  * This class abstracts a SpillFile It is a accessible on a per page basis

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3034b658/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
index 3f4bf35..2fbea5c 100644
--- 

git commit: PHOENIX-1253 Throw SQLException on prepared stmt

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/3.0 12494b7bf - 963ea0f91


PHOENIX-1253 Throw SQLException on prepared stmt

Throw an SQLException if a bind parameter with an invalid index
is set (via setXXX methods) on a PhoenixPreparedStatement.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/963ea0f9
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/963ea0f9
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/963ea0f9

Branch: refs/heads/3.0
Commit: 963ea0f9140244dc969da627f191d882cf2fd2f2
Parents: 12494b7
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 10:04:59 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:28:55 2014 +0200

--
 .../phoenix/jdbc/PhoenixPreparedStatement.java  | 79 +---
 .../jdbc/PhoenixPreparedStatementTest.java  | 61 +++
 2 files changed, 112 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/963ea0f9/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
index 7eea568..09fcb98 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
@@ -66,11 +66,12 @@ import org.apache.phoenix.util.SQLCloseable;
  * {@link #setTime(int, Time, Calendar)} - {@link #setTimestamp(int, 
Timestamp)} -
  * {@link #setTimestamp(int, Timestamp, Calendar)} - {@link #setNull(int, 
int)} - {@link #setNull(int, int, String)} -
  * {@link #setBytes(int, byte[])} - {@link #clearParameters()} - {@link 
#getMetaData()}
- * 
- * 
+ *
+ *
  * @since 0.1
  */
 public class PhoenixPreparedStatement extends PhoenixStatement implements 
PreparedStatement, SQLCloseable {
+private final int parameterCount;
 private final ListObject parameters;
 private final CompilableStatement statement;
 
@@ -82,6 +83,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 this.statement = parser.nextStatement(new ExecutableNodeFactory());
 if (this.statement == null) { throw new EOFException(); }
 this.query = null; // TODO: add toString on SQLStatement
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -90,6 +92,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(connection);
 this.query = query;
 this.statement = parseStatement(query);
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -98,6 +101,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(statement.connection);
 this.query = statement.query;
 this.statement = statement.statement;
+this.parameterCount = statement.parameters.size();
 this.parameters = new ArrayListObject(statement.parameters);
 }
 
@@ -107,6 +111,27 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 batch.add(new PhoenixPreparedStatement(this));
 }
 
+/**
+ * Set a bind parameter's value.
+ * @param parameterIndex 1-based index of the bind parameter to be set
+ * @param value value to be set
+ * @throws SQLException if the bind parameter index is invalid
+ */
+private void setParameter(int parameterIndex, Object value) throws 
SQLException {
+if (parameterIndex  1 || parameterIndex  parameterCount) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Can't set parameter at index  + 
parameterIndex + ,  +
+ parameterCount +  bind parameters are defined)
+.build().buildException();
+}
+if (parameterIndex  1) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Invalid bind parameter index  + 
parameterIndex)
+.build().buildException();
+}
+this.parameters.set(parameterIndex - 1, value);
+}
+
 
 @Override
 public void clearParameters() throws SQLException {
@@ -128,8 +153,8 @@ public class 

Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1254 Add REGEXP_SPLIT function



Apache-Phoenix | 4.0 | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1254 Add REGEXP_SPLIT function



Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1250 Remove use of Closeables.closeQuietly

[gabrielr] PHOENIX-1253 Throw SQLException on prepared stmt



Apache-Phoenix | 4.0 | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1250 Remove use of Closeables.closeQuietly



Apache-Phoenix | Master | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1254 Add REGEXP_SPLIT function



git commit: PHOENIX-1253 Throw SQLException on prepared stmt

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/master 3034b6583 - 486e28b58


PHOENIX-1253 Throw SQLException on prepared stmt

Throw an SQLException if a bind parameter with an invalid index
is set (via setXXX methods) on a PhoenixPreparedStatement.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/486e28b5
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/486e28b5
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/486e28b5

Branch: refs/heads/master
Commit: 486e28b5821fdce014755b695248fba995c37225
Parents: 3034b65
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 10:04:59 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:28:40 2014 +0200

--
 .../phoenix/jdbc/PhoenixPreparedStatement.java  | 79 +---
 .../jdbc/PhoenixPreparedStatementTest.java  | 61 +++
 2 files changed, 112 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/486e28b5/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
index 7eea568..09fcb98 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
@@ -66,11 +66,12 @@ import org.apache.phoenix.util.SQLCloseable;
  * {@link #setTime(int, Time, Calendar)} - {@link #setTimestamp(int, 
Timestamp)} -
  * {@link #setTimestamp(int, Timestamp, Calendar)} - {@link #setNull(int, 
int)} - {@link #setNull(int, int, String)} -
  * {@link #setBytes(int, byte[])} - {@link #clearParameters()} - {@link 
#getMetaData()}
- * 
- * 
+ *
+ *
  * @since 0.1
  */
 public class PhoenixPreparedStatement extends PhoenixStatement implements 
PreparedStatement, SQLCloseable {
+private final int parameterCount;
 private final ListObject parameters;
 private final CompilableStatement statement;
 
@@ -82,6 +83,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 this.statement = parser.nextStatement(new ExecutableNodeFactory());
 if (this.statement == null) { throw new EOFException(); }
 this.query = null; // TODO: add toString on SQLStatement
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -90,6 +92,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(connection);
 this.query = query;
 this.statement = parseStatement(query);
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -98,6 +101,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(statement.connection);
 this.query = statement.query;
 this.statement = statement.statement;
+this.parameterCount = statement.parameters.size();
 this.parameters = new ArrayListObject(statement.parameters);
 }
 
@@ -107,6 +111,27 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 batch.add(new PhoenixPreparedStatement(this));
 }
 
+/**
+ * Set a bind parameter's value.
+ * @param parameterIndex 1-based index of the bind parameter to be set
+ * @param value value to be set
+ * @throws SQLException if the bind parameter index is invalid
+ */
+private void setParameter(int parameterIndex, Object value) throws 
SQLException {
+if (parameterIndex  1 || parameterIndex  parameterCount) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Can't set parameter at index  + 
parameterIndex + ,  +
+ parameterCount +  bind parameters are defined)
+.build().buildException();
+}
+if (parameterIndex  1) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Invalid bind parameter index  + 
parameterIndex)
+.build().buildException();
+}
+this.parameters.set(parameterIndex - 1, value);
+}
+
 
 @Override
 public void clearParameters() throws SQLException {
@@ -128,8 +153,8 @@ public class 

git commit: PHOENIX-1253 Throw SQLException on prepared stmt

2014-09-17 Thread greid
Repository: phoenix
Updated Branches:
  refs/heads/4.0 89262f2be - e174793e9


PHOENIX-1253 Throw SQLException on prepared stmt

Throw an SQLException if a bind parameter with an invalid index
is set (via setXXX methods) on a PhoenixPreparedStatement.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e174793e
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e174793e
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e174793e

Branch: refs/heads/4.0
Commit: e174793e915de85e4784a6162898e3a5cc06ac10
Parents: 89262f2
Author: Gabriel Reid gabri...@ngdata.com
Authored: Tue Sep 16 10:04:59 2014 +0200
Committer: Gabriel Reid gabri...@ngdata.com
Committed: Wed Sep 17 09:28:50 2014 +0200

--
 .../phoenix/jdbc/PhoenixPreparedStatement.java  | 79 +---
 .../jdbc/PhoenixPreparedStatementTest.java  | 61 +++
 2 files changed, 112 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e174793e/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
index 7eea568..09fcb98 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
@@ -66,11 +66,12 @@ import org.apache.phoenix.util.SQLCloseable;
  * {@link #setTime(int, Time, Calendar)} - {@link #setTimestamp(int, 
Timestamp)} -
  * {@link #setTimestamp(int, Timestamp, Calendar)} - {@link #setNull(int, 
int)} - {@link #setNull(int, int, String)} -
  * {@link #setBytes(int, byte[])} - {@link #clearParameters()} - {@link 
#getMetaData()}
- * 
- * 
+ *
+ *
  * @since 0.1
  */
 public class PhoenixPreparedStatement extends PhoenixStatement implements 
PreparedStatement, SQLCloseable {
+private final int parameterCount;
 private final ListObject parameters;
 private final CompilableStatement statement;
 
@@ -82,6 +83,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 this.statement = parser.nextStatement(new ExecutableNodeFactory());
 if (this.statement == null) { throw new EOFException(); }
 this.query = null; // TODO: add toString on SQLStatement
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -90,6 +92,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(connection);
 this.query = query;
 this.statement = parseStatement(query);
+this.parameterCount = statement.getBindCount();
 this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
 Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
 }
@@ -98,6 +101,7 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 super(statement.connection);
 this.query = statement.query;
 this.statement = statement.statement;
+this.parameterCount = statement.parameters.size();
 this.parameters = new ArrayListObject(statement.parameters);
 }
 
@@ -107,6 +111,27 @@ public class PhoenixPreparedStatement extends 
PhoenixStatement implements Prepar
 batch.add(new PhoenixPreparedStatement(this));
 }
 
+/**
+ * Set a bind parameter's value.
+ * @param parameterIndex 1-based index of the bind parameter to be set
+ * @param value value to be set
+ * @throws SQLException if the bind parameter index is invalid
+ */
+private void setParameter(int parameterIndex, Object value) throws 
SQLException {
+if (parameterIndex  1 || parameterIndex  parameterCount) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Can't set parameter at index  + 
parameterIndex + ,  +
+ parameterCount +  bind parameters are defined)
+.build().buildException();
+}
+if (parameterIndex  1) {
+throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
+.setMessage(Invalid bind parameter index  + 
parameterIndex)
+.build().buildException();
+}
+this.parameters.set(parameterIndex - 1, value);
+}
+
 
 @Override
 public void clearParameters() throws SQLException {
@@ -128,8 +153,8 @@ public class 

Apache-Phoenix | Master | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1250 Remove use of Closeables.closeQuietly



Apache-Phoenix | Master | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1253 Throw SQLException on prepared stmt



Apache-Phoenix | 4.0 | Hadoop1 | Build Successful

2014-09-17 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastCompletedBuild/testReport/

Changes
[gabrielr] PHOENIX-1253 Throw SQLException on prepared stmt



Build failed in Jenkins: Phoenix | 4.0 | Hadoop2 #132

2014-09-17 Thread Apache Jenkins Server
See https://builds.apache.org/job/Phoenix-4.0-hadoop2/132/

--
[...truncated 633 lines...]
remote: Counting objects: 3571   
remote: Counting objects: 3588   
remote: Counting objects: 4046   
remote: Counting objects: 4175   
remote: Counting objects: 4202   
remote: Counting objects: 4221   
remote: Counting objects: 4279   
remote: Counting objects: 4319   
remote: Counting objects: 4325   
remote: Counting objects: 4340   
remote: Counting objects: 4399   
remote: Counting objects: 4441   
remote: Counting objects: 4492   
remote: Counting objects: 4494   
remote: Counting objects: 4501   
remote: Counting objects: 4531   
remote: Counting objects: 4569   
remote: Counting objects: 4588   
remote: Counting objects: 4599   
remote: Counting objects: 4609   
remote: Counting objects: 4615   
remote: Counting objects: 4616   
remote: Counting objects: 4639   
remote: Counting objects: 4647   
remote: Counting objects: 4681   
remote: Counting objects: 4761   
remote: Counting objects: 4811   
remote: Counting objects: 4883   
remote: Counting objects: 4890   
remote: Counting objects: 4967   
remote: Counting objects: 4986   
remote: Counting objects: 4992   
remote: Counting objects: 5044   
remote: Counting objects: 5050   
remote: Counting objects: 5129   
remote: Counting objects: 5130   
remote: Counting objects: 5132   
remote: Counting objects: 5141   
remote: Counting objects: 5146   
remote: Counting objects: 5149   
remote: Counting objects: 5156   
remote: Counting objects: 5203   
remote: Counting objects: 5205   
remote: Counting objects: 5207   
remote: Counting objects: 5214   
remote: Counting objects: 5242   
remote: Counting objects: 5264   
remote: Counting objects: 5267   
remote: Counting objects: 5281   
remote: Counting objects: 5288   
remote: Counting objects: 5307   
remote: Counting objects: 5308   
remote: Counting objects: 5315   
remote: Counting objects: 5322   
remote: Counting objects: 5339   
remote: Counting objects: 5341   
remote: Counting objects: 5347   
remote: Counting objects: 5358   
remote: Counting objects: 5371   
remote: Counting objects: 5396   
remote: Counting objects: 5440   
remote: Counting objects: 5469   
remote: Counting objects: 5499   
remote: Counting objects: 5507   
remote: Counting objects: 5517   
remote: Counting objects: 5522   
remote: Counting objects: 5534   
remote: Counting objects: 5564   
remote: Counting objects: 5568   
remote: Counting objects: 5571   
remote: Counting objects: 5575   
remote: Counting objects: 5585   
remote: Counting objects: 5597   
remote: Counting objects: 5604   
remote: Counting objects: 5606   
remote: Counting objects: 5608   
remote: Counting objects: 5622   
remote: Counting objects: 5649   
remote: Counting objects: 5661   
remote: Counting objects: 5663   
remote: Counting objects: 5664   
remote: Counting objects: 5671   
remote: Counting objects: 5684   
remote: Counting objects: 5685   
remote: Counting objects: 5690   
remote: Counting objects: 5695   
remote: Counting objects: 5696   
remote: Counting objects: 5702   
remote: Counting objects: 5703   
remote: Counting objects: 5707   
remote: Counting objects: 5735   
remote: Counting objects: 5738   
remote: Counting objects: 5742   
remote: Counting objects: 5747   
remote: Counting objects: 5748   
remote: Counting objects: 5760   
remote: Counting objects: 5764   
remote: Counting objects: 5781   
remote: Counting objects: 5796   
remote: Counting objects: 5808   
remote: Counting objects: 5811   
remote: Counting objects: 5831   
remote: Counting objects: 5853   
remote: Counting objects: 5883   
remote: Counting objects: 5929   
remote: Counting objects: 5958   
remote: Counting objects: 5971   
remote: Counting objects: 6017   
remote: Counting objects: 6086   
remote: Counting objects: 6178   
remote: Counting objects: 6198   
remote: Counting objects: 6208   
remote: Counting objects: 6256   
remote: Counting objects: 6388   
remote: Counting objects: 6584   
remote: Counting objects: 6621

Jenkins build is back to normal : Phoenix | 4.0 | Hadoop2 #133

2014-09-17 Thread Apache Jenkins Server
See https://builds.apache.org/job/Phoenix-4.0-hadoop2/133/changes



Build failed in Jenkins: Phoenix | 4.0 | Hadoop2 #135

2014-09-17 Thread Apache Jenkins Server
See https://builds.apache.org/job/Phoenix-4.0-hadoop2/135/

--
[...truncated 17979 lines...]
39 KB   66 KB   128 KB   
39 KB   66 KB   132 KB   
39 KB   69 KB   132 KB   
39 KB   69 KB   136 KB   
39 KB   69 KB   139 KB   
39 KB   69 KB   143 KB   
39 KB   69 KB   144 KB   
39 KB   69 KB   148 KB   
39 KB   69 KB   149 KB   
39 KB   73 KB   149 KB   
 
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
 (39 KB at 5521.6 KB/sec)
77 KB   149 KB   
81 KB   149 KB   
85 KB   149 KB   
89 KB   149 KB   
93 KB   149 KB   
97 KB   149 KB   
101 KB   149 KB   
105 KB   149 KB   
108 KB   149 KB   
108 KB   153 KB   
108 KB   157 KB   
108 KB   161 KB   
108 KB   165 KB   
108 KB   169 KB   
109 KB   169 KB   
109 KB   173 KB   
113 KB   173 KB   
113 KB   177 KB   
117 KB   177 KB   
117 KB   181 KB   
121 KB   181 KB   
121 KB   185 KB   
125 KB   185 KB   
125 KB   187 KB   
129 KB   187 KB   
133 KB   187 KB   
137 KB   187 KB   
141 KB   187 KB   
144 KB   187 KB   
144 KB   191 KB   
144 KB   195 KB   
144 KB   199 KB   
144 KB   203 KB   
144 KB   207 KB   
144 KB   211 KB   
144 KB   215 KB   
144 KB   219 KB   
144 KB   223 KB   
144 KB   225 KB   
144 KB   229 KB   
144 KB   233 KB   
144 KB   237 KB   
144 KB   241 KB   
144 KB   245 KB   
144 KB   249 KB   
144 KB   253 KB   
144 KB   257 KB   
144 KB   260 KB   
  
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
 (144 KB at 13077.9 KB/sec)
  
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
 (260 KB at 19936.1 KB/sec)
[INFO] Failsafe report directory: 
https://builds.apache.org/job/Phoenix-4.0-hadoop2/ws/phoenix-core/target/failsafe-reports
[INFO] parallel='none', perCoreThreadCount=true, threadCount=0, 
useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, 
threadCountMethods=0, parallelOptimized=true
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.pom
4 KB  
5 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.pom
 (5 KB at 818.6 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-providers/2.17/surefire-providers-2.17.pom
3 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-providers/2.17/surefire-providers-2.17.pom
 (3 KB at 580.6 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.pom
4 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.pom
 (4 KB at 821.5 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.pom
2 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.pom
 (2 KB at 399.2 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.pom
2 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.pom
 (2 KB at 190.9 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.pom
2 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.pom
 (2 KB at 336.9 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.pom
3 KB   
   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.pom
 (3 KB at 492.6 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
4 KB   
4 KB   4 KB   
8 KB   4 KB   
12 KB   4 KB   
16 KB   4 KB   
18 KB   4 KB   
18 KB   4 KB   4 KB   
18 KB   4 KB   8 KB   
  
8 KB   8 KB   
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
 (18 KB at 2919.3 KB/sec)
11 KB   8 KB   
4 KB   11 KB   8 KB   
4 KB   4 KB   11 KB   8 KB   
8 KB   4 KB   11 KB   8 KB   
12