gpt4 book ai didi

com.yahoo.memory.WritableMemory.copyTo()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 20:59:05 24 4
gpt4 key购买 nike

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

WritableMemory.copyTo介绍

暂无

代码示例

代码示例来源:origin: DataSketches/sketches-core

@Override
void serializeInto(final WritableMemory mem) {
 mem_.copyTo(0, mem, 0, mem.getCapacity());
}

代码示例来源:origin: DataSketches/sketches-core

@Override
long[] getCache() {
 final long lgArrLongs = mem_.getByte(LG_ARR_LONGS_BYTE) & 0XFF;
 final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;
 final long[] cacheArr = new long[1 << lgArrLongs];
 final WritableMemory mem = WritableMemory.wrap(cacheArr);
 mem_.copyTo(preambleLongs << 3, mem, 0, 8 << lgArrLongs);
 return cacheArr;
}

代码示例来源:origin: DataSketches/sketches-core

@Override
public byte[] toByteArray() { //MY_FAMILY is stored in mem_
 final byte lgArrLongs = mem_.getByte(LG_ARR_LONGS_BYTE);
 final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;
 final int lengthBytes = (preambleLongs + (1 << lgArrLongs)) << 3;
 final byte[] byteArray = new byte[lengthBytes];
 final WritableMemory mem = WritableMemory.wrap(byteArray);
 mem_.copyTo(0, mem, 0, lengthBytes);
 return byteArray;
}

代码示例来源:origin: DataSketches/sketches-core

private WritableMemory growCombinedMemBuffer(final int itemSpaceNeeded) {
  final long memBytes = mem_.getCapacity();
  final int needBytes = (itemSpaceNeeded << 3) + COMBINED_BUFFER; //+ preamble + min & max
  assert needBytes > memBytes;

  memReqSvr = (memReqSvr == null) ? mem_.getMemoryRequestServer() : memReqSvr;

  final WritableMemory newMem = memReqSvr.request(needBytes);

  mem_.copyTo(0, newMem, 0, memBytes);

  memReqSvr.requestClose(mem_, newMem);

  return newMem;
 }
}

代码示例来源:origin: DataSketches/sketches-core

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkSizeTooSmall() {
 int k = 16;
 WritableMemory mem = WritableMemory.wrap(new byte[(k*16) +32]); //initialized
 SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, mem);
 println(setOp.toString());
 WritableMemory mem2 = WritableMemory.wrap(new byte[32]); //for just preamble
 mem.copyTo(0, mem2, 0, 32); //too small
 DirectQuickSelectSketch.writableWrap(mem2, Util.DEFAULT_UPDATE_SEED);
}

代码示例来源:origin: DataSketches/sketches-core

private static final void grow(final DirectHllArray host, final int oldLgAuxArrInts) {
 final int oldAuxArrInts = 1 << oldLgAuxArrInts;
 final int[] oldIntArray = new int[oldAuxArrInts]; //buffer old aux data
 host.wmem.getIntArray(host.auxStart, oldIntArray, 0, oldAuxArrInts);
 insertLgArr(host.wmem, oldLgAuxArrInts + 1); //update LgArr field
 final long newAuxBytes = oldAuxArrInts << 3;
 final long requestBytes = host.auxStart + newAuxBytes;
 final long oldCapBytes = host.wmem.getCapacity();
 if (requestBytes > oldCapBytes) {
  final MemoryRequestServer svr = host.wmem.getMemoryRequestServer();
  final WritableMemory newWmem = svr.request(requestBytes);
  host.wmem.copyTo(0, newWmem, 0, host.auxStart);
  newWmem.clear(host.auxStart, newAuxBytes); //clear space for new aux data
  svr.requestClose(host.wmem, newWmem); //old host.wmem is now invalid
  host.updateMemory(newWmem);
 }
 //rehash into larger aux array
 final int configKmask = (1 << host.lgConfigK) - 1;
 for (int i = 0; i < oldAuxArrInts; i++) {
  final int fetched = oldIntArray[i];
  if (fetched != EMPTY) {
   //find empty in new array
   final int index = find(host, fetched & configKmask);
   host.wmem.putInt(host.auxStart + (~index << 2), fetched);
  }
 }
}

