hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [11/52] [partial] hbase-site git commit: Published site at 61220e4d7c8d7e5fb8ed3bbe2469bc86632c48de.
Date Wed, 07 Dec 2016 18:24:17 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d9f3c819/apidocs/src-html/org/apache/hadoop/hbase/types/DataType.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/types/DataType.html b/apidocs/src-html/org/apache/hadoop/hbase/types/DataType.html
index 0c06ef6..1d42f02 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/types/DataType.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/types/DataType.html
@@ -69,14 +69,14 @@
 <span class="sourceLineNo">061</span>   * @return {@code true} when natural order is preserved,<a name="line.61"></a>
 <span class="sourceLineNo">062</span>   *         {@code false} otherwise.<a name="line.62"></a>
 <span class="sourceLineNo">063</span>   */<a name="line.63"></a>
-<span class="sourceLineNo">064</span>  public boolean isOrderPreserving();<a name="line.64"></a>
+<span class="sourceLineNo">064</span>  boolean isOrderPreserving();<a name="line.64"></a>
 <span class="sourceLineNo">065</span><a name="line.65"></a>
 <span class="sourceLineNo">066</span>  /**<a name="line.66"></a>
 <span class="sourceLineNo">067</span>   * Retrieve the sort {@link Order} imposed by this data type, or null when<a name="line.67"></a>
 <span class="sourceLineNo">068</span>   * natural ordering is not preserved. Value is either ascending or<a name="line.68"></a>
 <span class="sourceLineNo">069</span>   * descending. Default is assumed to be {@link Order#ASCENDING}.<a name="line.69"></a>
 <span class="sourceLineNo">070</span>   */<a name="line.70"></a>
-<span class="sourceLineNo">071</span>  public Order getOrder();<a name="line.71"></a>
+<span class="sourceLineNo">071</span>  Order getOrder();<a name="line.71"></a>
 <span class="sourceLineNo">072</span><a name="line.72"></a>
 <span class="sourceLineNo">073</span>  /**<a name="line.73"></a>
 <span class="sourceLineNo">074</span>   * Indicates whether this instance supports encoding null values. This<a name="line.74"></a>
@@ -85,40 +85,40 @@
 <span class="sourceLineNo">077</span>   * less than any non-null value for default sort ordering purposes.<a name="line.77"></a>
 <span class="sourceLineNo">078</span>   * @return {@code true} when null is supported, {@code false} otherwise.<a name="line.78"></a>
 <span class="sourceLineNo">079</span>   */<a name="line.79"></a>
-<span class="sourceLineNo">080</span>  public boolean isNullable();<a name="line.80"></a>
+<span class="sourceLineNo">080</span>  boolean isNullable();<a name="line.80"></a>
 <span class="sourceLineNo">081</span><a name="line.81"></a>
 <span class="sourceLineNo">082</span>  /**<a name="line.82"></a>
 <span class="sourceLineNo">083</span>   * Indicates whether this instance is able to skip over it's encoded value.<a name="line.83"></a>
 <span class="sourceLineNo">084</span>   * {@code DataType}s that are not skippable can only be used as the<a name="line.84"></a>
 <span class="sourceLineNo">085</span>   * right-most field of a {@link Struct}.<a name="line.85"></a>
 <span class="sourceLineNo">086</span>   */<a name="line.86"></a>
-<span class="sourceLineNo">087</span>  public boolean isSkippable();<a name="line.87"></a>
+<span class="sourceLineNo">087</span>  boolean isSkippable();<a name="line.87"></a>
 <span class="sourceLineNo">088</span><a name="line.88"></a>
 <span class="sourceLineNo">089</span>  /**<a name="line.89"></a>
 <span class="sourceLineNo">090</span>   * Inform consumers how long the encoded {@code byte[]} will be.<a name="line.90"></a>
 <span class="sourceLineNo">091</span>   * @param val The value to check.<a name="line.91"></a>
 <span class="sourceLineNo">092</span>   * @return the number of bytes required to encode {@code val}.a<a name="line.92"></a>
 <span class="sourceLineNo">093</span>   */<a name="line.93"></a>
-<span class="sourceLineNo">094</span>  public int encodedLength(T val);<a name="line.94"></a>
+<span class="sourceLineNo">094</span>  int encodedLength(T val);<a name="line.94"></a>
 <span class="sourceLineNo">095</span><a name="line.95"></a>
 <span class="sourceLineNo">096</span>  /**<a name="line.96"></a>
 <span class="sourceLineNo">097</span>   * Inform consumers over what type this {@code DataType} operates. Useful<a name="line.97"></a>
 <span class="sourceLineNo">098</span>   * when working with bare {@code DataType} instances.<a name="line.98"></a>
 <span class="sourceLineNo">099</span>   */<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  public Class&lt;T&gt; encodedClass();<a name="line.100"></a>
