gpt4 book ai didi

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

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

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

WritableMemory.putInt介绍

[英]Puts the int value at the given offset
[中]将int值置于给定的偏移量

代码示例

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

static void insertCurCount(final WritableMemory wmem, final int curCount) {
 wmem.putInt(RETAINED_ENTRIES_INT, curCount);
}

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

static void putPinnedSlidingMergedNoSv(final WritableMemory wmem,
  final int lgK,
  final int fiCol,
  final int numCoupons, //unsigned
  final int wLengthInts,
  final short seedHash,
  final int[] wStream) {
 final Format format = Format.PINNED_SLIDING_MERGED_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.putIntArray(getWStreamOffset(wmem), wStream, 0, wLengthInts);
}

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

static void insertHashSetCount(final WritableMemory wmem, final int hashSetCnt) {
 wmem.putInt(HASH_SET_COUNT_INT, hashSetCnt);
}

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

static void putSparseHybridMerged(final WritableMemory wmem,
  final int lgK,
  final int numCoupons, //unsigned
  final int svLengthInts,
  final short seedHash,
  final int[] svStream) {
 final Format format = Format.SPARSE_HYBRID_MERGED;
 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.putIntArray(getSvStreamOffset(wmem), svStream, 0, svLengthInts);
}

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

static void insertHRegionItemCount(final WritableMemory wmem, final int hCount) {
 wmem.putInt(ITEM_COUNT_H_INT, hCount);
}

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

static void insertAuxCount(final WritableMemory wmem, final int auxCount) {
 wmem.putInt(AUX_COUNT_INT, auxCount);
}

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

static void insertK(final WritableMemory wmem, final int k) {
 wmem.putInt(RESERVOIR_SIZE_INT, k);
}

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

static void insertNumAtCurMin(final WritableMemory wmem, final int numAtCurMin) {
 wmem.putInt(CUR_MIN_COUNT_INT, numAtCurMin);
}

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

static void insertInt(final WritableMemory wmem, final long byteOffset, final int value) {
 wmem.putInt(byteOffset, value);
}

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

static void insertRRegionItemCount(final WritableMemory wmem, final int rCount) {
 wmem.putInt(ITEM_COUNT_R_INT, rCount);
}

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

@Override
void decNumAtCurMin() {
 int numAtCurMin = mem.getInt(CUR_MIN_COUNT_INT);
 wmem.putInt(CUR_MIN_COUNT_INT, --numAtCurMin);
}

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

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

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

@Override
protected void incrementCount() {
 final int count = mem_.getInt(RETAINED_ENTRIES_INT);
 if (count == 0) {
  mem_.setBits(FLAGS_BYTE, (byte) (1 << Flags.HAS_ENTRIES.ordinal()));
 }
 mem_.putInt(RETAINED_ENTRIES_INT, count + 1);
}

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

private static final void insertHll(final AbstractHllArray impl, final WritableMemory wmem,
  final boolean compact) {
 insertCommonHll(impl, wmem, compact);
 final byte[] hllByteArr = ((HllArray)impl).hllByteArr;
 wmem.putByteArray(HLL_BYTE_ARR_START, hllByteArr, 0, hllByteArr.length);
 if (impl.getAuxHashMap() != null) {
  insertAux(impl, wmem, compact);
 } else {
  wmem.putInt(AUX_COUNT_INT, 0);
 }
}

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

@Override
public void mustReplace(final int slotNo, final int value) {
 final int index = find(host, slotNo);
 if (index >= 0) {
  host.wmem.putInt(host.auxStart + (index << 2), HllUtil.pair(slotNo, value));
  return;
 }
 final String pairStr = HllUtil.pairString(HllUtil.pair(slotNo, value));
 throw new SketchesStateException("Pair not found: " + pairStr);
}

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

