phoenix git commit: PHOENIX-2142 Implement octet_length build-in function for BINARY and VARBINARY(Shuxiong Ye)

2015-08-12 Thread samarth
Repository: phoenix
Updated Branches:
  refs/heads/master c435bba8f - 274eb42d4


PHOENIX-2142 Implement octet_length build-in function for BINARY and 
VARBINARY(Shuxiong Ye)


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

Branch: refs/heads/master
Commit: 274eb42d41c3c545f28491d845ec6e0b20bdbe5b
Parents: c435bba
Author: Samarth samarth.j...@salesforce.com
Authored: Wed Aug 12 09:00:57 2015 -0700
Committer: Samarth samarth.j...@salesforce.com
Committed: Wed Aug 12 09:00:57 2015 -0700

--
 .../end2end/OctetLengthFunctionEnd2EndIT.java   | 73 
 .../phoenix/expression/ExpressionType.java  |  4 +-
 .../function/OctetLengthFunction.java   | 66 ++
 .../phoenix/schema/types/PBinaryBase.java   | 12 
 .../expression/OctetLengthFunctionTest.java | 67 ++
 5 files changed, 221 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/274eb42d/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
new file mode 100644
index 000..1239e7a
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
@@ -0,0 +1,73 @@
+/*
+ * 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 static org.apache.phoenix.util.TestUtil.closeStmtAndConn;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.apache.phoenix.expression.function.OctetLengthFunction;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * End to end tests for {@link OctetLengthFunction}
+ */
+public class OctetLengthFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
+
+private static final String KEY = key;
+
+@Before
+public void initTable() throws Exception {
+Connection conn = null;
+PreparedStatement stmt = null;
+try {
+conn = DriverManager.getConnection(getUrl());
+String ddl;
+ddl = CREATE TABLE ta (k VARCHAR NOT NULL PRIMARY KEY, b 
BINARY(4), vb VARBINARY);
+conn.createStatement().execute(ddl);
+conn.commit();
+} finally {
+closeStmtAndConn(stmt, conn);
+}
+}
+
+@Test
+public void test() throws Exception {
+Connection conn = DriverManager.getConnection(getUrl());
+PreparedStatement stmt = conn.prepareStatement(UPSERT INTO ta VALUES 
(?, ?, ?));
+stmt.setString(1, KEY);
+stmt.setBytes(2, new byte[] { 1, 2, 3, 4 });
+stmt.setBytes(3, new byte[] { 1, 2, 3, 4 });
+stmt.executeUpdate();
+conn.commit();
+ResultSet rs =
+conn.createStatement()
+.executeQuery(
+SELECT OCTET_LENGTH(vb), OCTET_LENGTH(b) FROM ta 
WHERE OCTET_LENGTH(vb)=4 and OCTET_LENGTH(b)=4);
+assertTrue(rs.next());
+assertEquals(4, rs.getInt(1));
+assertEquals(4, rs.getInt(2));
+assertTrue(!rs.next());
+}
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/274eb42d/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
index 5dbab69..dbe2509 100644
--- 

phoenix git commit: PHOENIX-2142 Implement octet_length build-in function for BINARY and VARBINARY(Shuxiong Ye)

2015-08-12 Thread samarth
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 e1c92a2a1 - 55f2d61ea


PHOENIX-2142 Implement octet_length build-in function for BINARY and 
VARBINARY(Shuxiong Ye)


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

Branch: refs/heads/4.x-HBase-1.0
Commit: 55f2d61ea996daf64c0759b0047e4dbd4ed4bbf9
Parents: e1c92a2
Author: Samarth samarth.j...@salesforce.com
Authored: Wed Aug 12 09:04:30 2015 -0700
Committer: Samarth samarth.j...@salesforce.com
Committed: Wed Aug 12 09:04:30 2015 -0700

--
 .../end2end/OctetLengthFunctionEnd2EndIT.java   | 73 
 .../phoenix/expression/ExpressionType.java  |  4 +-
 .../function/OctetLengthFunction.java   | 66 ++
 .../phoenix/schema/types/PBinaryBase.java   | 12 
 .../expression/OctetLengthFunctionTest.java | 67 ++
 5 files changed, 221 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/55f2d61e/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
new file mode 100644
index 000..1239e7a
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
@@ -0,0 +1,73 @@
+/*
+ * 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 static org.apache.phoenix.util.TestUtil.closeStmtAndConn;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.apache.phoenix.expression.function.OctetLengthFunction;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * End to end tests for {@link OctetLengthFunction}
+ */
+public class OctetLengthFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
+
+private static final String KEY = key;
+
+@Before
+public void initTable() throws Exception {
+Connection conn = null;
+PreparedStatement stmt = null;
+try {
+conn = DriverManager.getConnection(getUrl());
+String ddl;
+ddl = CREATE TABLE ta (k VARCHAR NOT NULL PRIMARY KEY, b 
BINARY(4), vb VARBINARY);
+conn.createStatement().execute(ddl);
+conn.commit();
+} finally {
+closeStmtAndConn(stmt, conn);
+}
+}
+
+@Test
+public void test() throws Exception {
+Connection conn = DriverManager.getConnection(getUrl());
+PreparedStatement stmt = conn.prepareStatement(UPSERT INTO ta VALUES 
(?, ?, ?));
+stmt.setString(1, KEY);
+stmt.setBytes(2, new byte[] { 1, 2, 3, 4 });
+stmt.setBytes(3, new byte[] { 1, 2, 3, 4 });
+stmt.executeUpdate();
+conn.commit();
+ResultSet rs =
+conn.createStatement()
+.executeQuery(
+SELECT OCTET_LENGTH(vb), OCTET_LENGTH(b) FROM ta 
WHERE OCTET_LENGTH(vb)=4 and OCTET_LENGTH(b)=4);
+assertTrue(rs.next());
+assertEquals(4, rs.getInt(1));
+assertEquals(4, rs.getInt(2));
+assertTrue(!rs.next());
+}
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/55f2d61e/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
index bbd02be..1af0ee4 100644
--- 

phoenix git commit: PHOENIX-2142 Implement octet_length build-in function for BINARY and VARBINARY(Shuxiong Ye)

2015-08-12 Thread samarth
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 2114f8180 - 71eb9e656


PHOENIX-2142 Implement octet_length build-in function for BINARY and 
VARBINARY(Shuxiong Ye)


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 71eb9e656e7b74d1509f0c77d125ae4dedf0e5c3
Parents: 2114f81
Author: Samarth samarth.j...@salesforce.com
Authored: Wed Aug 12 09:03:03 2015 -0700
Committer: Samarth samarth.j...@salesforce.com
Committed: Wed Aug 12 09:03:03 2015 -0700

--
 .../end2end/OctetLengthFunctionEnd2EndIT.java   | 73 
 .../phoenix/expression/ExpressionType.java  |  4 +-
 .../function/OctetLengthFunction.java   | 66 ++
 .../phoenix/schema/types/PBinaryBase.java   | 12 
 .../expression/OctetLengthFunctionTest.java | 67 ++
 5 files changed, 221 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/71eb9e65/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
new file mode 100644
index 000..1239e7a
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java
@@ -0,0 +1,73 @@
+/*
+ * 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 static org.apache.phoenix.util.TestUtil.closeStmtAndConn;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.apache.phoenix.expression.function.OctetLengthFunction;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * End to end tests for {@link OctetLengthFunction}
+ */
+public class OctetLengthFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
+
+private static final String KEY = key;
+
+@Before
+public void initTable() throws Exception {
+Connection conn = null;
+PreparedStatement stmt = null;
+try {
+conn = DriverManager.getConnection(getUrl());
+String ddl;
+ddl = CREATE TABLE ta (k VARCHAR NOT NULL PRIMARY KEY, b 
BINARY(4), vb VARBINARY);
+conn.createStatement().execute(ddl);
+conn.commit();
+} finally {
+closeStmtAndConn(stmt, conn);
+}
+}
+
+@Test
+public void test() throws Exception {
+Connection conn = DriverManager.getConnection(getUrl());
+PreparedStatement stmt = conn.prepareStatement(UPSERT INTO ta VALUES 
(?, ?, ?));
+stmt.setString(1, KEY);
+stmt.setBytes(2, new byte[] { 1, 2, 3, 4 });
+stmt.setBytes(3, new byte[] { 1, 2, 3, 4 });
+stmt.executeUpdate();
+conn.commit();
+ResultSet rs =
+conn.createStatement()
+.executeQuery(
+SELECT OCTET_LENGTH(vb), OCTET_LENGTH(b) FROM ta 
WHERE OCTET_LENGTH(vb)=4 and OCTET_LENGTH(b)=4);
+assertTrue(rs.next());
+assertEquals(4, rs.getInt(1));
+assertEquals(4, rs.getInt(2));
+assertTrue(!rs.next());
+}
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/71eb9e65/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ExpressionType.java
index 2089b6c..07f3bdd 100644
---