+<span class="sourceLineNo">100</span>  Class&lt;T&gt; encodedClass();<a name="line.100"></a>
 <span class="sourceLineNo">101</span><a name="line.101"></a>
 <span class="sourceLineNo">102</span>  /**<a name="line.102"></a>
 <span class="sourceLineNo">103</span>   * Skip {@code src}'s position forward over one encoded value.<a name="line.103"></a>
 <span class="sourceLineNo">104</span>   * @param src the buffer containing the encoded value.<a name="line.104"></a>
 <span class="sourceLineNo">105</span>   * @return number of bytes skipped.<a name="line.105"></a>
 <span class="sourceLineNo">106</span>   */<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  public int skip(PositionedByteRange src);<a name="line.107"></a>
+<span class="sourceLineNo">107</span>  int skip(PositionedByteRange src);<a name="line.107"></a>
 <span class="sourceLineNo">108</span><a name="line.108"></a>
 <span class="sourceLineNo">109</span>  /**<a name="line.109"></a>
 <span class="sourceLineNo">110</span>   * Read an instance of {@code T} from the buffer {@code src}.<a name="line.110"></a>
 <span class="sourceLineNo">111</span>   * @param src the buffer containing the encoded value.<a name="line.111"></a>
 <span class="sourceLineNo">112</span>   */<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  public T decode(PositionedByteRange src);<a name="line.113"></a>
+<span class="sourceLineNo">113</span>  T decode(PositionedByteRange src);<a name="line.113"></a>
 <span class="sourceLineNo">114</span><a name="line.114"></a>
 <span class="sourceLineNo">115</span>  /**<a name="line.115"></a>
 <span class="sourceLineNo">116</span>   * Write instance {@code val} into buffer {@code dst}.<a name="line.116"></a>
@@ -126,7 +126,7 @@
 <span class="sourceLineNo">118</span>   * @param val the value to encode onto {@code dst}.<a name="line.118"></a>
 <span class="sourceLineNo">119</span>   * @return number of bytes written.<a name="line.119"></a>
 <span class="sourceLineNo">120</span>   */<a name="line.120"></a>
-<span class="sourceLineNo">121</span>  public int encode(PositionedByteRange dst, T val);<a name="line.121"></a>
+<span class="sourceLineNo">121</span>  int encode(PositionedByteRange dst, T val);<a name="line.121"></a>
 <span class="sourceLineNo">122</span>}<a name="line.122"></a>
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d9f3c819/apidocs/src-html/org/apache/hadoop/hbase/util/ByteBufferUtils.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/util/ByteBufferUtils.html b/apidocs/src-html/org/apache/hadoop/hbase/util/ByteBufferUtils.html
index 77ccd85..db9d7c8 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/util/ByteBufferUtils.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/util/ByteBufferUtils.html
@@ -884,169 +884,201 @@
 <span class="sourceLineNo">876</span>    }<a name="line.876"></a>
 <span class="sourceLineNo">877</span>  }<a name="line.877"></a>
 <span class="sourceLineNo">878</span><a name="line.878"></a>
