You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/01/02 18:42:30 UTC
[03/10] git commit: ACCUMULO-1993 ACCUMULO-1994 make proxy useful for
ruby, fix getRowRange (and test it)
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.6.0-SNAPSHOT
Commit: 27ee2367056e5ad0cb6175f91154cd13d49e2c95
Parents: 0b6749a
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:00 2014 -0500
Committer: Eric Newton <er...@gmail.com>
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();