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


Java WritableMemory.wrap方法代码示例

本文整理汇总了Java中com.yahoo.memory.WritableMemory.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java WritableMemory.wrap方法的具体用法?Java WritableMemory.wrap怎么用?Java WritableMemory.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yahoo.memory.WritableMemory的用法示例。


在下文中一共展示了WritableMemory.wrap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invalidSerVer

import com.yahoo.memory.WritableMemory; //导入方法依赖的package包/类
@Test
public void invalidSerVer() {
  final int nRows = 3;
  final int nCols = 3;
  final Matrix m = generateIncreasingEye(nRows, nCols);
  final byte[] sketchBytes = m.toByteArray();
  final WritableMemory mem = WritableMemory.wrap(sketchBytes);
  MatrixPreambleUtil.insertSerVer(mem.getArray(), mem.getCumulativeOffset(0L), 0);

  try {
    MatrixImplOjAlgo.heapifyInstance(mem);
    fail();
  } catch (final IllegalArgumentException e) {
    // expected
  }
}
 
开发者ID:DataSketches,项目名称:sketches-vector,代码行数:17,代码来源:MatrixImplOjAlgoTest.java

示例2: invalidFamily

import com.yahoo.memory.WritableMemory; //导入方法依赖的package包/类
@Test
public void invalidFamily() {
  final int nRows = 3;
  final int nCols = 3;
  final Matrix m = generateIncreasingEye(nRows, nCols);
  final byte[] sketchBytes = m.toByteArray();
  final WritableMemory mem = WritableMemory.wrap(sketchBytes);
  MatrixPreambleUtil.insertFamilyID(mem.getArray(), mem.getCumulativeOffset(0L), 0);

  try {
    MatrixImplOjAlgo.heapifyInstance(mem);
    fail();
  } catch (final IllegalArgumentException e) {
    // expected
  }
}
 
开发者ID:DataSketches,项目名称:sketches-vector,代码行数:17,代码来源:MatrixImplOjAlgoTest.java

示例3: invalidSerVer

import com.yahoo.memory.WritableMemory; //导入方法依赖的package包/类
@Test
public void invalidSerVer() {
  final int nRows = 50;
  final int nCols = 75;
  final MatrixBuilder mb = new MatrixBuilder();
  final Matrix m = mb.build(nRows, nCols);
  final byte[] sketchBytes = m.toByteArray();
  final WritableMemory mem = WritableMemory.wrap(sketchBytes);
  MatrixPreambleUtil.insertSerVer(mem.getArray(), mem.getCumulativeOffset(0L), 0);

  try {
    MatrixPreambleUtil.preambleToString(mem);
    fail();
  } catch (final IllegalArgumentException e) {
    // expected
  }
}
 
开发者ID:DataSketches,项目名称:sketches-vector,代码行数:18,代码来源:MatrixTest.java

示例4: invalidFamily

import com.yahoo.memory.WritableMemory; //导入方法依赖的package包/类
@Test
public void invalidFamily() {
  final int nRows = 3;
  final int nCols = 3;
  final MatrixBuilder mb = new MatrixBuilder();
  final Matrix m = mb.build(nRows, nCols);
  final byte[] sketchBytes = m.toByteArray();
  final WritableMemory mem = WritableMemory.wrap(sketchBytes);
  MatrixPreambleUtil.insertFamilyID(mem.getArray(), mem.getCumulativeOffset(0L), 0);

  try {
    MatrixPreambleUtil.preambleToString(mem);
    fail();
  } catch (final IllegalArgumentException e) {
    // expected
  }
}
 
开发者ID:DataSketches,项目名称:sketches-vector,代码行数:18,代码来源:MatrixTest.java

示例5: toByteArray

import com.yahoo.memory.WritableMemory; //导入方法依赖的package包/类
/**
 * Returns a serialized representation of the sketch.
 * @return A serialized representation of the sketch.
 */
public byte[] toByteArray() {
  final boolean empty = isEmpty();
  final int familyId = MatrixFamily.FREQUENTDIRECTIONS.getID();

  final Matrix wrapB = Matrix.wrap(B_);

  final int preLongs = empty
          ? MatrixFamily.FREQUENTDIRECTIONS.getMinPreLongs()
          : MatrixFamily.FREQUENTDIRECTIONS.getMaxPreLongs();

  final int mtxBytes = empty ? 0 : wrapB.getCompactSizeBytes(nextZeroRow_, d_);
  final int outBytes = (preLongs * Long.BYTES) + mtxBytes;

  final byte[] outArr = new byte[outBytes];
  final WritableMemory memOut = WritableMemory.wrap(outArr);
  final Object memObj = memOut.getArray();
  final long memAddr = memOut.getCumulativeOffset(0L);

  insertPreLongs(memObj, memAddr, preLongs);
  insertSerVer(memObj, memAddr, SER_VER);
  insertFamilyID(memObj, memAddr, familyId);
  insertFlags(memObj, memAddr, (empty ? EMPTY_FLAG_MASK : 0));
  insertK(memObj, memAddr, k_);
  insertNumRows(memObj, memAddr, nextZeroRow_);
  insertNumColumns(memObj, memAddr, d_);

  if (empty) {
    return outArr;
  }

  insertN(memObj, memAddr, n_);
  insertSVAdjustment(memObj, memAddr, svAdjustment_);

  memOut.putByteArray(preLongs * Long.BYTES,
          wrapB.toCompactByteArray(nextZeroRow_, d_), 0, mtxBytes);

  return outArr;
}
 
开发者ID:DataSketches,项目名称:sketches-vector,代码行数:43,代码来源:FrequentDirections.java


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