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 0E700200CE5 for ; Sun, 6 Aug 2017 14:44:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0CEBC164142; Sun, 6 Aug 2017 12:44:45 +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 583ED1640CF for ; Sun, 6 Aug 2017 14:44:44 +0200 (CEST) Received: (qmail 60993 invoked by uid 500); 6 Aug 2017 12:44:38 -0000 Mailing-List: contact dev-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 dev@hbase.apache.org Received: (qmail 60981 invoked by uid 99); 6 Aug 2017 12:44:38 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Aug 2017 12:44:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id BD0B6C004A for ; Sun, 6 Aug 2017 12:44:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.379 X-Spam-Level: X-Spam-Status: No, score=0.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id fT5z3BryQyL6 for ; Sun, 6 Aug 2017 12:44:36 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 50FBE5F3D1 for ; Sun, 6 Aug 2017 12:44:36 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id d17so21259902lfe.0 for ; Sun, 06 Aug 2017 05:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=1uMQIVjVzOWV3cH1fUX4qYG2dajAy2H2C/z0E+P78sg=; b=ULKpmUi/QT+mwQ5zCqVrZ56EJ+OVOepZ2Ns8DJV7hN54ANPmD5dsMrWxZzmXpLtZtC 5s+XtMSx7ehKsSmWVDgU1+K5ftiCJ8TFMwYE9+mSwgB71TE2j3ovOBUFGzlz/I41Zb8V /zx58jMSZ4zPkZk4kxZr//Qa4fAY7uar9T89iMH1+aHDSnu2rb7RGesvogg+KYs7M7ZH KFOWYzcCjZdGnXDzC/JURBDRj3+Rwe0ylSGtsMFuvipiyK4RwFh/KvBgdXL77WOMW4nu oFcuREgxN2L7l2Kd85FPiWFhpIfdZ/xiN6rhA8SzRAVkV7/93mF1IQ6LES3ioVXliV9H rXQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=1uMQIVjVzOWV3cH1fUX4qYG2dajAy2H2C/z0E+P78sg=; b=rgGwNO7jCEigtMNV+MLbDaUirOj1tUPJtIPkPeIAmPkXg+rZ39/BVWmb4oNWldPCnO GFfY2C7IasV5nCE3A+bnVbsICFummZTvud4hA0wvtgMHxrswoXHJxwzpGcq+BUR0XEMQ 8VhE1fhih6NjAJrrHQ1E89ihb1wK+7vGwyvIiafOBLAlKT56YIdJTQZ8ONAIdqLz37Nz gAY0UowrbAaS0pdkSUtr04E5CkHWWRb+m0cvfnqD1jjTXKwPlfqSduDr9ukOqtSiNGa3 CsVWmNBgjQtC151fslLlGObsVJat2Kezxj7K5YZWLem9QsDg0qUi/gyR4PJ6jRRdeUQW lajw== X-Gm-Message-State: AHYfb5iLJlHP27jphAiF20WrbY7LQ7bp+005RnxI+kNFqiZeDx1GHxjP Osx8bfrmUHZnX9NLDagpavfF1Lqa2nYl X-Received: by 10.46.77.83 with SMTP id a80mr2035662ljb.110.1502023474736; Sun, 06 Aug 2017 05:44:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.43.209 with HTTP; Sun, 6 Aug 2017 05:44:34 -0700 (PDT) In-Reply-To: References: From: Lars George Date: Sun, 6 Aug 2017 14:44:34 +0200 Message-ID: Subject: Re: Tags class using wrong length? To: "dev@hbase.apache.org" Content-Type: text/plain; charset="UTF-8" archived-at: Sun, 06 Aug 2017 12:44:45 -0000 You mean I am right and it should be the other constant being used? Sorry, just wanting to confirm. On Sun, Aug 6, 2017 at 2:40 PM, Chia-Ping Tsai wrote: > According to the following code: > public ArrayBackedTag(byte tagType, byte[] tag) { > int tagLength = tag.length + TYPE_LENGTH_SIZE; > if (tagLength > MAX_TAG_LENGTH) { > throw new IllegalArgumentException( > "Invalid tag data being passed. Its length can not exceed " + MAX_TAG_LENGTH); > } > length = TAG_LENGTH_SIZE + tagLength; > bytes = new byte[length]; > int pos = Bytes.putAsShort(bytes, 0, tagLength); > pos = Bytes.putByte(bytes, pos, tagType); > Bytes.putBytes(bytes, pos, tag, 0, tag.length); > this.type = tagType; > } > The layout of the byte array should be: > |tag legnth (2 bytes)|tag type(1 byte)|tag| > > It seems to me that the "bytes[offset + TYPE_LENGTH_SIZE]" is correct. > > On 2017-08-06 16:35, Lars George wrote: >> Hi, >> >> I found this reading through tags in 1.3, but checked in trunk as >> well. There is this code: >> >> public ArrayBackedTag(byte[] bytes, int offset, int length) { >> if (length > MAX_TAG_LENGTH) { >> throw new IllegalArgumentException( >> "Invalid tag data being passed. Its length can not exceed " >> + MAX_TAG_LENGTH); >> } >> this.bytes = bytes; >> this.offset = offset; >> this.length = length; >> this.type = bytes[offset + TAG_LENGTH_SIZE]; >> } >> >> I am concerned about the last line of the code, using the wrong constant? >> >> public final static int TYPE_LENGTH_SIZE = Bytes.SIZEOF_BYTE; >> public final static int TAG_LENGTH_SIZE = Bytes.SIZEOF_SHORT; >> >> Should this not read >> >> this.type = bytes[offset + TYPE_LENGTH_SIZE]; >> >> Would this not read the type from the wrong place in the array? >> >> Cheers, >> Lars >>