Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8FECB10504 for ; Thu, 2 Jan 2014 17:47:06 +0000 (UTC) Received: (qmail 55473 invoked by uid 500); 2 Jan 2014 17:43:25 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 55171 invoked by uid 500); 2 Jan 2014 17:42:49 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 54860 invoked by uid 99); 2 Jan 2014 17:42:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jan 2014 17:42:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 50C75914037; Thu, 2 Jan 2014 17:42:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ecn@apache.org To: commits@accumulo.apache.org Date: Thu, 02 Jan 2014 17:42:28 -0000 Message-Id: <3b5353e33daa492e84ff5c1c28118e83@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/10] git commit: ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it) Updated Branches: refs/heads/1.4.5-SNAPSHOT 0b6749a4f -> 27ee23670 refs/heads/1.5.1-SNAPSHOT 712e946d1 -> 8729dba76 refs/heads/1.6.0-SNAPSHOT 417902e21 -> a95831a20 ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it) Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27ee2367 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27ee2367 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27ee2367 Branch: refs/heads/1.4.5-SNAPSHOT Commit: 27ee2367056e5ad0cb6175f91154cd13d49e2c95 Parents: 0b6749a Author: Eric Newton Authored: Thu Jan 2 12:02:00 2014 -0500 Committer: Eric Newton Committed: Thu Jan 2 12:02:00 2014 -0500 ---------------------------------------------------------------------- src/proxy/examples/python/TestClient.py | 4 ++-- src/proxy/examples/ruby/test_client.rb | 8 ++++---- .../org/apache/accumulo/proxy/ProxyServer.java | 6 ++---- .../org/apache/accumulo/proxy/thrift/Key.java | 6 ++++-- src/proxy/src/main/thrift/proxy.thrift | 4 +++- .../org/apache/accumulo/proxy/SimpleTest.java | 20 ++++++++++++++++++++ 6 files changed, 35 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/python/TestClient.py ---------------------------------------------------------------------- diff --git a/src/proxy/examples/python/TestClient.py b/src/proxy/examples/python/TestClient.py index 7ecf367..5509ded 100644 --- a/src/proxy/examples/python/TestClient.py +++ b/src/proxy/examples/python/TestClient.py @@ -21,8 +21,8 @@ from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TCompactProtocol -from proxy import AccumuloProxy -from proxy.ttypes import * +from accumulo import AccumuloProxy +from accumulo.ttypes import * transport = TSocket.TSocket('localhost', 42424) transport = TTransport.TFramedTransport(transport) http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/ruby/test_client.rb ---------------------------------------------------------------------- diff --git a/src/proxy/examples/ruby/test_client.rb b/src/proxy/examples/ruby/test_client.rb index d5ee5f5..6310a2f 100644 --- a/src/proxy/examples/ruby/test_client.rb +++ b/src/proxy/examples/ruby/test_client.rb @@ -23,7 +23,7 @@ server = ARGV[0] || 'localhost' socket = Thrift::Socket.new(server, 42424, 9001) transport = Thrift::FramedTransport.new(socket) proto = Thrift::CompactProtocol.new(transport) -proxy = AccumuloProxy::Client.new(proto) +proxy = Accumulo::AccumuloProxy::Client.new(proto) # open up the connect transport.open() @@ -35,10 +35,10 @@ login = proxy.login('root', {'password' => 'secret'}) puts "List of tables: #{proxy.listTables(login).inspect}" testtable = "rubytest" -proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) +proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) -update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"}) -update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"}) +update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"}) +update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"}) proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]}) cookie = proxy.createScanner(login,testtable,nil) http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java ---------------------------------------------------------------------- diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java index d749723..bf050e4 100644 --- a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java +++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java @@ -1328,6 +1328,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility())); + result.setTimestamp(k.getTimestamp()); return result; } @@ -1346,12 +1347,9 @@ public class ProxyServer implements AccumuloProxy.Iface { } } - static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {}); - @Override public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException { - return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true, - new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true); + return getRange(new Range(ByteBufferUtil.toText(row))); } @Override http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java ---------------------------------------------------------------------- diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java index 5d8a31c..422149c 100644 --- a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java +++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java @@ -143,6 +143,8 @@ import org.slf4j.LoggerFactory; } public Key() { + this.timestamp = 9223372036854775807L; + } public Key( @@ -193,8 +195,8 @@ import org.slf4j.LoggerFactory; this.colFamily = null; this.colQualifier = null; this.colVisibility = null; - setTimestampIsSet(false); - this.timestamp = 0; + this.timestamp = 9223372036854775807L; + } public byte[] getRow() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/thrift/proxy.thrift ---------------------------------------------------------------------- diff --git a/src/proxy/src/main/thrift/proxy.thrift b/src/proxy/src/main/thrift/proxy.thrift index 1cebf55..872e253 100644 --- a/src/proxy/src/main/thrift/proxy.thrift +++ b/src/proxy/src/main/thrift/proxy.thrift @@ -16,13 +16,15 @@ */ namespace cpp accumulo namespace java org.apache.accumulo.proxy.thrift +namespace rb Accumulo +namespace py accumulo struct Key { 1:binary row; 2:binary colFamily; 3:binary colQualifier; 4:binary colVisibility; - 5:optional i64 timestamp + 5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF } enum PartialKey { http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java ---------------------------------------------------------------------- diff --git a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java index d3b45ae..67b36a6 100644 --- a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java +++ b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java @@ -798,6 +798,26 @@ public class SimpleTest { return toRet; } + static private ByteBuffer t2bb(Text t) { + return ByteBuffer.wrap(t.getBytes()); + } + + @Test + public void testGetRowRange() throws Exception { + Range range = client.getRowRange(s2bb("xyzzy")); + org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); + assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow()))); + assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow()))); + assertEquals(range.startInclusive, range2.isStartKeyInclusive()); + assertEquals(range.stopInclusive, range2.isEndKeyInclusive()); + assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily()))); + assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier()))); + assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily()))); + assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier()))); + assertEquals(range.start.timestamp, range.start.timestamp); + assertEquals(range.stop.timestamp, range.stop.timestamp); + } + @AfterClass public static void tearDownMiniCluster() throws Exception { accumulo.stop();