当前位置: 首页>>代码示例>>Java>>正文


Java WritableUtils.writeToByteArray方法代码示例

本文整理汇总了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));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestIntMatrix.java

示例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);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestFloatMatrix.java

示例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);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestDoubleMatrix.java

示例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));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:21,代码来源:TestLongMatrix.java


注:本文中的org.apache.giraph.utils.WritableUtils.writeToByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。