Index: src/test/org/apache/hadoop/hbase/thrift/TestThriftServer.java =================================================================== --- src/test/org/apache/hadoop/hbase/thrift/TestThriftServer.java (revision 761872) +++ src/test/org/apache/hadoop/hbase/thrift/TestThriftServer.java (working copy) @@ -166,7 +166,13 @@ failed2 = true; } assertTrue(failed2); - assertNull(handler.getRow(tableAname, rowBname)); + boolean failed3 = false; + try { + handler.getRow(tableAname, rowBname); + } catch (NotFound nf) { + failed3 = true; + } + assertTrue(failed3); // Teardown handler.disableTable(tableAname); @@ -235,7 +241,13 @@ } assertTrue(failed); assertTrue(Bytes.equals(handler.get(tableAname, rowAname, columnBname).value, valueCname)); - assertNull(handler.getRow(tableAname, rowBname)); + boolean failed2 = false; + try { + handler.getRow(tableAname, rowBname); + } catch (NotFound nf) { + failed2 = true; + } + assertTrue(failed2); // Teardown handler.disableTable(tableAname); Index: src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift =================================================================== --- src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift (revision 761872) +++ src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift (working copy) @@ -275,10 +275,11 @@ * * @param tableName name of table * @param row row key - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ TRowResult getRow(1:Text tableName, 2:Text row) - throws (1:IOError io) + throws (1:IOError io, 2:NotFound nf) /** * Get the specified columns for the specified table and row at the latest @@ -287,10 +288,11 @@ * @param tableName name of table * @param row row key * @param columns List of columns to return, null for all columns - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ TRowResult getRowWithColumns(1:Text tableName, 2:Text row, 3:list columns) - throws (1:IOError io) + throws (1:IOError io, 2:NotFound nf) /** * Get all the data for the specified table and row at the specified @@ -299,10 +301,11 @@ * @param tableName of table * @param row row key * @param timestamp timestamp - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ TRowResult getRowTs(1:Text tableName, 2:Text row, 3:i64 timestamp) - throws (1:IOError io) + throws (1:IOError io, 2:NotFound nf) /** * Get the specified columns for the specified table and row at the specified @@ -311,10 +314,11 @@ * @param tableName name of table * @param row row key * @param columns List of columns to return, null for all columns - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ TRowResult getRowWithColumnsTs(1:Text tableName, 2:Text row, 3:list columns, 4:i64 timestamp) - throws (1:IOError io) + throws (1:IOError io, 2:NotFound nf) /** * Apply a series of mutations (updates/deletes) to a row in a Index: src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (revision 761872) +++ src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (working copy) @@ -251,25 +251,25 @@ } public TRowResult getRow(byte[] tableName, byte[] row) - throws IOError { + throws IOError, NotFound { return getRowWithColumnsTs(tableName, row, null, HConstants.LATEST_TIMESTAMP); } public TRowResult getRowWithColumns(byte[] tableName, byte[] row, - List columns) throws IOError { + List columns) throws IOError, NotFound { return getRowWithColumnsTs(tableName, row, columns, HConstants.LATEST_TIMESTAMP); } public TRowResult getRowTs(byte[] tableName, byte[] row, - long timestamp) throws IOError { + long timestamp) throws IOError, NotFound { return getRowWithColumnsTs(tableName, row, null, timestamp); } public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, - List columns, long timestamp) throws IOError { + List columns, long timestamp) throws IOError, NotFound { try { HTable table = getTable(tableName); if (columns == null) { Index: src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java =================================================================== --- src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java (revision 761872) +++ src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java (working copy) @@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.io.RowResult; import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor; import org.apache.hadoop.hbase.thrift.generated.IllegalArgument; +import org.apache.hadoop.hbase.thrift.generated.NotFound; import org.apache.hadoop.hbase.thrift.generated.TCell; import org.apache.hadoop.hbase.thrift.generated.TRowResult; import org.apache.hadoop.hbase.util.Bytes; @@ -98,12 +99,14 @@ * @param in * Hbase RowResult object * @return Thrift TRowResult + * @throws NotFound */ - static public TRowResult rowResultFromHBase(RowResult in) { - TRowResult result = new TRowResult(); + static public TRowResult rowResultFromHBase(RowResult in) + throws NotFound { if(in == null) { - return null; + throw new NotFound(); } + TRowResult result = new TRowResult(); result.row = in.getRow(); result.columns = new TreeMap(Bytes.BYTES_COMPARATOR); for (Map.Entry entry : in.entrySet()){ Index: src/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java =================================================================== --- src/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java (revision 761872) +++ src/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java (working copy) @@ -141,9 +141,10 @@ * * @param tableName name of table * @param row row key - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ - public TRowResult getRow(byte[] tableName, byte[] row) throws IOError, TException; + public TRowResult getRow(byte[] tableName, byte[] row) throws IOError, NotFound, TException; /** * Get the specified columns for the specified table and row at the latest @@ -152,9 +153,10 @@ * @param tableName name of table * @param row row key * @param columns List of columns to return, null for all columns - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ - public TRowResult getRowWithColumns(byte[] tableName, byte[] row, List columns) throws IOError, TException; + public TRowResult getRowWithColumns(byte[] tableName, byte[] row, List columns) throws IOError, NotFound, TException; /** * Get all the data for the specified table and row at the specified @@ -163,9 +165,10 @@ * @param tableName of table * @param row row key * @param timestamp timestamp - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ - public TRowResult getRowTs(byte[] tableName, byte[] row, long timestamp) throws IOError, TException; + public TRowResult getRowTs(byte[] tableName, byte[] row, long timestamp) throws IOError, NotFound, TException; /** * Get the specified columns for the specified table and row at the specified @@ -174,9 +177,10 @@ * @param tableName name of table * @param row row key * @param columns List of columns to return, null for all columns - * @return TRowResult containing the row and map of columns to TCells. Map is empty if row does not exist. + * @return TRowResult containing the row and map of columns to TCells + * @throws NotFound if the row does not exist */ - public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, List columns, long timestamp) throws IOError, TException; + public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, List columns, long timestamp) throws IOError, NotFound, TException; /** * Apply a series of mutations (updates/deletes) to a row in a @@ -795,7 +799,7 @@ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getVerTs failed: unknown result"); } - public TRowResult getRow(byte[] tableName, byte[] row) throws IOError, TException + public TRowResult getRow(byte[] tableName, byte[] row) throws IOError, NotFound, TException { send_getRow(tableName, row); return recv_getRow(); @@ -812,7 +816,7 @@ oprot_.getTransport().flush(); } - public TRowResult recv_getRow() throws IOError, TException + public TRowResult recv_getRow() throws IOError, NotFound, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -829,10 +833,13 @@ if (result.__isset.io) { throw result.io; } + if (result.__isset.nf) { + throw result.nf; + } throw new TApplicationException(TApplicationException.MISSING_RESULT, "getRow failed: unknown result"); } - public TRowResult getRowWithColumns(byte[] tableName, byte[] row, List columns) throws IOError, TException + public TRowResult getRowWithColumns(byte[] tableName, byte[] row, List columns) throws IOError, NotFound, TException { send_getRowWithColumns(tableName, row, columns); return recv_getRowWithColumns(); @@ -850,7 +857,7 @@ oprot_.getTransport().flush(); } - public TRowResult recv_getRowWithColumns() throws IOError, TException + public TRowResult recv_getRowWithColumns() throws IOError, NotFound, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -867,10 +874,13 @@ if (result.__isset.io) { throw result.io; } + if (result.__isset.nf) { + throw result.nf; + } throw new TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumns failed: unknown result"); } - public TRowResult getRowTs(byte[] tableName, byte[] row, long timestamp) throws IOError, TException + public TRowResult getRowTs(byte[] tableName, byte[] row, long timestamp) throws IOError, NotFound, TException { send_getRowTs(tableName, row, timestamp); return recv_getRowTs(); @@ -888,7 +898,7 @@ oprot_.getTransport().flush(); } - public TRowResult recv_getRowTs() throws IOError, TException + public TRowResult recv_getRowTs() throws IOError, NotFound, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -905,10 +915,13 @@ if (result.__isset.io) { throw result.io; } + if (result.__isset.nf) { + throw result.nf; + } throw new TApplicationException(TApplicationException.MISSING_RESULT, "getRowTs failed: unknown result"); } - public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, List columns, long timestamp) throws IOError, TException + public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, List columns, long timestamp) throws IOError, NotFound, TException { send_getRowWithColumnsTs(tableName, row, columns, timestamp); return recv_getRowWithColumnsTs(); @@ -927,7 +940,7 @@ oprot_.getTransport().flush(); } - public TRowResult recv_getRowWithColumnsTs() throws IOError, TException + public TRowResult recv_getRowWithColumnsTs() throws IOError, NotFound, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -944,6 +957,9 @@ if (result.__isset.io) { throw result.io; } + if (result.__isset.nf) { + throw result.nf; + } throw new TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumnsTs failed: unknown result"); } @@ -1803,6 +1819,9 @@ } catch (IOError io) { result.io = io; result.__isset.io = true; + } catch (NotFound nf) { + result.nf = nf; + result.__isset.nf = true; } oprot.writeMessageBegin(new TMessage("getRow", TMessageType.REPLY, seqid)); result.write(oprot); @@ -1825,6 +1844,9 @@ } catch (IOError io) { result.io = io; result.__isset.io = true; + } catch (NotFound nf) { + result.nf = nf; + result.__isset.nf = true; } oprot.writeMessageBegin(new TMessage("getRowWithColumns", TMessageType.REPLY, seqid)); result.write(oprot); @@ -1847,6 +1869,9 @@ } catch (IOError io) { result.io = io; result.__isset.io = true; + } catch (NotFound nf) { + result.nf = nf; + result.__isset.nf = true; } oprot.writeMessageBegin(new TMessage("getRowTs", TMessageType.REPLY, seqid)); result.write(oprot); @@ -1869,6 +1894,9 @@ } catch (IOError io) { result.io = io; result.__isset.io = true; + } catch (NotFound nf) { + result.nf = nf; + result.__isset.nf = true; } oprot.writeMessageBegin(new TMessage("getRowWithColumnsTs", TMessageType.REPLY, seqid)); result.write(oprot); @@ -5411,11 +5439,13 @@ public static class getRow_result implements TBase, java.io.Serializable { public TRowResult success; public IOError io; + public NotFound nf; public final Isset __isset = new Isset(); public static final class Isset implements java.io.Serializable { public boolean success = false; public boolean io = false; + public boolean nf = false; } public getRow_result() { @@ -5423,13 +5453,16 @@ public getRow_result( TRowResult success, - IOError io) + IOError io, + NotFound nf) { this(); this.success = success; this.__isset.success = true; this.io = io; this.__isset.io = true; + this.nf = nf; + this.__isset.nf = true; } public boolean equals(Object that) { @@ -5462,6 +5495,15 @@ return false; } + boolean this_present_nf = true && (this.nf != null); + boolean that_present_nf = true && (that.nf != null); + if (this_present_nf || that_present_nf) { + if (!(this_present_nf && that_present_nf)) + return false; + if (!this.nf.equals(that.nf)) + return false; + } + return true; } @@ -5498,6 +5540,15 @@ TProtocolUtil.skip(iprot, field.type); } break; + case 2: + if (field.type == TType.STRUCT) { + this.nf = new NotFound(); + this.nf.read(iprot); + this.__isset.nf = true; + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -5530,6 +5581,15 @@ this.io.write(oprot); oprot.writeFieldEnd(); } + } else if (this.__isset.nf) { + if (this.nf != null) { + field.name = "nf"; + field.type = TType.STRUCT; + field.id = 2; + oprot.writeFieldBegin(field); + this.nf.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -5541,6 +5601,8 @@ sb.append(this.success); sb.append(",io:"); sb.append(this.io); + sb.append(",nf:"); + sb.append(this.nf); sb.append(")"); return sb.toString(); } @@ -5731,11 +5793,13 @@ public static class getRowWithColumns_result implements TBase, java.io.Serializable { public TRowResult success; public IOError io; + public NotFound nf; public final Isset __isset = new Isset(); public static final class Isset implements java.io.Serializable { public boolean success = false; public boolean io = false; + public boolean nf = false; } public getRowWithColumns_result() { @@ -5743,13 +5807,16 @@ public getRowWithColumns_result( TRowResult success, - IOError io) + IOError io, + NotFound nf) { this(); this.success = success; this.__isset.success = true; this.io = io; this.__isset.io = true; + this.nf = nf; + this.__isset.nf = true; } public boolean equals(Object that) { @@ -5782,6 +5849,15 @@ return false; } + boolean this_present_nf = true && (this.nf != null); + boolean that_present_nf = true && (that.nf != null); + if (this_present_nf || that_present_nf) { + if (!(this_present_nf && that_present_nf)) + return false; + if (!this.nf.equals(that.nf)) + return false; + } + return true; } @@ -5818,6 +5894,15 @@ TProtocolUtil.skip(iprot, field.type); } break; + case 2: + if (field.type == TType.STRUCT) { + this.nf = new NotFound(); + this.nf.read(iprot); + this.__isset.nf = true; + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -5850,6 +5935,15 @@ this.io.write(oprot); oprot.writeFieldEnd(); } + } else if (this.__isset.nf) { + if (this.nf != null) { + field.name = "nf"; + field.type = TType.STRUCT; + field.id = 2; + oprot.writeFieldBegin(field); + this.nf.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -5861,6 +5955,8 @@ sb.append(this.success); sb.append(",io:"); sb.append(this.io); + sb.append(",nf:"); + sb.append(this.nf); sb.append(")"); return sb.toString(); } @@ -6033,11 +6129,13 @@ public static class getRowTs_result implements TBase, java.io.Serializable { public TRowResult success; public IOError io; + public NotFound nf; public final Isset __isset = new Isset(); public static final class Isset implements java.io.Serializable { public boolean success = false; public boolean io = false; + public boolean nf = false; } public getRowTs_result() { @@ -6045,13 +6143,16 @@ public getRowTs_result( TRowResult success, - IOError io) + IOError io, + NotFound nf) { this(); this.success = success; this.__isset.success = true; this.io = io; this.__isset.io = true; + this.nf = nf; + this.__isset.nf = true; } public boolean equals(Object that) { @@ -6084,6 +6185,15 @@ return false; } + boolean this_present_nf = true && (this.nf != null); + boolean that_present_nf = true && (that.nf != null); + if (this_present_nf || that_present_nf) { + if (!(this_present_nf && that_present_nf)) + return false; + if (!this.nf.equals(that.nf)) + return false; + } + return true; } @@ -6120,6 +6230,15 @@ TProtocolUtil.skip(iprot, field.type); } break; + case 2: + if (field.type == TType.STRUCT) { + this.nf = new NotFound(); + this.nf.read(iprot); + this.__isset.nf = true; + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -6152,6 +6271,15 @@ this.io.write(oprot); oprot.writeFieldEnd(); } + } else if (this.__isset.nf) { + if (this.nf != null) { + field.name = "nf"; + field.type = TType.STRUCT; + field.id = 2; + oprot.writeFieldBegin(field); + this.nf.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -6163,6 +6291,8 @@ sb.append(this.success); sb.append(",io:"); sb.append(this.io); + sb.append(",nf:"); + sb.append(this.nf); sb.append(")"); return sb.toString(); } @@ -6383,11 +6513,13 @@ public static class getRowWithColumnsTs_result implements TBase, java.io.Serializable { public TRowResult success; public IOError io; + public NotFound nf; public final Isset __isset = new Isset(); public static final class Isset implements java.io.Serializable { public boolean success = false; public boolean io = false; + public boolean nf = false; } public getRowWithColumnsTs_result() { @@ -6395,13 +6527,16 @@ public getRowWithColumnsTs_result( TRowResult success, - IOError io) + IOError io, + NotFound nf) { this(); this.success = success; this.__isset.success = true; this.io = io; this.__isset.io = true; + this.nf = nf; + this.__isset.nf = true; } public boolean equals(Object that) { @@ -6434,6 +6569,15 @@ return false; } + boolean this_present_nf = true && (this.nf != null); + boolean that_present_nf = true && (that.nf != null); + if (this_present_nf || that_present_nf) { + if (!(this_present_nf && that_present_nf)) + return false; + if (!this.nf.equals(that.nf)) + return false; + } + return true; } @@ -6470,6 +6614,15 @@ TProtocolUtil.skip(iprot, field.type); } break; + case 2: + if (field.type == TType.STRUCT) { + this.nf = new NotFound(); + this.nf.read(iprot); + this.__isset.nf = true; + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; default: TProtocolUtil.skip(iprot, field.type); break; @@ -6502,6 +6655,15 @@ this.io.write(oprot); oprot.writeFieldEnd(); } + } else if (this.__isset.nf) { + if (this.nf != null) { + field.name = "nf"; + field.type = TType.STRUCT; + field.id = 2; + oprot.writeFieldBegin(field); + this.nf.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -6513,6 +6675,8 @@ sb.append(this.success); sb.append(",io:"); sb.append(this.io); + sb.append(",nf:"); + sb.append(this.nf); sb.append(")"); return sb.toString(); }