hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r780334 - in /hadoop/hbase/trunk: CHANGES.txt src/examples/thrift/DemoClient.py
Date Sat, 30 May 2009 21:44:47 GMT
Author: stack
Date: Sat May 30 21:44:46 2009
New Revision: 780334

URL: http://svn.apache.org/viewvc?rev=780334&view=rev
Log:
HBASE-1455 Update DemoClient.py for thrift 1.0

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/examples/thrift/DemoClient.py

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=780334&r1=780333&r2=780334&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Sat May 30 21:44:46 2009
@@ -289,6 +289,7 @@
    HBASE-1454  HBaseAdmin.getClusterStatus
    HBASE-1236  Improve readability of table descriptions in the UI
                (Lars George and Alex Newman via Stack)
+   HBASE-1455  Update DemoClient.py for thrift 1.0 (Tim Sell via Stack)
 
   OPTIMIZATIONS
    HBASE-1412  Change values for delete column and column family in KeyValue

Modified: hadoop/hbase/trunk/src/examples/thrift/DemoClient.py
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/examples/thrift/DemoClient.py?rev=780334&r1=780333&r2=780334&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/examples/thrift/DemoClient.py (original)
+++ hadoop/hbase/trunk/src/examples/thrift/DemoClient.py Sat May 30 21:44:46 2009
@@ -106,20 +106,21 @@
 valid = "foo-\xE7\x94\x9F\xE3\x83\x93\xE3\x83\xBC\xE3\x83\xAB";
 
 # non-utf8 is fine for data
-mutations = [Mutation({"column":"entry:foo", "value":invalid})]
+mutations = [Mutation(column="entry:foo",value=invalid)]
+print str(mutations)
 client.mutateRow(t, "foo", mutations)
 
 # try empty strings
-mutations = [Mutation({"column":"entry:", "value":""})]
+mutations = [Mutation(column="entry:", value="")]
 client.mutateRow(t, "", mutations)
 
 # this row name is valid utf8
-mutations = [Mutation({"column":"entry:foo", "value":valid})]
+mutations = [Mutation(column="entry:foo", value=valid)]
 client.mutateRow(t, valid, mutations)
 
 # non-utf8 is not allowed in row names
 try:
-  mutations = [Mutation({"column":"entry:foo", "value":invalid})]
+  mutations = [Mutation(column="entry:foo", value=invalid)]
   client.mutateRow(t, invalid, mutations)
 except ttypes.IOError, e:
   print 'expected exception: %s' %(e.message)
@@ -127,11 +128,12 @@
 # Run a scanner on the rows we just created
 print "Starting scanner..."
 scanner = client.scannerOpen(t, "", ["entry:"])
-try:
-  while 1:
-    printRow(client.scannerGet(scanner))
-except ttypes.NotFound, e:
-  print "Scanner finished"
+
+r = client.scannerGet(scanner)
+while r:
+  printRow(r[0])
+  r = client.scannerGet(scanner)
+print "Scanner finished"
 
 #
 # Run some operations on a bunch of rows.
@@ -140,46 +142,32 @@
     # format row keys as "00000" to "00100"
   row = "%0.5d" % (e)
 
-  mutations = [Mutation({"column":"unused:", "value":"DELETE_ME"})]
+  mutations = [Mutation(column="unused:", value="DELETE_ME")]
   client.mutateRow(t, row, mutations)
-  printRow(client.getRow(t, row))
+  printRow(client.getRow(t, row)[0])
   client.deleteAllRow(t, row)
 
-  mutations = [Mutation({"column":"entry:num", "value":"0"}),
-               Mutation({"column":"entry:foo", "value":"FOO"})]
+  mutations = [Mutation(column="entry:num", value="0"),
+               Mutation(column="entry:foo", value="FOO")]
   client.mutateRow(t, row, mutations)
-  printRow(client.getRow(t, row));
+  printRow(client.getRow(t, row)[0]);
 
-  mutations = []
-  m = Mutation()
-  m.column = "entry:foo"
-  m.isDelete = 1
-  mutations.append(m)
-  m = Mutation()
-  m.column = "entry:num"
-  m.value = "-1"
-  mutations.append(m)
+  mutations = [Mutation(column="entry:foo",isDelete=True),
+               Mutation(column="entry:num",value="-1")]
   client.mutateRow(t, row, mutations)
-  printRow(client.getRow(t, row))
+  printRow(client.getRow(t, row)[0])
 
-  mutations = [Mutation({"column":"entry:num", "value":str(e)}),
-               Mutation({"column":"entry:sqr", "value":str(e*e)})]
+  mutations = [Mutation(column="entry:num", value=str(e)),
+               Mutation(column="entry:sqr", value=str(e*e))]
   client.mutateRow(t, row, mutations)
-  printRow(client.getRow(t, row));
+  printRow(client.getRow(t, row)[0])
 
   time.sleep(0.05)
 
-  mutations = []
-  m = Mutation()
-  m.column = "entry:num"
-  m.value = "-999"
-  mutations.append(m)
-  m = Mutation()
-  m.column = "entry:sqr"
-  m.isDelete = 1
-  mutations.append(m)
+  mutations = [Mutation(column="entry:num",value="-999"),
+               Mutation(column="entry:sqr",isDelete=True)]
   client.mutateRowTs(t, row, mutations, 1) # shouldn't override latest
-  printRow(client.getRow(t, row))
+  printRow(client.getRow(t, row)[0])
 
   versions = client.getVer(t, row, "entry:num", 10)
   printVersions(row, versions)
@@ -187,13 +175,12 @@
     print("FATAL: wrong # of versions")
     sys.exit(-1)
 
-  try:
-    client.get(t, row, "entry:foo")
+  r = client.get(t, row, "entry:foo")
+  if not r:
+    print "yup, we didn't find entry:foo"
+  # just to be explicit, we get lists back, if it's empty there was no matching row.
+  if len(r) > 0:
     raise "shouldn't get here!"
-  except ttypes.NotFound, e:
-	pass
-
-  print
 
 columnNames = []
 for (col, desc) in client.getColumnDescriptors(t).items():
@@ -203,11 +190,13 @@
 
 print "Starting scanner..."
 scanner = client.scannerOpenWithStop(t, "00020", "00040", columnNames)
-try:
-  while 1:
-    printRow(client.scannerGet(scanner))
-except ttypes.NotFound:
-  client.scannerClose(scanner)
-  print "Scanner finished"
+
+r = client.scannerGet(scanner)
+while r:
+  printRow(r[0])
+  r = client.scannerGet(scanner)
+
+client.scannerClose(scanner)
+print "Scanner finished"
 
 transport.close()



Mime
View raw message