本文整理汇总了Java中org.apache.giraph.utils.WritableUtils.writeToByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java WritableUtils.writeToByteArray方法的具体用法?Java WritableUtils.writeToByteArray怎么用?Java WritableUtils.writeToByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.utils.WritableUtils
的用法示例。
在下文中一共展示了WritableUtils.writeToByteArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVectorSerialize
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
int size = 100;
// Serialize from
IntVector from = new IntVector(size);
from.set(0, 10);
from.set(10, 5);
from.set(12, 1);
byte[] data = WritableUtils.writeToByteArray(from);
// De-serialize to
IntVector to = new IntVector();
WritableUtils.readFieldsFromByteArray(data, to);
// The vectors should be equal
for (int i = 0; i < size; ++i) {
assertEquals(from.get(i), to.get(i));
}
}
示例2: testVectorSerialize
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
int size = 100;
// Serialize from
FloatVector from = new FloatVector(size);
from.set(0, 10.0f);
from.set(10, 5.0f);
from.set(12, 1.0f);
byte[] data = WritableUtils.writeToByteArray(from);
// De-serialize to
FloatVector to = new FloatVector();
WritableUtils.readFieldsFromByteArray(data, to);
// The vectors should be equal
for (int i = 0; i < size; ++i) {
assertEquals(from.get(i), to.get(i), E);
}
}
示例3: testVectorSerialize
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
int size = 100;
// Serialize from
DoubleVector from = new DoubleVector(size);
from.set(0, 10.0);
from.set(10, 5.0);
from.set(12, 1.0);
byte[] data = WritableUtils.writeToByteArray(from);
// De-serialize to
DoubleVector to = new DoubleVector();
WritableUtils.readFieldsFromByteArray(data, to);
// The vectors should be equal
for (int i = 0; i < size; ++i) {
assertEquals(from.get(i), to.get(i), E);
}
}
示例4: testVectorSerialize
import org.apache.giraph.utils.WritableUtils; //导入方法依赖的package包/类
@Test
public void testVectorSerialize() throws Exception {
int size = 100;
// Serialize from
LongVector from = new LongVector(size);
from.set(0, 10);
from.set(10, 5);
from.set(12, 1);
byte[] data = WritableUtils.writeToByteArray(from);
// De-serialize to
LongVector to = new LongVector();
WritableUtils.readFieldsFromByteArray(data, to);
// The vectors should be equal
for (int i = 0; i < size; ++i) {
assertEquals(from.get(i), to.get(i));
}
}