gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-23 21:11:05 27 4
gpt4 key购买 nike

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

WritableMemory.putDouble介绍

[英]Puts the double value at the given offset
[中]将双精度值置于给定偏移量处

代码示例

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

@Override
protected void setValues(final int index, final double[] values) {
 long offset = valuesOffset_ + ((long) SIZE_OF_VALUE_BYTES * numValues_ * index);
 for (int i = 0; i < numValues_; i++) {
  mem_.putDouble(offset, values[i]);
  offset += SIZE_OF_VALUE_BYTES;
 }
}

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

static void insertMaxDouble(final WritableMemory wmem, final double value) {
  wmem.putDouble(MAX_DOUBLE, value);
 }
}

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

static void insertHipAccum(final WritableMemory wmem, final double hipAccum) {
 wmem.putDouble(HIP_ACCUM_DOUBLE, hipAccum);
}

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

static void insertMinDouble(final WritableMemory wmem, final double value) {
 wmem.putDouble(MIN_DOUBLE, value);
}

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

static void insertTotalRWeight(final WritableMemory wmem, final double weight) {
 wmem.putDouble(TOTAL_WEIGHT_R_DOUBLE, weight);
}

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

static void insertOuterTauNumerator(final WritableMemory wmem, final double numer) {
 wmem.putDouble(OUTER_TAU_NUM_DOUBLE, numer);
}

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

static void insertKxQ0(final WritableMemory wmem, final double kxq0) {
 wmem.putDouble(KXQ0_DOUBLE, kxq0);
}

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

static void insertKxQ1(final WritableMemory wmem, final double kxq1) {
 wmem.putDouble(KXQ1_DOUBLE, kxq1);
}

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

@Override
public byte[] serializeToByteArray(final Double[] items) {
 final byte[] bytes = new byte[Double.BYTES * items.length];
 final WritableMemory mem = WritableMemory.wrap(bytes);
 long offsetBytes = 0;
 for (int i = 0; i < items.length; i++) {
  mem.putDouble(offsetBytes, items[i]);
  offsetBytes += Double.BYTES;
 }
 return bytes;
}

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

@Override
void putMinValue(final double minValue) {
 assert (mem_.getCapacity() >= COMBINED_BUFFER);
 mem_.putDouble(MIN_DOUBLE, minValue);
}

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

@Override
void putMaxValue(final double maxValue) {
 assert (mem_.getCapacity() >= COMBINED_BUFFER);
 mem_.putDouble(MAX_DOUBLE, maxValue);
}

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

@Override
protected void updateValues(final int index, final double[] values) {
 long offset = valuesOffset_ + ((long) SIZE_OF_VALUE_BYTES * numValues_ * index);
 for (int i = 0; i < numValues_; i++) {
  mem_.putDouble(offset, mem_.getDouble(offset) + values[i]);
  offset += SIZE_OF_VALUE_BYTES;
 }
}

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

@Override
void addToHipAccum(final double delta) {
 final double hipAccum = mem.getDouble(HIP_ACCUM_DOUBLE);
 wmem.putDouble(HIP_ACCUM_DOUBLE, hipAccum + delta);
}

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

@Override
public void reset() {
 if (mem_.getCapacity() >= COMBINED_BUFFER) {
  mem_.putByte(FLAGS_BYTE, (byte) EMPTY_FLAG_MASK); //not compact, not ordered
  mem_.putLong(N_LONG, 0L);
  mem_.putDouble(MIN_DOUBLE, Double.NaN);
  mem_.putDouble(MAX_DOUBLE, Double.NaN);
 }
}

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

@Override
double set(final int index, final double value) {
 assert index >= 0 && index < numItems_;
 assert n_ == ds_.getN();
 assert !ds_.isCompact(); // can't write to a compact sketch
 final int idxOffset = offset_ + (index << 3);
 final WritableMemory mem = ds_.getMemory();
 final double oldVal = mem.getDouble(idxOffset);
 mem.putDouble(idxOffset, value);
 return oldVal;
}

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

static void putPinnedSlidingHipNoSv(final WritableMemory wmem,
  final int lgK,
  final int fiCol,
  final int numCoupons, //unsigned
  final int wLengthInts,
  final double kxp,
  final double hipAccum,
  final short seedHash,
  final int[] wStream) {
 final Format format = Format.PINNED_SLIDING_HIP_NOSV;
 final byte preInts = getDefinedPreInts(format);
 final byte flags = (byte) ((format.ordinal() << 2) | COMPRESSED_FLAG_MASK);
 checkCapacity(wmem.getCapacity(), 4L * (preInts + wLengthInts));
 putFirst8(wmem, preInts, (byte) lgK, (byte) fiCol, flags, seedHash);
 wmem.putInt(getHiFieldOffset(format, HiField.NUM_COUPONS), numCoupons);
 wmem.putInt(getHiFieldOffset(format, HiField.W_LENGTH_INTS), wLengthInts);
 wmem.putDouble(getHiFieldOffset(format, HiField.KXP), kxp);
 wmem.putDouble(getHiFieldOffset(format, HiField.HIP_ACCUM), hipAccum);
 wmem.putIntArray(getWStreamOffset(wmem), wStream, 0, wLengthInts);
}

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