@Override
public void reset() {
 if (!isEmpty_) {
  isEmpty_ = true;
  mem_.setBits(FLAGS_BYTE, (byte) (1 << Flags.IS_EMPTY.ordinal()));
 }
 final int lgResizeFactor = mem_.getByte(LG_RESIZE_FACTOR_BYTE);
 final float samplingProbability = mem_.getFloat(SAMPLING_P_FLOAT);
 final int startingCapacity = Util.getStartingCapacity(getNominalEntries(), lgResizeFactor);
 theta_ = (long) (Long.MAX_VALUE * (double) samplingProbability);
 mem_.putLong(THETA_LONG, theta_);
 mem_.putByte(LG_CUR_CAPACITY_BYTE, (byte) Integer.numberOfTrailingZeros(startingCapacity));
 mem_.putInt(RETAINED_ENTRIES_INT, 0);
 keysOffset_ = ENTRIES_START;
 valuesOffset_ = keysOffset_ + (SIZE_OF_KEY_BYTES * startingCapacity);
 mem_.clear(keysOffset_, (long) SIZE_OF_KEY_BYTES * startingCapacity); // clear keys only
 lgCurrentCapacity_ = Integer.numberOfTrailingZeros(startingCapacity);
 setRebuildThreshold();
}

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

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkExceptions2() {
 int k = 16;
 WritableMemory mem = WritableMemory.wrap(new byte[(k*16) + PREBYTES]);
 IntersectionImpl.initNewDirectInstance(DEFAULT_UPDATE_SEED, mem);
 //mem now has non-empty intersection
 //corrupt empty and CurCount
 mem.setBits(PreambleUtil.FLAGS_BYTE, (byte) PreambleUtil.EMPTY_FLAG_MASK);
 mem.putInt(PreambleUtil.RETAINED_ENTRIES_INT, 2);
 IntersectionImplR.wrapInstance(mem, DEFAULT_UPDATE_SEED);
}

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

@Override
public void reset() {
 //clear hash table
 //hash table size and hashTableThreshold stays the same
 //lgArrLongs stays the same
 //thetaLongs resets to p
 final int arrLongs = 1 << getLgArrLongs();
 final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;
 final int preBytes = preambleLongs << 3;
 mem_.clear(preBytes, arrLongs * 8L); //clear data array
 //flags: bigEndian = readOnly = compact = ordered = false; empty = true.
 mem_.putByte(FLAGS_BYTE, (byte) EMPTY_FLAG_MASK);
 mem_.putInt(RETAINED_ENTRIES_INT, 0);
 final float p = mem_.getFloat(P_FLOAT);
 final long thetaLong = (long) (p * MAX_THETA_LONG_AS_DOUBLE);
 mem_.putLong(THETA_LONG, thetaLong);
}

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

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadEmptyState() {
 Intersection inter1 = SetOperation.builder().buildIntersection(); //virgin
 UpdateSketch sk = Sketches.updateSketchBuilder().build();
 inter1.update(sk); //initializes to a true empty intersection.
 byte[] byteArray = inter1.toByteArray();
 WritableMemory mem = WritableMemory.wrap(byteArray);
 //corrupt:
 mem.putInt(RETAINED_ENTRIES_INT, 1);
 SetOperation.heapify(mem);
}

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

@Test(expectedExceptions = SketchesArgumentException.class)
public void checkSerVer1_32Bytes_tooSmall() {
 byte[] byteArray = new byte[32];
 WritableMemory mem = WritableMemory.wrap(byteArray);
 mem.putByte(0, (byte) 3); //mdLongs
 mem.putByte(1, (byte) 1); //SerVer
 mem.putByte(2, (byte) 3); //SketchType = SetSketch
 //byte 3 lgNomLongs not used with SetSketch
 //byte 4 lgArrLongs not used with SetSketch
 //byte 5 lgRR not used with SetSketch
 //byte 6: Flags: b0: BigEnd, b1: ReadOnly
 mem.putByte(6, (byte) 2);
 //byte 7 Not used
 mem.putInt(8, 2); //curCount = 2
 mem.putLong(16, Long.MAX_VALUE);
 Memory srcMem = Memory.wrap(byteArray);
 Sketch.heapify(srcMem);
}

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