代码示例来源:origin: com.yahoo.datasketches/sketches-core

@Override
void serializeInto(final WritableMemory mem) {
 mem_.copyTo(0, mem, 0, mem.getCapacity());
}

代码示例来源:origin: DataSketches/sketches-core

wmem2.copyTo(0, wmem3, 0, wmem2.getCapacity());
HllSketch dst3 = HllSketch.writableWrap(wmem3);

代码示例来源:origin: DataSketches/sketches-core

mem.copyTo(0, mem2, 0, mem2.getCapacity());
try {
 HeapAlphaSketch.heapifyInstance(mem2, DEFAULT_UPDATE_SEED);

代码示例来源:origin: DataSketches/sketches-core

mem.copyTo(0, mem2, 0, mem2.getCapacity());
try {
 HeapQuickSelectSketch.heapifyInstance(mem2, DEFAULT_UPDATE_SEED);

代码示例来源:origin: com.yahoo.datasketches/sketches-core

@Override
public byte[] toByteArray() { //MY_FAMILY is stored in mem_
 final byte lgArrLongs = mem_.getByte(LG_ARR_LONGS_BYTE);
 final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;
 final int lengthBytes = (preambleLongs + (1 << lgArrLongs)) << 3;
 final byte[] byteArray = new byte[lengthBytes];
 final WritableMemory mem = WritableMemory.wrap(byteArray);
 mem_.copyTo(0, mem, 0, lengthBytes);
 return byteArray;
}

代码示例来源:origin: com.yahoo.datasketches/sketches-core

@Override
long[] getCache() {
 final long lgArrLongs = mem_.getByte(LG_ARR_LONGS_BYTE) & 0XFF;
 final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;
 final long[] cacheArr = new long[1 << lgArrLongs];
 final WritableMemory mem = WritableMemory.wrap(cacheArr);
 mem_.copyTo(preambleLongs << 3, mem, 0, 8 << lgArrLongs);
 return cacheArr;
}

代码示例来源:origin: com.yahoo.datasketches/sketches-core

private WritableMemory growCombinedMemBuffer(final int itemSpaceNeeded) {
  final long memBytes = mem_.getCapacity();
  final int needBytes = (itemSpaceNeeded << 3) + COMBINED_BUFFER; //+ preamble + min & max
  assert needBytes > memBytes;

  memReqSvr = (memReqSvr == null) ? mem_.getMemoryRequestServer() : memReqSvr;

  final WritableMemory newMem = memReqSvr.request(needBytes);

  mem_.copyTo(0, newMem, 0, memBytes);

  memReqSvr.requestClose(mem_, newMem);

  return newMem;
 }
}

代码示例来源:origin: com.yahoo.datasketches/sketches-core

private static final void grow(final DirectHllArray host, final int oldLgAuxArrInts) {
 final int oldAuxArrInts = 1 << oldLgAuxArrInts;
 final int[] oldIntArray = new int[oldAuxArrInts]; //buffer old aux data
 host.wmem.getIntArray(host.auxStart, oldIntArray, 0, oldAuxArrInts);
 insertLgArr(host.wmem, oldLgAuxArrInts + 1); //update LgArr field
 final long newAuxBytes = oldAuxArrInts << 3;
 final long requestBytes = host.auxStart + newAuxBytes;
 final long oldCapBytes = host.wmem.getCapacity();
 if (requestBytes > oldCapBytes) {
  final MemoryRequestServer svr = host.wmem.getMemoryRequestServer();
  final WritableMemory newWmem = svr.request(requestBytes);
  host.wmem.copyTo(0, newWmem, 0, host.auxStart);
  newWmem.clear(host.auxStart, newAuxBytes); //clear space for new aux data
  svr.requestClose(host.wmem, newWmem); //old host.wmem is now invalid
  host.updateMemory(newWmem);
 }
 //rehash into larger aux array
 final int configKmask = (1 << host.lgConfigK) - 1;
 for (int i = 0; i < oldAuxArrInts; i++) {
  final int fetched = oldIntArray[i];
  if (fetched != EMPTY) {
   //find empty in new array
   final int index = find(host, fetched & configKmask);
   host.wmem.putInt(host.auxStart + (~index << 2), fetched);
  }
 }
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com