static void putSparseHybridHip(final WritableMemory wmem,
  final int lgK,
  final int numCoupons, //unsigned
  final int svLengthInts,
  final double kxp,
  final double hipAccum,
  final short seedHash,
  final int[] svStream) {
 final Format format = Format.SPARSE_HYBRID_HIP;
 final byte preInts = getDefinedPreInts(format);
 final byte fiCol = (byte) 0;
 final byte flags = (byte) ((format.ordinal() << 2) | COMPRESSED_FLAG_MASK);
 checkCapacity(wmem.getCapacity(), 4L * (preInts + svLengthInts));
 putFirst8(wmem, preInts, (byte) lgK, fiCol, flags, seedHash);
 wmem.putInt(getHiFieldOffset(format, HiField.NUM_COUPONS), numCoupons);
 wmem.putInt(getHiFieldOffset(format, HiField.SV_LENGTH_INTS), svLengthInts);
 wmem.putDouble(getHiFieldOffset(format, HiField.KXP), kxp);
 wmem.putDouble(getHiFieldOffset(format, HiField.HIP_ACCUM), hipAccum);
 wmem.putIntArray(getSvStreamOffset(wmem), svStream, 0, svLengthInts);
}

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

@Test
public void checkCorruptSerializedWeight() {
 final VarOptItemsSketch<String> vis = VarOptItemsSketch.newInstance(24);
 for (int i = 1; i < 10; ++i) {
  vis.update(Integer.toString(i), i);
 }
 final byte[] sketchBytes = vis.toByteArray(new ArrayOfStringsSerDe(), String.class);
 final WritableMemory mem = WritableMemory.wrap(sketchBytes);
 // weights will be stored in the first double after the preamble
 final int numPreLongs = PreambleUtil.extractPreLongs(mem);
 final int weightOffset = numPreLongs << 3;
 mem.putDouble(weightOffset, -1.25); // inject a negative weight
 try {
  VarOptItemsSketch.heapify(mem, new ArrayOfStringsSerDe());
  fail();
 } catch (final SketchesArgumentException e) {
  assertTrue(e.getMessage().equals("Possible Corruption: Non-positive weight in "
      + "heapify(): -1.25"));
 }
}

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

static void putPinnedSlidingHip(final WritableMemory wmem,
  final int lgK,
  final int fiCol,
  final int numCoupons, //unsigned
  final int numSv,
  final double kxp,
  final double hipAccum,
  final int svLengthInts,
  final int wLengthInts,
  final short seedHash,
  final int[] svStream,
  final int[] wStream) {
 final Format format = Format.PINNED_SLIDING_HIP;
 final byte preInts = getDefinedPreInts(format);
 final byte flags = (byte) ((format.ordinal() << 2) | COMPRESSED_FLAG_MASK);
 checkCapacity(wmem.getCapacity(), 4L * (preInts + svLengthInts + wLengthInts));
 putFirst8(wmem, preInts, (byte) lgK, (byte) fiCol, flags, seedHash);
 wmem.putInt(getHiFieldOffset(format, HiField.NUM_COUPONS), numCoupons);
 wmem.putInt(getHiFieldOffset(format, HiField.NUM_SV), numSv);
 wmem.putDouble(getHiFieldOffset(format, HiField.KXP), kxp);
 wmem.putDouble(getHiFieldOffset(format, HiField.HIP_ACCUM), hipAccum);
 wmem.putInt(getHiFieldOffset(format, HiField.SV_LENGTH_INTS), svLengthInts);
 wmem.putInt(getHiFieldOffset(format, HiField.W_LENGTH_INTS), wLengthInts);
 wmem.putIntArray(getSvStreamOffset(wmem), svStream, 0, svLengthInts);
 wmem.putIntArray(getWStreamOffset(wmem), wStream, 0, wLengthInts);
}

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

@Test
public void checkHeapifyUnsortedCompactV2() {
 final int k = 64;
 final UpdateDoublesSketch qs = DoublesSketch.builder().setK(64).build();
 for (int i = 0; i < (3 * k); ++i) {
  qs.update(i);
 }
 assertEquals(qs.getBaseBufferCount(), k);
 final byte[] sketchBytes = qs.toByteArray(true);
 final WritableMemory mem = WritableMemory.wrap(sketchBytes);
 // modify to make v2, clear compact flag, and insert a -1 in the middle of the base buffer
 PreambleUtil.insertSerVer(mem, 2);
 PreambleUtil.insertFlags(mem, 0);
 final long tgtAddr = COMBINED_BUFFER + ((Double.BYTES * k) / 2);
 mem.putDouble(tgtAddr, -1.0);
 assert mem.getDouble(tgtAddr - Double.BYTES) > mem.getDouble(tgtAddr);
 // ensure the heapified base buffer is sorted
 final HeapCompactDoublesSketch qs2 = HeapCompactDoublesSketch.heapifyInstance(mem);
 checkBaseBufferIsSorted(qs2);
}

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