-<span class="sourceLineNo">879</span>  /**<a name="line.879"></a>
-<span class="sourceLineNo">880</span>   * Reads a double value at the given buffer's offset.<a name="line.880"></a>
-<span class="sourceLineNo">881</span>   * @param buffer<a name="line.881"></a>
-<span class="sourceLineNo">882</span>   * @param offset offset where double is<a name="line.882"></a>
-<span class="sourceLineNo">883</span>   * @return double value at offset<a name="line.883"></a>
-<span class="sourceLineNo">884</span>   */<a name="line.884"></a>
-<span class="sourceLineNo">885</span>  public static double toDouble(ByteBuffer buffer, int offset) {<a name="line.885"></a>
-<span class="sourceLineNo">886</span>    return Double.longBitsToDouble(toLong(buffer, offset));<a name="line.886"></a>
-<span class="sourceLineNo">887</span>  }<a name="line.887"></a>
-<span class="sourceLineNo">888</span><a name="line.888"></a>
-<span class="sourceLineNo">889</span>  /**<a name="line.889"></a>
-<span class="sourceLineNo">890</span>   * Reads a BigDecimal value at the given buffer's offset.<a name="line.890"></a>
-<span class="sourceLineNo">891</span>   * @param buffer<a name="line.891"></a>
-<span class="sourceLineNo">892</span>   * @param offset<a name="line.892"></a>
-<span class="sourceLineNo">893</span>   * @return BigDecimal value at offset<a name="line.893"></a>
-<span class="sourceLineNo">894</span>   */<a name="line.894"></a>
-<span class="sourceLineNo">895</span>  public static BigDecimal toBigDecimal(ByteBuffer buffer, int offset, int length) {<a name="line.895"></a>
-<span class="sourceLineNo">896</span>    if (buffer == null || length &lt; Bytes.SIZEOF_INT + 1 ||<a name="line.896"></a>
-<span class="sourceLineNo">897</span>      (offset + length &gt; buffer.limit())) {<a name="line.897"></a>
-<span class="sourceLineNo">898</span>      return null;<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    }<a name="line.899"></a>
-<span class="sourceLineNo">900</span><a name="line.900"></a>
-<span class="sourceLineNo">901</span>    int scale = toInt(buffer, offset);<a name="line.901"></a>
-<span class="sourceLineNo">902</span>    byte[] tcBytes = new byte[length - Bytes.SIZEOF_INT];<a name="line.902"></a>
-<span class="sourceLineNo">903</span>    copyFromBufferToArray(tcBytes, buffer, offset + Bytes.SIZEOF_INT, 0, length - Bytes.SIZEOF_INT);<a name="line.903"></a>
-<span class="sourceLineNo">904</span>    return new BigDecimal(new BigInteger(tcBytes), scale);<a name="line.904"></a>
-<span class="sourceLineNo">905</span>  }<a name="line.905"></a>
-<span class="sourceLineNo">906</span><a name="line.906"></a>
-<span class="sourceLineNo">907</span>  /**<a name="line.907"></a>
-<span class="sourceLineNo">908</span>   * Put a short value out to the given ByteBuffer's current position in big-endian format.<a name="line.908"></a>
-<span class="sourceLineNo">909</span>   * This also advances the position in buffer by short size.<a name="line.909"></a>
-<span class="sourceLineNo">910</span>   * @param buffer the ByteBuffer to write to<a name="line.910"></a>
-<span class="sourceLineNo">911</span>   * @param val short to write out<a name="line.911"></a>
-<span class="sourceLineNo">912</span>   */<a name="line.912"></a>
-<span class="sourceLineNo">913</span>  public static void putShort(ByteBuffer buffer, short val) {<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    if (UNSAFE_UNALIGNED) {<a name="line.914"></a>
-<span class="sourceLineNo">915</span>      int newPos = UnsafeAccess.putShort(buffer, buffer.position(), val);<a name="line.915"></a>
-<span class="sourceLineNo">916</span>      buffer.position(newPos);<a name="line.916"></a>
-<span class="sourceLineNo">917</span>    } else {<a name="line.917"></a>
-<span class="sourceLineNo">918</span>      buffer.putShort(val);<a name="line.918"></a>
-<span class="sourceLineNo">919</span>    }<a name="line.919"></a>
-<span class="sourceLineNo">920</span>  }<a name="line.920"></a>
-<span class="sourceLineNo">921</span><a name="line.921"></a>
-<span class="sourceLineNo">922</span>  /**<a name="line.922"></a>
-<span class="sourceLineNo">923</span>   * Put a long value out to the given ByteBuffer's current position in big-endian format.<a name="line.923"></a>
-<span class="sourceLineNo">924</span>   * This also advances the position in buffer by long size.<a name="line.924"></a>
-<span class="sourceLineNo">925</span>   * @param buffer the ByteBuffer to write to<a name="line.925"></a>
-<span class="sourceLineNo">926</span>   * @param val long to write out<a name="line.926"></a>
-<span class="sourceLineNo">927</span>   */<a name="line.927"></a>
-<span class="sourceLineNo">928</span>  public static void putLong(ByteBuffer buffer, long val) {<a name="line.928"></a>
-<span class="sourceLineNo">929</span>    if (UNSAFE_UNALIGNED) {<a name="line.929"></a>
-<span class="sourceLineNo">930</span>      int newPos = UnsafeAccess.putLong(buffer, buffer.position(), val);<a name="line.930"></a>
-<span class="sourceLineNo">931</span>      buffer.position(newPos);<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    } else {<a name="line.932"></a>
-<span class="sourceLineNo">933</span>      buffer.putLong(val);<a name="line.933"></a>
-<span class="sourceLineNo">934</span>    }<a name="line.934"></a>
-<span class="sourceLineNo">935</span>  }<a name="line.935"></a>
-<span class="sourceLineNo">936</span>  /**<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   * Copies the bytes from given array's offset to length part into the given buffer. Puts the bytes<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   * to buffer's current position. This also advances the position in the 'out' buffer by 'length'<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   * @param out<a name="line.939"></a>
-<span class="sourceLineNo">940</span>   * @param in<a name="line.940"></a>
-<span class="sourceLineNo">941</span>   * @param inOffset<a name="line.941"></a>
-<span class="sourceLineNo">942</span>   * @param length<a name="line.942"></a>
-<span class="sourceLineNo">943</span>   */<a name="line.943"></a>
-<span class="sourceLineNo">944</span>  public static void copyFromArrayToBuffer(ByteBuffer out, byte[] in, int inOffset, int length) {<a name="line.944"></a>
-<span class="sourceLineNo">945</span>    if (out.hasArray()) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>      System.arraycopy(in, inOffset, out.array(), out.arrayOffset() + out.position(), length);<a name="line.946"></a>
-<span class="sourceLineNo">947</span>      // Move the position in out by length<a name="line.947"></a>
-<span class="sourceLineNo">948</span>      out.position(out.position() + length);<a name="line.948"></a>
-<span class="sourceLineNo">949</span>    } else if (UNSAFE_AVAIL) {<a name="line.949"></a>
-<span class="sourceLineNo">950</span>      UnsafeAccess.copy(in, inOffset, out, out.position(), length);<a name="line.950"></a>
-<span class="sourceLineNo">951</span>      // Move the position in out by length<a name="line.951"></a>
-<span class="sourceLineNo">952</span>      out.position(out.position() + length);<a name="line.952"></a>
-<span class="sourceLineNo">953</span>    } else {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>      out.put(in, inOffset, length);<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    }<a name="line.955"></a>
-<span class="sourceLineNo">956</span>  }<a name="line.956"></a>
-<span class="sourceLineNo">957</span><a name="line.957"></a>
-<span class="sourceLineNo">958</span>  /**<a name="line.958"></a>
-<span class="sourceLineNo">959</span>   * Copies bytes from given array's offset to length part into the given buffer. Puts the bytes<a name="line.959"></a>
-<span class="sourceLineNo">960</span>   * to buffer's given position.<a name="line.960"></a>
-<span class="sourceLineNo">961</span>   * @param out<a name="line.961"></a>
-<span class="sourceLineNo">962</span>   * @param in<a name="line.962"></a>
-<span class="sourceLineNo">963</span>   * @param inOffset<a name="line.963"></a>
-<span class="sourceLineNo">964</span>   * @param length<a name="line.964"></a>
-<span class="sourceLineNo">965</span>   */<a name="line.965"></a>
-<span class="sourceLineNo">966</span>  public static void copyFromArrayToBuffer(ByteBuffer out, int outOffset, byte[] in, int inOffset,<a name="line.966"></a>
-<span class="sourceLineNo">967</span>      int length) {<a name="line.967"></a>
-<span class="sourceLineNo">968</span>    if (out.hasArray()) {<a name="line.968"></a>
-<span class="sourceLineNo">969</span>      System.arraycopy(in, inOffset, out.array(), out.arrayOffset() + outOffset, length);<a name="line.969"></a>
-<span class="sourceLineNo">970</span>    } else if (UNSAFE_AVAIL) {<a name="line.970"></a>
-<span class="sourceLineNo">971</span>      UnsafeAccess.copy(in, inOffset, out, outOffset, length);<a name="line.971"></a>
-<span class="sourceLineNo">972</span>    } else {<a name="line.972"></a>
-<span class="sourceLineNo">973</span>      int oldPos = out.position();<a name="line.973"></a>
-<span class="sourceLineNo">974</span>      out.position(outOffset);<a name="line.974"></a>
-<span class="sourceLineNo">975</span>      out.put(in, inOffset, length);<a name="line.975"></a>
-<span class="sourceLineNo">976</span>      out.position(oldPos);<a name="line.976"></a>
-<span class="sourceLineNo">977</span>    }<a name="line.977"></a>
-<span class="sourceLineNo">978</span>  }<a name="line.978"></a>
-<span class="sourceLineNo">979</span><a name="line.979"></a>
-<span class="sourceLineNo">980</span>  /**<a name="line.980"></a>
-<span class="sourceLineNo">981</span>   * Copies specified number of bytes from given offset of 'in' ByteBuffer to<a name="line.981"></a>
-<span class="sourceLineNo">982</span>   * the array.<a name="line.982"></a>
-<span class="sourceLineNo">983</span>   * @param out<a name="line.983"></a>
-<span class="sourceLineNo">984</span>   * @param in<a name="line.984"></a>
-<span class="sourceLineNo">985</span>   * @param sourceOffset<a name="line.985"></a>
-<span class="sourceLineNo">986</span>   * @param destinationOffset<a name="line.986"></a>
-<span class="sourceLineNo">987</span>   * @param length<a name="line.987"></a>
-<span class="sourceLineNo">988</span>   */<a name="line.988"></a>
-<span class="sourceLineNo">989</span>  public static void copyFromBufferToArray(byte[] out, ByteBuffer in, int sourceOffset,<a name="line.989"></a>
-<span class="sourceLineNo">990</span>      int destinationOffset, int length) {<a name="line.990"></a>
-<span class="sourceLineNo">991</span>    if (in.hasArray()) {<a name="line.991"></a>
-<span class="sourceLineNo">992</span>      System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out, destinationOffset, length);<a name="line.992"></a>
-<span class="sourceLineNo">993</span>    } else if (UNSAFE_AVAIL) {<a name="line.993"></a>
-<span class="sourceLineNo">994</span>      UnsafeAccess.copy(in, sourceOffset, out, destinationOffset, length);<a name="line.994"></a>
-<span class="sourceLineNo">995</span>    } else {<a name="line.995"></a>
-<span class="sourceLineNo">996</span>      int oldPos = in.position();<a name="line.996"></a>
-<span class="sourceLineNo">997</span>      in.position(sourceOffset);<a name="line.997"></a>
-<span class="sourceLineNo">998</span>      in.get(out, destinationOffset, length);<a name="line.998"></a>
-<span class="sourceLineNo">999</span>      in.position(oldPos);<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>    }<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>  }<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span><a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>  /**<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>   * Similar to  {@link Arrays#copyOfRange(byte[], int, int)}<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>   * @param original the buffer from which the copy has to happen<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>   * @param from the starting index<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>   * @param to the ending index<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>   * @return a byte[] created out of the copy<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>   */<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>  public static byte[] copyOfRange(ByteBuffer original, int from, int to) {<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>    int newLength = to - from;<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>    if (newLength &lt; 0) throw new IllegalArgumentException(from + " &gt; " + to);<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    byte[] copy = new byte[newLength];<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    ByteBufferUtils.copyFromBufferToArray(copy, original, from, 0, newLength);<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    return copy;<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>  }<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span><a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>  // For testing purpose<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>  public static String toStringBinary(final ByteBuffer b, int off, int len) {<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>    StringBuilder result = new StringBuilder();<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    // Just in case we are passed a 'len' that is &gt; buffer length...<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>    if (off &gt;= b.capacity())<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>      return result.toString();<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    if (off + len &gt; b.capacity())<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>      len = b.capacity() - off;<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    for (int i = off; i &lt; off + len; ++i) {<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>      int ch = b.get(i) &amp; 0xFF;<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>      if ((ch &gt;= '0' &amp;&amp; ch &lt;= '9') || (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z') || (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z')<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>          || " `~!@#$%^&amp;*()-_=+[]{}|;:'\",.&lt;&gt;/?".indexOf(ch) &gt;= 0) {<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>        result.append((char) ch);<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>      } else {<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>        result.append(String.format("\\x%02X", ch));<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>      }<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    }<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>    return result.toString();<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>  }<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span><a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  public static String toStringBinary(final ByteBuffer b) {<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>    return toStringBinary(b, 0, b.capacity());<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  }<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>}<a name="line.1041"></a>
+<span class="sourceLineNo">879</span>  public static int putInt(ByteBuffer buffer, int index, int val) {<a name="line.879"></a>
+<span class="sourceLineNo">880</span>    if (UNSAFE_UNALIGNED) {<a name="line.880"></a>
+<span class="sourceLineNo">881</span>      return UnsafeAccess.putInt(buffer, index, val);<a name="line.881"></a>
+<span class="sourceLineNo">882</span>    }<a name="line.882"></a>
+<span class="sourceLineNo">883</span>    buffer.putInt(index, val);<a name="line.883"></a>
+<span class="sourceLineNo">884</span>    return index + Bytes.SIZEOF_INT;<a name="line.884"></a>
+<span class="sourceLineNo">885</span>  }<a name="line.885"></a>
+<span class="sourceLineNo">886</span><a name="line.886"></a>
+<span class="sourceLineNo">887</span>  /**<a name="line.887"></a>
+<span class="sourceLineNo">888</span>   * Reads a double value at the given buffer's offset.<a name="line.888"></a>
+<span class="sourceLineNo">889</span>   * @param buffer<a name="line.889"></a>
+<span class="sourceLineNo">890</span>   * @param offset offset where double is<a name="line.890"></a>
+<span class="sourceLineNo">891</span>   * @return double value at offset<a name="line.891"></a>
+<span class="sourceLineNo">892</span>   */<a name="line.892"></a>
+<span class="sourceLineNo">893</span>  public static double toDouble(ByteBuffer buffer, int offset) {<a name="line.893"></a>
+<span class="sourceLineNo">894</span>    return Double.longBitsToDouble(toLong(buffer, offset));<a name="line.894"></a>
+<span class="sourceLineNo">895</span>  }<a name="line.895"></a>
+<span class="sourceLineNo">896</span><a name="line.896"></a>
+<span class="sourceLineNo">897</span>  /**<a name="line.897"></a>
+<span class="sourceLineNo">898</span>   * Reads a BigDecimal value at the given buffer's offset.<a name="line.898"></a>
+<span class="sourceLineNo">899</span>   * @param buffer<a name="line.899"></a>
+<span class="sourceLineNo">900</span>   * @param offset<a name="line.900"></a>
+<span class="sourceLineNo">901</span>   * @return BigDecimal value at offset<a name="line.901"></a>
+<span class="sourceLineNo">902</span>   */<a name="line.902"></a>
+<span class="sourceLineNo">903</span>  public static BigDecimal toBigDecimal(ByteBuffer buffer, int offset, int length) {<a name="line.903"></a>
+<span class="sourceLineNo">904</span>    if (buffer == null || length &lt; Bytes.SIZEOF_INT + 1 ||<a name="line.904"></a>
+<span class="sourceLineNo">905</span>      (offset + length &gt; buffer.limit())) {<a name="line.905"></a>
+<span class="sourceLineNo">906</span>      return null;<a name="line.906"></a>
+<span class="sourceLineNo">907</span>    }<a name="line.907"></a>
+<span class="sourceLineNo">908</span><a name="line.908"></a>
+<span class="sourceLineNo">909</span>    int scale = toInt(buffer, offset);<a name="line.909"></a>
+<span class="sourceLineNo">910</span>    byte[] tcBytes = new byte[length - Bytes.SIZEOF_INT];<a name="line.910"></a>
+<span class="sourceLineNo">911</span>    copyFromBufferToArray(tcBytes, buffer, offset + Bytes.SIZEOF_INT, 0, length - Bytes.SIZEOF_INT);<a name="line.911"></a>
+<span class="sourceLineNo">912</span>    return new BigDecimal(new BigInteger(tcBytes), scale);<a name="line.912"></a>
+<span class="sourceLineNo">913</span>  }<a name="line.913"></a>
+<span class="sourceLineNo">914</span><a name="line.914"></a>
+<span class="sourceLineNo">915</span>  /**<a name="line.915"></a>
+<span class="sourceLineNo">916</span>   * Put a short value out to the given ByteBuffer's current position in big-endian format.<a name="line.916"></a>
+<span class="sourceLineNo">917</span>   * This also advances the position in buffer by short size.<a name="line.917"></a>
+<span class="sourceLineNo">918</span>   * @param buffer the ByteBuffer to write to<a name="line.918"></a>
+<span class="sourceLineNo">919</span>   * @param val short to write out<a name="line.919"></a>
+<span class="sourceLineNo">920</span>   */<a name="line.920"></a>
+<span class="sourceLineNo">921</span>  public static void putShort(ByteBuffer buffer, short val) {<a name="line.921"></a>
+<span class="sourceLineNo">922</span>    if (UNSAFE_UNALIGNED) {<a name="line.922"></a>
+<span class="sourceLineNo">923</span>      int newPos = UnsafeAccess.putShort(buffer, buffer.position(), val);<a name="line.923"></a>
+<span class="sourceLineNo">924</span>      buffer.position(newPos);<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    } else {<a name="line.925"></a>
+<span class="sourceLineNo">926</span>      buffer.putShort(val);<a name="line.926"></a>
+<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
+<span class="sourceLineNo">928</span>  }<a name="line.928"></a>
+<span class="sourceLineNo">929</span><a name="line.929"></a>
+<span class="sourceLineNo">930</span>  public static int putShort(ByteBuffer buffer, int index, short val) {<a name="line.930"></a>
+<span class="sourceLineNo">931</span>    if (UNSAFE_UNALIGNED) {<a name="line.931"></a>
+<span class="sourceLineNo">932</span>      return UnsafeAccess.putShort(buffer, index, val);<a name="line.932"></a>
+<span class="sourceLineNo">933</span>    }<a name="line.933"></a>
+<span class="sourceLineNo">934</span>    buffer.putShort(index, val);<a name="line.934"></a>
+<span class="sourceLineNo">935</span>    return index + Bytes.SIZEOF_SHORT;<a name="line.935"></a>
+<span class="sourceLineNo">936</span>  }<a name="line.936"></a>
+<span class="sourceLineNo">937</span><a name="line.937"></a>
+<span class="sourceLineNo">938</span>  public static int putAsShort(ByteBuffer buf, int index, int val) {<a name="line.938"></a>
+<span class="sourceLineNo">939</span>    buf.put(index + 1, (byte) val);<a name="line.939"></a>
+<span class="sourceLineNo">940</span>    val &gt;&gt;= 8;<a name="line.940"></a>
+<span class="sourceLineNo">941</span>    buf.put(index, (byte) val);<a name="line.941"></a>
+<span class="sourceLineNo">942</span>    return index + Bytes.SIZEOF_SHORT;<a name="line.942"></a>
+<span class="sourceLineNo">943</span>  }<a name="line.943"></a>
+<span class="sourceLineNo">944</span><a name="line.944"></a>
+<span class="sourceLineNo">945</span>  /**<a name="line.945"></a>
+<span class="sourceLineNo">946</span>   * Put a long value out to the given ByteBuffer's current position in big-endian format.<a name="line.946"></a>
+<span class="sourceLineNo">947</span>   * This also advances the position in buffer by long size.<a name="line.947"></a>
+<span class="sourceLineNo">948</span>   * @param buffer the ByteBuffer to write to<a name="line.948"></a>
+<span class="sourceLineNo">949</span>   * @param val long to write out<a name="line.949"></a>
+<span class="sourceLineNo">950</span>   */<a name="line.950"></a>
+<span class="sourceLineNo">951</span>  public static void putLong(ByteBuffer buffer, long val) {<a name="line.951"></a>
+<span class="sourceLineNo">952</span>    if (UNSAFE_UNALIGNED) {<a name="line.952"></a>
+<span class="sourceLineNo">953</span>      int newPos = UnsafeAccess.putLong(buffer, buffer.position(), val);<a name="line.953"></a>
+<span class="sourceLineNo">954</span>      buffer.position(newPos);<a name="line.954"></a>
+<span class="sourceLineNo">955</span>    } else {<a name="line.955"></a>
+<span class="sourceLineNo">956</span>      buffer.putLong(val);<a name="line.956"></a>
+<span class="sourceLineNo">957</span>    }<a name="line.957"></a>
+<span class="sourceLineNo">958</span>  }<a name="line.958"></a>
+<span class="sourceLineNo">959</span><a name="line.959"></a>
+<span class="sourceLineNo">960</span>  public static int putLong(ByteBuffer buffer, int index, long val) {<a name="line.960"></a>
+<span class="sourceLineNo">961</span>    if (UNSAFE_UNALIGNED) {<a name="line.961"></a>
+<span class="sourceLineNo">962</span>      return UnsafeAccess.putLong(buffer, index, val);<a name="line.962"></a>
+<span class="sourceLineNo">963</span>    }<a name="line.963"></a>
+<span class="sourceLineNo">964</span>    buffer.putLong(index, val);<a name="line.964"></a>
+<span class="sourceLineNo">965</span>    return index + Bytes.SIZEOF_LONG;<a name="line.965"></a>
+<span class="sourceLineNo">966</span>  }<a name="line.966"></a>
+<span class="sourceLineNo">967</span><a name="line.967"></a>
+<span class="sourceLineNo">968</span>  /**<a name="line.968"></a>
+<span class="sourceLineNo">969</span>   * Copies the bytes from given array's offset to length part into the given buffer. Puts the bytes<a name="line.969"></a>
+<span class="sourceLineNo">970</span>   * to buffer's current position. This also advances the position in the 'out' buffer by 'length'<a name="line.970"></a>
+<span class="sourceLineNo">971</span>   * @param out<a name="line.971"></a>
+<span class="sourceLineNo">972</span>   * @param in<a name="line.972"></a>
+<span class="sourceLineNo">973</span>   * @param inOffset<a name="line.973"></a>
+<span class="sourceLineNo">974</span>   * @param length<a name="line.974"></a>
+<span class="sourceLineNo">975</span>   */<a name="line.975"></a>
+<span class="sourceLineNo">976</span>  public static void copyFromArrayToBuffer(ByteBuffer out, byte[] in, int inOffset, int length) {<a name="line.976"></a>
+<span class="sourceLineNo">977</span>    if (out.hasArray()) {<a name="line.977"></a>
+<span class="sourceLineNo">978</span>      System.arraycopy(in, inOffset, out.array(), out.arrayOffset() + out.position(), length);<a name="line.978"></a>
+<span class="sourceLineNo">979</span>      // Move the position in out by length<a name="line.979"></a>
+<span class="sourceLineNo">980</span>      out.position(out.position() + length);<a name="line.980"></a>
+<span class="sourceLineNo">981</span>    } else if (UNSAFE_AVAIL) {<a name="line.981"></a>
+<span class="sourceLineNo">982</span>      UnsafeAccess.copy(in, inOffset, out, out.position(), length);<a name="line.982"></a>
+<span class="sourceLineNo">983</span>      // Move the position in out by length<a name="line.983"></a>
+<span class="sourceLineNo">984</span>      out.position(out.position() + length);<a name="line.984"></a>
+<span class="sourceLineNo">985</span>    } else {<a name="line.985"></a>
+<span class="sourceLineNo">986</span>      out.put(in, inOffset, length);<a name="line.986"></a>
+<span class="sourceLineNo">987</span>    }<a name="line.987"></a>
+<span class="sourceLineNo">988</span>  }<a name="line.988"></a>
+<span class="sourceLineNo">989</span><a name="line.989"></a>
+<span class="sourceLineNo">990</span>  /**<a name="line.990"></a>
+<span class="sourceLineNo">991</span>   * Copies bytes from given array's offset to length part into the given buffer. Puts the bytes<a name="line.991"></a>
+<span class="sourceLineNo">992</span>   * to buffer's given position.<a name="line.992"></a>
+<span class="sourceLineNo">993</span>   * @param out<a name="line.993"></a>
+<span class="sourceLineNo">994</span>   * @param in<a name="line.994"></a>
+<span class="sourceLineNo">995</span>   * @param inOffset<a name="line.995"></a>
+<span class="sourceLineNo">996</span>   * @param length<a name="line.996"></a>
+<span class="sourceLineNo">997</span>   */<a name="line.997"></a>
+<span class="sourceLineNo">998</span>  public static void copyFromArrayToBuffer(ByteBuffer out, int outOffset, byte[] in, int inOffset,<a name="line.998"></a>
+<span class="sourceLineNo">999</span>      int length) {<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>    if (out.hasArray()) {<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>      System.arraycopy(in, inOffset, out.array(), out.arrayOffset() + outOffset, length);<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>    } else if (UNSAFE_AVAIL) {<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>      UnsafeAccess.copy(in, inOffset, out, outOffset, length);<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>    } else {<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>      int oldPos = out.position();<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>      out.position(outOffset);<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>      out.put(in, inOffset, length);<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>      out.position(oldPos);<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>    }<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>  }<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span><a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>  /**<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>   * Copies specified number of bytes from given offset of 'in' ByteBuffer to<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>   * the array.<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>   * @param out<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>   * @param in<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>   * @param sourceOffset<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>   * @param destinationOffset<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>   * @param length<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>   */<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>  public static void copyFromBufferToArray(byte[] out, ByteBuffer in, int sourceOffset,<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>      int destinationOffset, int length) {<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>    if (in.hasArray()) {<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>      System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out, destinationOffset, length);<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>    } else if (UNSAFE_AVAIL) {<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>      UnsafeAccess.copy(in, sourceOffset, out, destinationOffset, length);<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>    } else {<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>      int oldPos = in.position();<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>      in.position(sourceOffset);<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>      in.get(out, destinationOffset, length);<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>      in.position(oldPos);<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>    }<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>  }<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span><a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>  /**<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>   * Similar to  {@link Arrays#copyOfRange(byte[], int, int)}<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>   * @param original the buffer from which the copy has to happen<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>   * @param from the starting index<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>   * @param to the ending index<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>   * @return a byte[] created out of the copy<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>   */<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>  public static byte[] copyOfRange(ByteBuffer original, int from, int to) {<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>    int newLength = to - from;<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>    if (newLength &lt; 0) throw new IllegalArgumentException(from + " &gt; " + to);<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>    byte[] copy = new byte[newLength];<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>    ByteBufferUtils.copyFromBufferToArray(copy, original, from, 0, newLength);<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>    return copy;<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>  }<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span><a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>  // For testing purpose<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>  public static String toStringBinary(final ByteBuffer b, int off, int len) {<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>    StringBuilder result = new StringBuilder();<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>    // Just in case we are passed a 'len' that is &gt; buffer length...<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>    if (off &gt;= b.capacity())<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>      return result.toString();<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>    if (off + len &gt; b.capacity())<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>      len = b.capacity() - off;<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>    for (int i = off; i &lt; off + len; ++i) {<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>      int ch = b.get(i) &amp; 0xFF;<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>      if ((ch &gt;= '0' &amp;&amp; ch &lt;= '9') || (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z') || (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z')<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>          || " `~!@#$%^&amp;*()-_=+[]{}|;:'\",.&lt;&gt;/?".indexOf(ch) &gt;= 0) {<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>        result.append((char) ch);<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>      } else {<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>        result.append(String.format("\\x%02X", ch));<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>      }<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>    }<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>    return result.toString();<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>  }<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span><a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>  public static String toStringBinary(final ByteBuffer b) {<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>    return toStringBinary(b, 0, b.capacity());<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>  }<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>}<a name="line.1073"></a>
 
 
 


Mime
View raw message