本文整理了Java中org.apache.hadoop.record.Buffer.getCapacity()
方法的一些代码示例,展示了Buffer.getCapacity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getCapacity()
方法的具体详情如下:
包路径:org.apache.hadoop.record.Buffer
类名称:Buffer
方法名:getCapacity
[英]Get the capacity, which is the maximum count that could handled without resizing the backing storage.
[中]获取容量,这是在不调整备份存储大小的情况下可以处理的最大计数。
代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity >= getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity {@literal >=} getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity {@literal >=} getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: com.facebook.hadoop/hadoop-core
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity >= getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: io.prestosql.hadoop/hadoop-apache
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity {@literal >=} getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-streaming
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity {@literal >=} getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Change the capacity of the backing storage.
* The data is preserved if newCapacity {@literal >=} getCount().
* @param newCapacity The new capacity in bytes.
*/
public void setCapacity(int newCapacity) {
if (newCapacity < 0) {
throw new IllegalArgumentException("Invalid capacity argument "+newCapacity);
}
if (newCapacity == 0) {
this.bytes = null;
this.count = 0;
return;
}
if (newCapacity != getCapacity()) {
byte[] data = new byte[newCapacity];
if (newCapacity < count) {
count = newCapacity;
}
if (count != 0) {
System.arraycopy(this.get(), 0, data, 0, count);
}
bytes = data;
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common-test
/**
* Test of getCapacity method, of class org.apache.hadoop.record.Buffer.
*/
public void testGetCapacity() {
final Buffer instance = new Buffer();
final int expResult = 0;
final int result = instance.getCapacity();
assertEquals("getCapacity failed", expResult, result);
instance.setCapacity(100);
assertEquals("setCapacity failed", 100, instance.getCapacity());
}
代码示例来源:origin: org.apache.hadoop/hadoop-common-test
/**
* Test of truncate method, of class org.apache.hadoop.record.Buffer.
*/
public void testTruncate() {
final Buffer instance = new Buffer();
instance.setCapacity(100);
assertEquals("setCapacity failed", 100, instance.getCapacity());
instance.truncate();
assertEquals("truncate failed", 0, instance.getCapacity());
}
代码示例来源:origin: org.apache.hadoop/hadoop-common-test
/**
* Test of copy method, of class org.apache.hadoop.record.Buffer.
*/
public void testCopy() {
final byte[] bytes = new byte[10];
final int offset = 6;
final int length = 3;
for (int idx = 0; idx < 10; idx ++) {
bytes[idx] = (byte) idx;
}
final Buffer instance = new Buffer();
instance.copy(bytes, offset, length);
assertEquals("copy failed", 3, instance.getCapacity());
assertEquals("copy failed", 3, instance.get().length);
for (int idx = 0; idx < 3; idx++) {
assertEquals("Buffer content corrupted", idx+6, instance.get()[idx]);
}
}
内容来源于网络,如有侵权,请联系作者删除!