Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 10835200BC0 for ; Tue, 15 Nov 2016 19:49:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0F2FF160B1E; Tue, 15 Nov 2016 18:49:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1754B160B05 for ; Tue, 15 Nov 2016 19:49:14 +0100 (CET) Received: (qmail 88674 invoked by uid 500); 15 Nov 2016 18:49:12 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 88069 invoked by uid 99); 15 Nov 2016 18:49:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2016 18:49:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5D45DFE5C; Tue, 15 Nov 2016 18:49:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: stack@apache.org To: commits@hbase.apache.org Date: Tue, 15 Nov 2016 18:49:23 -0000 Message-Id: <996db332a87243a5b8cde6c0e6b4825e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/52] [partial] hbase-site git commit: Published site at 4d1bff9e78884adf689dd587d65afe36a336c56b. archived-at: Tue, 15 Nov 2016 18:49:17 -0000 http://git-wip-us.apache.org/repos/asf/hbase-site/blob/86fde03b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBuffKeyValueDecoder.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBuffKeyValueDecoder.html b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBuffKeyValueDecoder.html new file mode 100644 index 0000000..ee41b19 --- /dev/null +++ b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBuffKeyValueDecoder.html @@ -0,0 +1,263 @@ + + + +Source code + + + +
+
001/**
+002 * Licensed to the Apache Software Foundation (ASF) under one
+003 * or more contributor license agreements.  See the NOTICE file
+004 * distributed with this work for additional information
+005 * regarding copyright ownership.  The ASF licenses this file
+006 * to you under the Apache License, Version 2.0 (the
+007 * "License"); you may not use this file except in compliance
+008 * with the License.  You may obtain a copy of the License at
+009 *
+010 *     http://www.apache.org/licenses/LICENSE-2.0
+011 *
+012 * Unless required by applicable law or agreed to in writing, software
+013 * distributed under the License is distributed on an "AS IS" BASIS,
+014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+015 * See the License for the specific language governing permissions and
+016 * limitations under the License.
+017 */
+018package org.apache.hadoop.hbase.codec;
+019
+020import java.io.IOException;
+021import java.io.InputStream;
+022import java.io.OutputStream;
+023import java.nio.ByteBuffer;
+024
+025import org.apache.hadoop.hbase.Cell;
+026import org.apache.hadoop.hbase.HBaseInterfaceAudience;
+027import org.apache.hadoop.hbase.KeyValue;
+028import org.apache.hadoop.hbase.KeyValueUtil;
+029import org.apache.hadoop.hbase.NoTagsKeyValue;
+030import org.apache.hadoop.hbase.OffheapKeyValue;
+031import org.apache.hadoop.hbase.ShareableMemory;
+032import org.apache.hadoop.hbase.classification.InterfaceAudience;
+033import org.apache.hadoop.hbase.nio.ByteBuff;
+034import org.apache.hadoop.hbase.util.ByteBufferUtils;
+035import org.apache.hadoop.hbase.util.Bytes;
+036
+037/**
+038 * Codec that does KeyValue version 1 serialization.
+039 * 
+040 * <p>Encodes Cell as serialized in KeyValue with total length prefix.
+041 * This is how KVs were serialized in Puts, Deletes and Results pre-0.96.  Its what would
+042 * happen if you called the Writable#write KeyValue implementation.  This encoder will fail
+043 * if the passed Cell is not an old-school pre-0.96 KeyValue.  Does not copy bytes writing.
+044 * It just writes them direct to the passed stream.
+045 *
+046 * <p>If you wrote two KeyValues to this encoder, it would look like this in the stream:
+047 * <pre>
+048 * length-of-KeyValue1 // A java int with the length of KeyValue1 backing array
+049 * KeyValue1 backing array filled with a KeyValue serialized in its particular format
+050 * length-of-KeyValue2
+051 * KeyValue2 backing array
+052 * </pre>
+053 */
+054@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
+055public class KeyValueCodec implements Codec {
+056  public static class KeyValueEncoder extends BaseEncoder {
+057    public KeyValueEncoder(final OutputStream out) {
+058      super(out);
+059    }
+060
+061    @Override
+062    public void write(Cell cell) throws IOException {
+063      checkFlushed();
+064      // Do not write tags over RPC
+065      ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, false));
+066      KeyValueUtil.oswrite(cell, out, false);
+067    }
+068  }
+069
+070  public static class KeyValueDecoder extends BaseDecoder {
+071    public KeyValueDecoder(final InputStream in) {
+072      super(in);
+073    }
+074
+075    protected Cell parseCell() throws IOException {
+076      // No tags here
+077      return KeyValueUtil.iscreate(in, false);
+078    }
+079  }
+080
+081  public static class ByteBuffKeyValueDecoder implements Codec.Decoder {
+082
+083    protected final ByteBuff buf;
+084    protected Cell current = null;
+085
+086    public ByteBuffKeyValueDecoder(ByteBuff buf) {
+087      this.buf = buf;
+088    }
+089
+090    @Override
+091    public boolean advance() throws IOException {
+092      if (!this.buf.hasRemaining()) {
+093        return false;
+094      }
+095      int len = buf.getInt();
+096      ByteBuffer bb = buf.asSubByteBuffer(len);
+097      if (bb.isDirect()) {
+098        this.current = createCell(bb, bb.position(), len);
+099      } else {
+100        this.current = createCell(bb.array(), bb.arrayOffset() + bb.position(), len);
+101      }
+102      buf.skip(len);
+103      return true;
+104    }
+105
+106    @Override
+107    public Cell current() {
+108      return this.current;
+109    }
+110
+111    protected Cell createCell(byte[] buf, int offset, int len) {
+112      return new ShareableMemoryNoTagsKeyValue(buf, offset, len);
+113    }
+114
+115    protected Cell createCell(ByteBuffer bb, int pos, int len) {
+116      // We know there is not going to be any tags.
+117      return new ShareableMemoryOffheapKeyValue(bb, pos, len, false, 0);
+118    }
+119
+120    static class ShareableMemoryKeyValue extends KeyValue implements ShareableMemory {
+121      public ShareableMemoryKeyValue(byte[] bytes, int offset, int length) {
+122        super(bytes, offset, length);
+123      }
+124
+125      @Override
+126      public Cell cloneToCell() {
+127        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
+128        KeyValue kv = new KeyValue(copy, 0, copy.length);
+129        kv.setSequenceId(this.getSequenceId());
+130        return kv;
+131      }
+132    }
+133
+134    static class ShareableMemoryNoTagsKeyValue extends NoTagsKeyValue implements ShareableMemory {
+135      public ShareableMemoryNoTagsKeyValue(byte[] bytes, int offset, int length) {
+136        super(bytes, offset, length);
+137      }
+138
+139      @Override
+140      public Cell cloneToCell() {
+141        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
+142        KeyValue kv = new NoTagsKeyValue(copy, 0, copy.length);
+143        kv.setSequenceId(this.getSequenceId());
+144        return kv;
+145      }
+146    }
+147
+148    static class ShareableMemoryOffheapKeyValue extends OffheapKeyValue implements ShareableMemory {
+149      public ShareableMemoryOffheapKeyValue(ByteBuffer buf, int offset, int length) {
+150        super(buf, offset, length);
+151      }
+152
+153      public ShareableMemoryOffheapKeyValue(ByteBuffer buf, int offset, int length, boolean hasTags,
+154          long seqId) {
+155        super(buf, offset, length, hasTags, seqId);
+156      }
+157
+158      @Override
+159      public Cell cloneToCell() {
+160        byte[] copy = new byte[this.length];
+161        ByteBufferUtils.copyFromBufferToArray(copy, this.buf, this.offset, 0, this.length);
+162        KeyValue kv;
+163        if (this.hasTags) {
+164          kv = new KeyValue(copy, 0, copy.length);
+165        } else {
+166          kv = new NoTagsKeyValue(copy, 0, copy.length);
+167        }
+168        kv.setSequenceId(this.getSequenceId());
+169        return kv;
+170      }
+171    }
+172  }
+173
+174  /**
+175   * Implementation depends on {@link InputStream#available()}
+176   */
+177  @Override
+178  public Decoder getDecoder(final InputStream is) {
+179    return new KeyValueDecoder(is);
+180  }
+181
+182  @Override
+183  public Decoder getDecoder(ByteBuff buf) {
+184    return new ByteBuffKeyValueDecoder(buf);
+185  }
+186
+187  @Override
+188  public Encoder getEncoder(OutputStream os) {
+189    return new KeyValueEncoder(os);
+190  }
+191}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + http://git-wip-us.apache.org/repos/asf/hbase-site/blob/86fde03b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryKeyValue.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryKeyValue.html b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryKeyValue.html deleted file mode 100644 index a6ce21d..0000000 --- a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryKeyValue.html +++ /dev/null @@ -1,227 +0,0 @@ - - - -Source code - - - -
-
001/**
-002 * Licensed to the Apache Software Foundation (ASF) under one
-003 * or more contributor license agreements.  See the NOTICE file
-004 * distributed with this work for additional information
-005 * regarding copyright ownership.  The ASF licenses this file
-006 * to you under the Apache License, Version 2.0 (the
-007 * "License"); you may not use this file except in compliance
-008 * with the License.  You may obtain a copy of the License at
-009 *
-010 *     http://www.apache.org/licenses/LICENSE-2.0
-011 *
-012 * Unless required by applicable law or agreed to in writing, software
-013 * distributed under the License is distributed on an "AS IS" BASIS,
-014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-015 * See the License for the specific language governing permissions and
-016 * limitations under the License.
-017 */
-018package org.apache.hadoop.hbase.codec;
-019
-020import java.io.IOException;
-021import java.io.InputStream;
-022import java.io.OutputStream;
-023import java.nio.ByteBuffer;
-024
-025import org.apache.hadoop.hbase.Cell;
-026import org.apache.hadoop.hbase.HBaseInterfaceAudience;
-027import org.apache.hadoop.hbase.KeyValue;
-028import org.apache.hadoop.hbase.KeyValueUtil;
-029import org.apache.hadoop.hbase.NoTagsKeyValue;
-030import org.apache.hadoop.hbase.ShareableMemory;
-031import org.apache.hadoop.hbase.classification.InterfaceAudience;
-032import org.apache.hadoop.hbase.util.ByteBufferUtils;
-033import org.apache.hadoop.hbase.util.Bytes;
-034
-035/**
-036 * Codec that does KeyValue version 1 serialization.
-037 * 
-038 * <p>Encodes Cell as serialized in KeyValue with total length prefix.
-039 * This is how KVs were serialized in Puts, Deletes and Results pre-0.96.  Its what would
-040 * happen if you called the Writable#write KeyValue implementation.  This encoder will fail
-041 * if the passed Cell is not an old-school pre-0.96 KeyValue.  Does not copy bytes writing.
-042 * It just writes them direct to the passed stream.
-043 *
-044 * <p>If you wrote two KeyValues to this encoder, it would look like this in the stream:
-045 * <pre>
-046 * length-of-KeyValue1 // A java int with the length of KeyValue1 backing array
-047 * KeyValue1 backing array filled with a KeyValue serialized in its particular format
-048 * length-of-KeyValue2
-049 * KeyValue2 backing array
-050 * </pre>
-051 */
-052@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
-053public class KeyValueCodec implements Codec {
-054  public static class KeyValueEncoder extends BaseEncoder {
-055    public KeyValueEncoder(final OutputStream out) {
-056      super(out);
-057    }
-058
-059    @Override
-060    public void write(Cell cell) throws IOException {
-061      checkFlushed();
-062      // Do not write tags over RPC
-063      ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, false));
-064      KeyValueUtil.oswrite(cell, out, false);
-065    }
-066  }
-067
-068  public static class KeyValueDecoder extends BaseDecoder {
-069    public KeyValueDecoder(final InputStream in) {
-070      super(in);
-071    }
-072
-073    protected Cell parseCell() throws IOException {
-074      // No tags here
-075      return KeyValueUtil.iscreate(in, false);
-076    }
-077  }
-078
-079  public static class ByteBufferedKeyValueDecoder implements Codec.Decoder {
-080
-081    protected final ByteBuffer buf;
-082    protected Cell current = null;
-083
-084    public ByteBufferedKeyValueDecoder(ByteBuffer buf) {
-085      this.buf = buf;
-086    }
-087
-088    @Override
-089    public boolean advance() throws IOException {
-090      if (this.buf.remaining() <= 0) {
-091        return false;
-092      }
-093      int len = ByteBufferUtils.toInt(buf);
-094      assert buf.hasArray();
-095      this.current = createCell(buf.array(), buf.arrayOffset() + buf.position(), len);
-096      buf.position(buf.position() + len);
-097      return true;
-098    }
-099
-100    @Override
-101    public Cell current() {
-102      return this.current;
-103    }
-104
-105    protected Cell createCell(byte[] buf, int offset, int len) {
-106      return new ShareableMemoryNoTagsKeyValue(buf, offset, len);
-107    }
-108
-109    static class ShareableMemoryKeyValue extends KeyValue implements ShareableMemory {
-110      public ShareableMemoryKeyValue(byte[] bytes, int offset, int length) {
-111        super(bytes, offset, length);
-112      }
-113
-114      @Override
-115      public Cell cloneToCell() {
-116        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-117        KeyValue kv = new KeyValue(copy, 0, copy.length);
-118        kv.setSequenceId(this.getSequenceId());
-119        return kv;
-120      }
-121    }
-122
-123    static class ShareableMemoryNoTagsKeyValue extends NoTagsKeyValue implements ShareableMemory {
-124      public ShareableMemoryNoTagsKeyValue(byte[] bytes, int offset, int length) {
-125        super(bytes, offset, length);
-126      }
-127
-128      @Override
-129      public Cell cloneToCell() {
-130        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-131        KeyValue kv = new NoTagsKeyValue(copy, 0, copy.length);
-132        kv.setSequenceId(this.getSequenceId());
-133        return kv;
-134      }
-135    }
-136  }
-137
-138  /**
-139   * Implementation depends on {@link InputStream#available()}
-140   */
-141  @Override
-142  public Decoder getDecoder(final InputStream is) {
-143    return new KeyValueDecoder(is);
-144  }
-145
-146  @Override
-147  public Decoder getDecoder(ByteBuffer buf) {
-148    return new ByteBufferedKeyValueDecoder(buf);
-149  }
-150
-151  @Override
-152  public Encoder getEncoder(OutputStream os) {
-153    return new KeyValueEncoder(os);
-154  }
-155}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - http://git-wip-us.apache.org/repos/asf/hbase-site/blob/86fde03b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryNoTagsKeyValue.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryNoTagsKeyValue.html b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryNoTagsKeyValue.html deleted file mode 100644 index a6ce21d..0000000 --- a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.ShareableMemoryNoTagsKeyValue.html +++ /dev/null @@ -1,227 +0,0 @@ - - - -Source code - - - -
-
001/**
-002 * Licensed to the Apache Software Foundation (ASF) under one
-003 * or more contributor license agreements.  See the NOTICE file
-004 * distributed with this work for additional information
-005 * regarding copyright ownership.  The ASF licenses this file
-006 * to you under the Apache License, Version 2.0 (the
-007 * "License"); you may not use this file except in compliance
-008 * with the License.  You may obtain a copy of the License at
-009 *
-010 *     http://www.apache.org/licenses/LICENSE-2.0
-011 *
-012 * Unless required by applicable law or agreed to in writing, software
-013 * distributed under the License is distributed on an "AS IS" BASIS,
-014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-015 * See the License for the specific language governing permissions and
-016 * limitations under the License.
-017 */
-018package org.apache.hadoop.hbase.codec;
-019
-020import java.io.IOException;
-021import java.io.InputStream;
-022import java.io.OutputStream;
-023import java.nio.ByteBuffer;
-024
-025import org.apache.hadoop.hbase.Cell;
-026import org.apache.hadoop.hbase.HBaseInterfaceAudience;
-027import org.apache.hadoop.hbase.KeyValue;
-028import org.apache.hadoop.hbase.KeyValueUtil;
-029import org.apache.hadoop.hbase.NoTagsKeyValue;
-030import org.apache.hadoop.hbase.ShareableMemory;
-031import org.apache.hadoop.hbase.classification.InterfaceAudience;
-032import org.apache.hadoop.hbase.util.ByteBufferUtils;
-033import org.apache.hadoop.hbase.util.Bytes;
-034
-035/**
-036 * Codec that does KeyValue version 1 serialization.
-037 * 
-038 * <p>Encodes Cell as serialized in KeyValue with total length prefix.
-039 * This is how KVs were serialized in Puts, Deletes and Results pre-0.96.  Its what would
-040 * happen if you called the Writable#write KeyValue implementation.  This encoder will fail
-041 * if the passed Cell is not an old-school pre-0.96 KeyValue.  Does not copy bytes writing.
-042 * It just writes them direct to the passed stream.
-043 *
-044 * <p>If you wrote two KeyValues to this encoder, it would look like this in the stream:
-045 * <pre>
-046 * length-of-KeyValue1 // A java int with the length of KeyValue1 backing array
-047 * KeyValue1 backing array filled with a KeyValue serialized in its particular format
-048 * length-of-KeyValue2
-049 * KeyValue2 backing array
-050 * </pre>
-051 */
-052@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
-053public class KeyValueCodec implements Codec {
-054  public static class KeyValueEncoder extends BaseEncoder {
-055    public KeyValueEncoder(final OutputStream out) {
-056      super(out);
-057    }
-058
-059    @Override
-060    public void write(Cell cell) throws IOException {
-061      checkFlushed();
-062      // Do not write tags over RPC
-063      ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, false));
-064      KeyValueUtil.oswrite(cell, out, false);
-065    }
-066  }
-067
-068  public static class KeyValueDecoder extends BaseDecoder {
-069    public KeyValueDecoder(final InputStream in) {
-070      super(in);
-071    }
-072
-073    protected Cell parseCell() throws IOException {
-074      // No tags here
-075      return KeyValueUtil.iscreate(in, false);
-076    }
-077  }
-078
-079  public static class ByteBufferedKeyValueDecoder implements Codec.Decoder {
-080
-081    protected final ByteBuffer buf;
-082    protected Cell current = null;
-083
-084    public ByteBufferedKeyValueDecoder(ByteBuffer buf) {
-085      this.buf = buf;
-086    }
-087
-088    @Override
-089    public boolean advance() throws IOException {
-090      if (this.buf.remaining() <= 0) {
-091        return false;
-092      }
-093      int len = ByteBufferUtils.toInt(buf);
-094      assert buf.hasArray();
-095      this.current = createCell(buf.array(), buf.arrayOffset() + buf.position(), len);
-096      buf.position(buf.position() + len);
-097      return true;
-098    }
-099
-100    @Override
-101    public Cell current() {
-102      return this.current;
-103    }
-104
-105    protected Cell createCell(byte[] buf, int offset, int len) {
-106      return new ShareableMemoryNoTagsKeyValue(buf, offset, len);
-107    }
-108
-109    static class ShareableMemoryKeyValue extends KeyValue implements ShareableMemory {
-110      public ShareableMemoryKeyValue(byte[] bytes, int offset, int length) {
-111        super(bytes, offset, length);
-112      }
-113
-114      @Override
-115      public Cell cloneToCell() {
-116        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-117        KeyValue kv = new KeyValue(copy, 0, copy.length);
-118        kv.setSequenceId(this.getSequenceId());
-119        return kv;
-120      }
-121    }
-122
-123    static class ShareableMemoryNoTagsKeyValue extends NoTagsKeyValue implements ShareableMemory {
-124      public ShareableMemoryNoTagsKeyValue(byte[] bytes, int offset, int length) {
-125        super(bytes, offset, length);
-126      }
-127
-128      @Override
-129      public Cell cloneToCell() {
-130        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-131        KeyValue kv = new NoTagsKeyValue(copy, 0, copy.length);
-132        kv.setSequenceId(this.getSequenceId());
-133        return kv;
-134      }
-135    }
-136  }
-137
-138  /**
-139   * Implementation depends on {@link InputStream#available()}
-140   */
-141  @Override
-142  public Decoder getDecoder(final InputStream is) {
-143    return new KeyValueDecoder(is);
-144  }
-145
-146  @Override
-147  public Decoder getDecoder(ByteBuffer buf) {
-148    return new ByteBufferedKeyValueDecoder(buf);
-149  }
-150
-151  @Override
-152  public Encoder getEncoder(OutputStream os) {
-153    return new KeyValueEncoder(os);
-154  }
-155}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - http://git-wip-us.apache.org/repos/asf/hbase-site/blob/86fde03b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.html b/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.html deleted file mode 100644 index a6ce21d..0000000 --- a/devapidocs/src-html/org/apache/hadoop/hbase/codec/KeyValueCodec.ByteBufferedKeyValueDecoder.html +++ /dev/null @@ -1,227 +0,0 @@ - - - -Source code - - - -
-
001/**
-002 * Licensed to the Apache Software Foundation (ASF) under one
-003 * or more contributor license agreements.  See the NOTICE file
-004 * distributed with this work for additional information
-005 * regarding copyright ownership.  The ASF licenses this file
-006 * to you under the Apache License, Version 2.0 (the
-007 * "License"); you may not use this file except in compliance
-008 * with the License.  You may obtain a copy of the License at
-009 *
-010 *     http://www.apache.org/licenses/LICENSE-2.0
-011 *
-012 * Unless required by applicable law or agreed to in writing, software
-013 * distributed under the License is distributed on an "AS IS" BASIS,
-014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-015 * See the License for the specific language governing permissions and
-016 * limitations under the License.
-017 */
-018package org.apache.hadoop.hbase.codec;
-019
-020import java.io.IOException;
-021import java.io.InputStream;
-022import java.io.OutputStream;
-023import java.nio.ByteBuffer;
-024
-025import org.apache.hadoop.hbase.Cell;
-026import org.apache.hadoop.hbase.HBaseInterfaceAudience;
-027import org.apache.hadoop.hbase.KeyValue;
-028import org.apache.hadoop.hbase.KeyValueUtil;
-029import org.apache.hadoop.hbase.NoTagsKeyValue;
-030import org.apache.hadoop.hbase.ShareableMemory;
-031import org.apache.hadoop.hbase.classification.InterfaceAudience;
-032import org.apache.hadoop.hbase.util.ByteBufferUtils;
-033import org.apache.hadoop.hbase.util.Bytes;
-034
-035/**
-036 * Codec that does KeyValue version 1 serialization.
-037 * 
-038 * <p>Encodes Cell as serialized in KeyValue with total length prefix.
-039 * This is how KVs were serialized in Puts, Deletes and Results pre-0.96.  Its what would
-040 * happen if you called the Writable#write KeyValue implementation.  This encoder will fail
-041 * if the passed Cell is not an old-school pre-0.96 KeyValue.  Does not copy bytes writing.
-042 * It just writes them direct to the passed stream.
-043 *
-044 * <p>If you wrote two KeyValues to this encoder, it would look like this in the stream:
-045 * <pre>
-046 * length-of-KeyValue1 // A java int with the length of KeyValue1 backing array
-047 * KeyValue1 backing array filled with a KeyValue serialized in its particular format
-048 * length-of-KeyValue2
-049 * KeyValue2 backing array
-050 * </pre>
-051 */
-052@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
-053public class KeyValueCodec implements Codec {
-054  public static class KeyValueEncoder extends BaseEncoder {
-055    public KeyValueEncoder(final OutputStream out) {
-056      super(out);
-057    }
-058
-059    @Override
-060    public void write(Cell cell) throws IOException {
-061      checkFlushed();
-062      // Do not write tags over RPC
-063      ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, false));
-064      KeyValueUtil.oswrite(cell, out, false);
-065    }
-066  }
-067
-068  public static class KeyValueDecoder extends BaseDecoder {
-069    public KeyValueDecoder(final InputStream in) {
-070      super(in);
-071    }
-072
-073    protected Cell parseCell() throws IOException {
-074      // No tags here
-075      return KeyValueUtil.iscreate(in, false);
-076    }
-077  }
-078
-079  public static class ByteBufferedKeyValueDecoder implements Codec.Decoder {
-080
-081    protected final ByteBuffer buf;
-082    protected Cell current = null;
-083
-084    public ByteBufferedKeyValueDecoder(ByteBuffer buf) {
-085      this.buf = buf;
-086    }
-087
-088    @Override
-089    public boolean advance() throws IOException {
-090      if (this.buf.remaining() <= 0) {
-091        return false;
-092      }
-093      int len = ByteBufferUtils.toInt(buf);
-094      assert buf.hasArray();
-095      this.current = createCell(buf.array(), buf.arrayOffset() + buf.position(), len);
-096      buf.position(buf.position() + len);
-097      return true;
-098    }
-099
-100    @Override
-101    public Cell current() {
-102      return this.current;
-103    }
-104
-105    protected Cell createCell(byte[] buf, int offset, int len) {
-106      return new ShareableMemoryNoTagsKeyValue(buf, offset, len);
-107    }
-108
-109    static class ShareableMemoryKeyValue extends KeyValue implements ShareableMemory {
-110      public ShareableMemoryKeyValue(byte[] bytes, int offset, int length) {
-111        super(bytes, offset, length);
-112      }
-113
-114      @Override
-115      public Cell cloneToCell() {
-116        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-117        KeyValue kv = new KeyValue(copy, 0, copy.length);
-118        kv.setSequenceId(this.getSequenceId());
-119        return kv;
-120      }
-121    }
-122
-123    static class ShareableMemoryNoTagsKeyValue extends NoTagsKeyValue implements ShareableMemory {
-124      public ShareableMemoryNoTagsKeyValue(byte[] bytes, int offset, int length) {
-125        super(bytes, offset, length);
-126      }
-127
-128      @Override
-129      public Cell cloneToCell() {
-130        byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
-131        KeyValue kv = new NoTagsKeyValue(copy, 0, copy.length);
-132        kv.setSequenceId(this.getSequenceId());
-133        return kv;
-134      }
-135    }
-136  }
-137
-138  /**
-139   * Implementation depends on {@link InputStream#available()}
-140   */
-141  @Override
-142  public Decoder getDecoder(final InputStream is) {
-143    return new KeyValueDecoder(is);
-144  }
-145
-146  @Override
-147  public Decoder getDecoder(ByteBuffer buf) {
-148    return new ByteBufferedKeyValueDecoder(buf);
-149  }
-150
-151  @Override
-152  public Encoder getEncoder(OutputStream os) {
-153    return new KeyValueEncoder(os);
-154  }
-155}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -