[ 
https://issues.apache.org/jira/browse/HBASE-4811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13627551#comment-13627551
 ] 

Liang Xie commented on HBASE-4811:
----------------------------------

Previous HBase-4811-0.94.3modified.txt didn't have a backward-compatibility, we 
can bump a SCAN version, like HBASE-6250's style:

e.g.:
{code} 
--- main/java/org/apache/hadoop/hbase/client/Scan.java  (revision 88835)
+++ main/java/org/apache/hadoop/hbase/client/Scan.java  (working copy)
@@ -85,6 +85,7 @@
   private static final String ISOLATION_LEVEL = "_isolationlevel_";
 
   private static final byte SCAN_VERSION = (byte)2;
+  private static final byte SCAN_REVERSED_VERSION = (byte)3;
   private byte [] startRow = HConstants.EMPTY_START_ROW;
   private byte [] stopRow  = HConstants.EMPTY_END_ROW;
   private int maxVersions = 1;
@@ -577,7 +578,7 @@
   public void readFields(final DataInput in)
   throws IOException {
     int version = in.readByte();
-    if (version > (int)SCAN_VERSION) {
+    if (version > SCAN_REVERSED_VERSION) {
       throw new IOException("version not supported");
     }
     this.startRow = Bytes.readByteArray(in);
@@ -586,7 +587,9 @@
     this.batch = in.readInt();
     this.caching = in.readInt();
     this.cacheBlocks = in.readBoolean();
-    this.reverse = in.readBoolean();
+    if (version >= SCAN_REVERSED_VERSION) {
+      this.reverse = in.readBoolean();
+    }
     if(in.readBoolean()) {
       this.filter = 
(Filter)createForName(Bytes.toString(Bytes.readByteArray(in)));
       this.filter.readFields(in);
@@ -614,14 +617,20 @@
 
   public void write(final DataOutput out)
   throws IOException {
-    out.writeByte(SCAN_VERSION);
+    if (reverse) {
+      out.writeByte(SCAN_REVERSED_VERSION);
+    } else {
+      out.writeByte(SCAN_VERSION);
+    }
     Bytes.writeByteArray(out, this.startRow);
     Bytes.writeByteArray(out, this.stopRow);
     out.writeInt(this.maxVersions);
     out.writeInt(this.batch);
     out.writeInt(this.caching);
     out.writeBoolean(this.cacheBlocks);
-    out.writeBoolean(this.reverse);
+    if (reverse) {    
+      out.writeBoolean(this.reverse);
+    }
     if(this.filter == null) {
       out.writeBoolean(false);
     } else {
{code} 
                
> Support reverse Scan
> --------------------
>
>                 Key: HBASE-4811
>                 URL: https://issues.apache.org/jira/browse/HBASE-4811
>             Project: HBase
>          Issue Type: Improvement
>          Components: Client
>    Affects Versions: 0.20.6
>            Reporter: John Carrino
>         Attachments: HBase-4811-0.94.3modified.txt
>
>
> All the documentation I find about HBase says that if you want forward and 
> reverse scans you should just build 2 tables and one be ascending and one 
> descending.  Is there a fundamental reason that HBase only supports forward 
> Scan?  It seems like a lot of extra space overhead and coding overhead (to 
> keep them in sync) to support 2 tables.  
> I am assuming this has been discussed before, but I can't find the 
> discussions anywhere about it or why it would be infeasible.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to