org.apache.hadoop.io.file.tfile.Utils.writeVLong()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.hadoop.io.file.tfile.Utils.writeVLong()方法的一些代码示例,展示了Utils.writeVLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.writeVLong()方法的具体详情如下:
包路径:org.apache.hadoop.io.file.tfile.Utils
类名称:Utils
方法名:writeVLong

Utils.writeVLong介绍

[英]Encoding a Long integer into a variable-length encoding format.

  • if n in [-32, 127): encode in one byte with the actual value. Otherwise,
  • if n in [-202^8, 202^8): encode in two bytes: byte[0] = n/256 - 52; byte[1]=n&0xff. Otherwise,
  • if n IN [-162^16, 162^16): encode in three bytes: byte[0]=n/2^16 - 88; byte[1]=(n>>8)&0xff; byte[2]=n&0xff. Otherwise,
  • if n in [-82^24, 82^24): encode in four bytes: byte[0]=n/2^24 - 112; byte[1] = (n>>16)&0xff; byte[2] = (n>>8)&0xff; byte[3]=n&0xff. Otherwise:
  • if n in [-2^31, 2^31): encode in five bytes: byte[0]=-125; byte[1] = (n>>24)&0xff; byte[2]=(n>>16)&0xff; byte[3]=(n>>8)&0xff; byte[4]=n&0xff;
  • if n in [-2^39, 2^39): encode in six bytes: byte[0]=-124; byte[1] = (n>>32)&0xff; byte[2]=(n>>24)&0xff; byte[3]=(n>>16)&0xff; byte[4]=(n>>8)&0xff; byte[5]=n&0xff
  • if n in [-2^47, 2^47): encode in seven bytes: byte[0]=-123; byte[1] = (n>>40)&0xff; byte[2]=(n>>32)&0xff; byte[3]=(n>>24)&0xff; byte[4]=(n>>16)&0xff; byte[5]=(n>>8)&0xff; byte[6]=n&0xff;
  • if n in [-2^55, 2^55): encode in eight bytes: byte[0]=-122; byte[1] = (n>>48)&0xff; byte[2] = (n>>40)&0xff; byte[3]=(n>>32)&0xff; byte[4]=(n>>24)&0xff; byte[5]=(n>>16)&0xff; byte[6]=(n>>8)&0xff; byte[7]=n&0xff;
  • if n in [-2^63, 2^63): encode in nine bytes: byte[0]=-121; byte[1] = (n>>54)&0xff; byte[2] = (n>>48)&0xff; byte[3] = (n>>40)&0xff; byte[4]=(n>>32)&0xff; byte[5]=(n>>24)&0xff; byte[6]=(n>>16)&0xff; byte[7]=(n>>8)&0xff; byte[8]=n&0xff;
    [中]将长整数编码为可变长度编码格式。
    如果n在[-32127]中:用实际值编码一个字节。否则,
    如果n在[-202^8,20
    2^8):在两个字节中编码:字节[0]=n/256-52;字节[1]=n&0xff。否则
    如果n在[-162^16,162^16):用三个字节编码:字节[0]=n/2^16-88;字节[1]=(n>>8)&0xff;字节[2]=n&0xff。否则
    如果n在[-82^24,8
    2^24):在四个字节中编码:字节[0]=n/2^24-112;字节[1]=(n>>16)&0xff;字节[2]=(n>>8)&0xff;字节[3]=n&0xff。否则:
    *如果n在[-2^31,2^31):在五个字节中编码:字节[0]=-125;字节[1]=(n>>24)&0xff;字节[2]=(n>>16)&0xff;字节[3]=(n>>8)&0xff;字节[4]=n&0xff;
    *如果n在[-2^39,2^39):在六个字节中编码:字节[0]=-124;字节[1]=(n>>32)&0xff;字节[2]=(n>>24)&0xff;字节[3]=(n>>16)&0xff;字节[4]=(n>>8)&0xff;字节[5]=n&0xff
    *如果n在[-2^47,2^47):在七个字节中编码:字节[0]=-123;字节[1]=(n>>40)&0xff;字节[2]=(n>>32)&0xff;字节[3]=(n>>24)&0xff;字节[4]=(n>>16)&0xff;字节[5]=(n>>8)&0xff;字节[6]=n&0xff;
    *如果n在[-2^55,2^55):在八个字节中编码:字节[0]=-122;字节[1]=(n>>48)&0xff;字节[2]=(n>>40)&0xff;字节[3]=(n>>32)&0xff;字节[4]=(n>>24)&0xff;字节[5]=(n>>16)&0xff;字节[6]=(n>>8)&0xff;字节[7]=n&0xff;
    *如果n在[-2^63,2^63):在九个字节中编码:字节[0]=-121;字节[1]=(n>>54)&0xff;字节[2]=(n>>48)&0xff;字节[3]=(n>>40)&0xff;字节[4]=(n>>32)&0xff;字节[5]=(n>>24)&0xff;字节[6]=(n>>16)&0xff;字节[7]=(n>>8)&0xff;字节[8]=n&0xff;

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Encoding an integer into a variable-length encoding format. Synonymous to
 * <code>Utils#writeVLong(out, n)</code>.
 * 
 * @param out
 *          output stream
 * @param n
 *          The integer to be encoded
 * @throws IOException
 * @see Utils#writeVLong(DataOutput, long)
 */
public static void writeVInt(DataOutput out, int n) throws IOException {
 writeVLong(out, n);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
 TFile.API_VERSION.write(out);
 Utils.writeVLong(out, recordCount);
 Utils.writeString(out, strComparator);
}

代码示例来源:origin: io.hops/hadoop-common

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: org.apache.apex/malhar-library

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * Encoding an integer into a variable-length encoding format. Synonymous to
 * <code>Utils#writeVLong(out, n)</code>.
 * 
 * @param out
 *          output stream
 * @param n
 *          The integer to be encoded
 * @throws IOException
 * @see Utils#writeVLong(DataOutput, long)
 */
public static void writeVInt(DataOutput out, int n) throws IOException {
 writeVLong(out, n);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

public void write(DataOutput out) throws IOException {
 Utils.writeVLong(out, offset);
 Utils.writeVLong(out, compressedSize);
 Utils.writeVLong(out, rawSize);
}

代码示例来源:origin: io.hops/hadoop-common

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: org.apache.apex/malhar-library

public void write(DataOutput out) throws IOException {
  Utils.writeVInt(out, key.length);
  out.write(key, 0, key.length);
  Utils.writeVLong(out, kvEntries);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

public void write(DataOutput out) throws IOException {
 TFile.API_VERSION.write(out);
 Utils.writeVLong(out, recordCount);
 Utils.writeString(out, strComparator);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

public void write(DataOutput out) throws IOException {
 TFile.API_VERSION.write(out);
 Utils.writeVLong(out, recordCount);
 Utils.writeString(out, strComparator);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public void write(DataOutput out) throws IOException {
 TFile.API_VERSION.write(out);
 Utils.writeVLong(out, recordCount);
 Utils.writeString(out, strComparator);
}

代码示例来源:origin: io.hops/hadoop-common

public void write(DataOutput out) throws IOException {
 TFile.API_VERSION.write(out);
 Utils.writeVLong(out, recordCount);
 Utils.writeString(out, strComparator);
}

相关文章