- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.yahoo.memory.WritableMemory.putShort()
方法的一些代码示例,展示了WritableMemory.putShort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WritableMemory.putShort()
方法的具体详情如下:
包路径:com.yahoo.memory.WritableMemory
类名称:WritableMemory
方法名:putShort
[英]Puts the short value at the given offset
[中]将短值置于给定偏移量处
代码示例来源:origin: DataSketches/sketches-core
static void insertSeedHash(final WritableMemory wmem, final int seedHash) {
wmem.putShort(SEED_HASH_SHORT, (short) seedHash);
}
代码示例来源:origin: DataSketches/sketches-core
static void insertK(final WritableMemory wmem, final int value) {
wmem.putShort(K_SHORT, (short) value);
}
代码示例来源:origin: DataSketches/sketches-core
static final void put6Bit(final WritableMemory wmem, final int offsetBytes, final int slotNo,
final int newValue) {
final int startBit = slotNo * 6;
final int shift = startBit & 0X7;
final int byteIdx = (startBit >>> 3) + offsetBytes;
final int valShifted = (newValue & 0X3F) << shift;
final int curMasked = wmem.getShort(byteIdx) & (~(VAL_MASK_6 << shift));
final short insert = (short) (curMasked | valShifted);
wmem.putShort(byteIdx, insert);
}
代码示例来源:origin: DataSketches/sketches-core
IntersectionImplR(final WritableMemory mem, final long seed, final boolean newMem) {
mem_ = mem;
if (mem != null) {
if (newMem) {
seedHash_ = computeSeedHash(seed);
mem_.putShort(SEED_HASH_SHORT, seedHash_);
} else {
seedHash_ = mem_.getShort(SEED_HASH_SHORT);
Util.checkSeedHashes(seedHash_, computeSeedHash(seed)); //check for seed hash conflict
}
} else {
seedHash_ = computeSeedHash(seed);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkSerVer2_8Bytes() {
byte[] byteArray = new byte[8];
WritableMemory mem = WritableMemory.wrap(byteArray);
mem.putByte(0, (byte) 1); //mdLongs, RR = 0
mem.putByte(1, (byte) 2); //SerVer
mem.putByte(2, (byte) 3); //SketchType = SetSketch
//byte 3 lgNomLongs not used w SetSketch
//byte 4 lgArrLongs not used w SetSketch
//byte 5 Flags: b0: BigEnd, b1: ReadOnly, b2: Empty, b3: NoRebuild, b4, Unordered
mem.putByte(5, (byte) 2); //Flags
short seedHash = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED);
mem.putShort(6, seedHash);
//mem.putInt(8, 0); //curCount = 0
//mem.putLong(16, Long.MAX_VALUE);
Memory srcMem = Memory.wrap(byteArray);
Sketch sketch = Sketch.heapify(srcMem);
assertEquals(sketch.isEmpty(), true);
assertEquals(sketch.isEstimationMode(), false);
assertEquals(sketch.isDirect(), false);
assertEquals(sketch.isCompact(), true);
assertEquals(sketch.isOrdered(), true);
String name = sketch.getClass().getSimpleName();
assertEquals(name, "HeapCompactOrderedSketch");
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkSerVer2_24Bytes_1Value() {
byte[] byteArray = new byte[24];
WritableMemory mem = WritableMemory.wrap(byteArray);
mem.putByte(0, (byte) 2); //mdLongs, RF (RR) = 0
mem.putByte(1, (byte) 2); //SerVer
mem.putByte(2, (byte) 3); //SketchType = SetSketch
//byte 3 lgNomLongs not used w SetSketch
//byte 4 lgArrLongs not used w SetSketch
//byte 5 Flags: b0: BigEnd, b1: ReadOnly, b2: Empty, b3: NoRebuild, b4, Unordered
mem.putByte(5, (byte) 2); //Flags = ReadOnly
short seedHash = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED);
mem.putShort(6, seedHash);
mem.putInt(8, 0); //curCount = 0
//mem.putLong(16, Long.MAX_VALUE);
Memory srcMem = Memory.wrap(byteArray);
Sketch sketch = Sketch.heapify(srcMem);
assertEquals(sketch.isEmpty(), false);
assertEquals(sketch.isEstimationMode(), false);
assertEquals(sketch.isDirect(), false);
assertEquals(sketch.isCompact(), true);
assertEquals(sketch.isOrdered(), true);
String name = sketch.getClass().getSimpleName();
assertEquals(name, "HeapCompactOrderedSketch");
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkSerVer2_32Bytes_1Value() {
byte[] byteArray = new byte[32];
WritableMemory mem = WritableMemory.wrap(byteArray);
mem.putByte(0, (byte) 3); //mdLongs, RF (RR) = 0
mem.putByte(1, (byte) 2); //SerVer
mem.putByte(2, (byte) 3); //SketchType = SetSketch
//byte 3 lgNomLongs not used w SetSketch
//byte 4 lgArrLongs not used w SetSketch
//byte 5 Flags: b0: BigEnd, b1: ReadOnly, b2: Empty, b3: NoRebuild, b4, Unordered
mem.putByte(5, (byte) 2); //Flags = ReadOnly
short seedHash = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED);
mem.putShort(6, seedHash);
mem.putInt(8, 0); //curCount = 0
mem.putLong(16, Long.MAX_VALUE);
Memory srcMem = Memory.wrap(byteArray);
Sketch sketch = Sketch.heapify(srcMem);
assertEquals(sketch.isEmpty(), false);
assertEquals(sketch.isEstimationMode(), false);
assertEquals(sketch.isDirect(), false);
assertEquals(sketch.isCompact(), true);
assertEquals(sketch.isOrdered(), true);
String name = sketch.getClass().getSimpleName();
assertEquals(name, "HeapCompactOrderedSketch");
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversion() {
// version change from 1 to 2 only impact first preamble long, so empty sketch is sufficient
final int k = 32768;
final short encK = ReservoirSize.computeSize(k);
final ReservoirLongsSketch rls = ReservoirLongsSketch.newInstance(k);
final byte[] sketchBytesOrig = rls.toByteArray();
// get a new byte[], manually revert to v1, then reconstruct
final byte[] sketchBytes = rls.toByteArray();
final WritableMemory sketchMem = WritableMemory.wrap(sketchBytes);
sketchMem.putByte(SER_VER_BYTE, (byte) 1);
sketchMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
sketchMem.putShort(RESERVOIR_SIZE_SHORT, encK);
final ReservoirLongsSketch rebuilt = ReservoirLongsSketch.heapify(sketchMem);
final byte[] rebuiltBytes = rebuilt.toByteArray();
assertEquals(sketchBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < sketchBytesOrig.length; ++i) {
assertEquals(sketchBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Override
void serializeInto(final WritableMemory mem) {
mem.putByte(PREAMBLE_LONGS_BYTE, (byte) 1);
mem.putByte(SERIAL_VERSION_BYTE, serialVersionUID);
mem.putByte(FAMILY_ID_BYTE, (byte) Family.TUPLE.getID());
mem.putByte(SKETCH_TYPE_BYTE,
(byte) SerializerDeserializer.SketchType.ArrayOfDoublesQuickSelectSketch.ordinal());
final boolean isBigEndian = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN);
mem.putByte(FLAGS_BYTE, (byte)(
(isBigEndian ? 1 << Flags.IS_BIG_ENDIAN.ordinal() : 0)
| (isInSamplingMode() ? 1 << Flags.IS_IN_SAMPLING_MODE.ordinal() : 0)
| (isEmpty_ ? 1 << Flags.IS_EMPTY.ordinal() : 0)
| (count_ > 0 ? 1 << Flags.HAS_ENTRIES.ordinal() : 0)
));
mem.putByte(NUM_VALUES_BYTE, (byte) numValues_);
mem.putShort(SEED_HASH_SHORT, Util.computeSeedHash(seed_));
mem.putLong(THETA_LONG, theta_);
mem.putByte(LG_NOM_ENTRIES_BYTE, (byte) Integer.numberOfTrailingZeros(nomEntries_));
mem.putByte(LG_CUR_CAPACITY_BYTE, (byte) Integer.numberOfTrailingZeros(keys_.length));
mem.putByte(LG_RESIZE_FACTOR_BYTE, (byte) lgResizeFactor_);
mem.putFloat(SAMPLING_P_FLOAT, samplingProbability_);
mem.putInt(RETAINED_ENTRIES_INT, count_);
if (count_ > 0) {
mem.putLongArray(ENTRIES_START, keys_, 0, keys_.length);
mem.putDoubleArray(ENTRIES_START + ((long) SIZE_OF_KEY_BYTES * keys_.length), values_, 0,
values_.length);
}
}
代码示例来源:origin: DataSketches/sketches-core
));
mem_.putByte(NUM_VALUES_BYTE, (byte) numValues);
mem_.putShort(SEED_HASH_SHORT, Util.computeSeedHash(seed));
theta_ = (long) (Long.MAX_VALUE * (double) samplingProbability);
mem_.putLong(THETA_LONG, theta_);
代码示例来源:origin: DataSketches/sketches-core
DirectArrayOfDoublesCompactSketch(final long[] keys, final double[] values, final long theta,
final boolean isEmpty, final int numValues, final short seedHash, final WritableMemory dstMem) {
super(numValues);
checkIfEnoughMemory(dstMem, values.length, numValues);
mem_ = dstMem;
dstMem.putByte(PREAMBLE_LONGS_BYTE, (byte) 1);
dstMem.putByte(SERIAL_VERSION_BYTE, serialVersionUID);
dstMem.putByte(FAMILY_ID_BYTE, (byte) Family.TUPLE.getID());
dstMem.putByte(SKETCH_TYPE_BYTE, (byte)
SerializerDeserializer.SketchType.ArrayOfDoublesCompactSketch.ordinal());
final boolean isBigEndian = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN);
isEmpty_ = isEmpty;
final int count = keys.length;
dstMem.putByte(FLAGS_BYTE, (byte) (
(isBigEndian ? 1 << Flags.IS_BIG_ENDIAN.ordinal() : 0)
| (isEmpty_ ? 1 << Flags.IS_EMPTY.ordinal() : 0)
| (count > 0 ? 1 << Flags.HAS_ENTRIES.ordinal() : 0)
));
dstMem.putByte(NUM_VALUES_BYTE, (byte) numValues_);
dstMem.putShort(SEED_HASH_SHORT, seedHash);
theta_ = theta;
dstMem.putLong(THETA_LONG, theta_);
if (count > 0) {
dstMem.putInt(RETAINED_ENTRIES_INT, count);
dstMem.putLongArray(ENTRIES_START, keys, 0, count);
dstMem.putDoubleArray(
ENTRIES_START + ((long) SIZE_OF_KEY_BYTES * count), values, 0, values.length);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversionWithGadget() {
final long n = 32;
final int k = 256;
final short encK = ReservoirSize.computeSize(k);
final ReservoirLongsUnion rlu = ReservoirLongsUnion.newInstance(k);
for (long i = 0; i < n; ++i) {
rlu.update(i);
}
final byte[] unionBytesOrig = rlu.toByteArray();
// get a new byte[], manually revert to v1, then reconstruct
final byte[] unionBytes = rlu.toByteArray();
final WritableMemory unionMem = WritableMemory.wrap(unionBytes);
unionMem.putByte(SER_VER_BYTE, (byte) 1);
unionMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(RESERVOIR_SIZE_SHORT, encK);
// force gadget header to v1, too
final int offset = Family.RESERVOIR_UNION.getMaxPreLongs() << 3;
unionMem.putByte(offset + SER_VER_BYTE, (byte) 1);
unionMem.putInt(offset + RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(offset + RESERVOIR_SIZE_SHORT, encK);
final ReservoirLongsUnion rebuilt = ReservoirLongsUnion.heapify(unionMem);
final byte[] rebuiltBytes = rebuilt.toByteArray();
assertEquals(unionBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < unionBytesOrig.length; ++i) {
assertEquals(unionBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversionWithEmptyGadget() {
final int k = 32768;
final short encK = ReservoirSize.computeSize(k);
final ReservoirLongsUnion rlu = ReservoirLongsUnion.newInstance(k);
final byte[] unionBytesOrig = rlu.toByteArray();
// get a new byte[], manually revert to v1, then reconstruct
final byte[] unionBytes = rlu.toByteArray();
final WritableMemory unionMem = WritableMemory.wrap(unionBytes);
unionMem.putByte(SER_VER_BYTE, (byte) 1);
unionMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(RESERVOIR_SIZE_SHORT, encK);
println(PreambleUtil.preambleToString(unionMem));
final ReservoirLongsUnion rebuilt = ReservoirLongsUnion.heapify(unionMem);
final byte[] rebuiltBytes = rebuilt.toByteArray();
assertEquals(unionBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < unionBytesOrig.length; ++i) {
assertEquals(unionBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
private static void putFirst8(final WritableMemory wmem, final byte preInts, final byte lgK,
final byte fiCol, final byte flags, final short seedHash) {
wmem.clear(0L, 4L * preInts);
wmem.putByte(getLoFieldOffset(LoField.PRE_INTS), preInts);
wmem.putByte(getLoFieldOffset(LoField.SER_VERSION), SER_VER);
wmem.putByte(getLoFieldOffset(LoField.FAMILY), (byte) Family.CPC.getID());
wmem.putByte(getLoFieldOffset(LoField.LG_K), lgK);
wmem.putByte(getLoFieldOffset(LoField.FI_COL), fiCol);
wmem.putByte(getLoFieldOffset(LoField.FLAGS), flags);
wmem.putShort(getLoFieldOffset(LoField.SEED_HASH), seedHash);
}
代码示例来源:origin: DataSketches/sketches-core
));
mem.putByte(NUM_VALUES_BYTE, (byte) numValues_);
mem.putShort(SEED_HASH_SHORT, seedHash_);
mem.putLong(THETA_LONG, theta_);
if (count > 0) {
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversionWithGadget() {
final long n = 32;
final int k = 256;
final short encK = ReservoirSize.computeSize(k);
final ArrayOfNumbersSerDe serDe = new ArrayOfNumbersSerDe();
final ReservoirItemsUnion<Number> rlu = ReservoirItemsUnion.newInstance(k);
for (long i = 0; i < n; ++i) {
rlu.update(i);
}
final byte[] unionBytesOrig = rlu.toByteArray(serDe);
// get a new byte[], manually revert to v1, then reconstruct
final byte[] unionBytes = rlu.toByteArray(serDe);
final WritableMemory unionMem = WritableMemory.wrap(unionBytes);
unionMem.putByte(SER_VER_BYTE, (byte) 1);
unionMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(RESERVOIR_SIZE_SHORT, encK);
// force gadget header to v1, too
final int offset = Family.RESERVOIR_UNION.getMaxPreLongs() << 3;
unionMem.putByte(offset + SER_VER_BYTE, (byte) 1);
unionMem.putInt(offset + RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(offset + RESERVOIR_SIZE_SHORT, encK);
final ReservoirItemsUnion<Number> rebuilt = ReservoirItemsUnion.heapify(unionMem, serDe);
final byte[] rebuiltBytes = rebuilt.toByteArray(serDe);
assertEquals(unionBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < unionBytesOrig.length; ++i) {
assertEquals(unionBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversionWithEmptyGadget() {
final int k = 32768;
final short encK = ReservoirSize.computeSize(k);
final ArrayOfStringsSerDe serDe = new ArrayOfStringsSerDe();
final ReservoirItemsUnion<String> riu = ReservoirItemsUnion.newInstance(k);
final byte[] unionBytesOrig = riu.toByteArray(serDe);
// get a new byte[], manually revert to v1, then reconstruct
final byte[] unionBytes = riu.toByteArray(serDe);
final WritableMemory unionMem = WritableMemory.wrap(unionBytes);
unionMem.putByte(SER_VER_BYTE, (byte) 1);
unionMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
unionMem.putShort(RESERVOIR_SIZE_SHORT, encK);
println(PreambleUtil.preambleToString(unionMem));
final ReservoirItemsUnion<String> rebuilt = ReservoirItemsUnion.heapify(unionMem, serDe);
final byte[] rebuiltBytes = rebuilt.toByteArray(serDe);
assertEquals(unionBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < unionBytesOrig.length; ++i) {
assertEquals(unionBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
@Test
public void checkVersionConversion() {
// version change from 1 to 2 only impact first preamble long, so empty sketch is sufficient
final int k = 32768;
final short encK = ReservoirSize.computeSize(k);
final ArrayOfLongsSerDe serDe = new ArrayOfLongsSerDe();
final ReservoirItemsSketch<Long> ris = ReservoirItemsSketch.newInstance(k);
final byte[] sketchBytesOrig = ris.toByteArray(serDe);
// get a new byte[], manually revert to v1, then reconstruct
final byte[] sketchBytes = ris.toByteArray(serDe);
final WritableMemory sketchMem = WritableMemory.wrap(sketchBytes);
sketchMem.putByte(SER_VER_BYTE, (byte) 1);
sketchMem.putInt(RESERVOIR_SIZE_INT, 0); // zero out all 4 bytes
sketchMem.putShort(RESERVOIR_SIZE_SHORT, encK);
println(PreambleUtil.preambleToString(sketchMem));
final ReservoirItemsSketch<Long> rebuilt = ReservoirItemsSketch.heapify(sketchMem, serDe);
final byte[] rebuiltBytes = rebuilt.toByteArray(serDe);
assertEquals(sketchBytesOrig.length, rebuiltBytes.length);
for (int i = 0; i < sketchBytesOrig.length; ++i) {
assertEquals(sketchBytesOrig[i], rebuiltBytes[i]);
}
}
代码示例来源:origin: DataSketches/sketches-core
memOut.clearBits(FLAGS_BYTE, (byte) EMPTY_FLAG_MASK);
memOut.putShort(SEED_HASH_SHORT, seedHash_);
memOut.putInt(RETAINED_ENTRIES_INT, curCount_);
memOut.putFloat(P_FLOAT, (float) 1.0);
代码示例来源:origin: DataSketches/sketches-core
));
dstMem.putByte(NUM_VALUES_BYTE, (byte) numValues_);
dstMem.putShort(SEED_HASH_SHORT, Util.computeSeedHash(sketch.getSeed()));
theta_ = Math.min(sketch.getThetaLong(), theta);
dstMem.putLong(THETA_LONG, theta_);
本文整理了Java中com.yahoo.memory.WritableMemory.putByte()方法的一些代码示例,展示了WritableMemory.putByte()的具体用法。这些代码示例
本文整理了Java中com.yahoo.memory.WritableMemory.getDouble()方法的一些代码示例,展示了WritableMemory.getDouble()的具体用法。这些
本文整理了Java中com.yahoo.memory.WritableMemory.copyTo()方法的一些代码示例,展示了WritableMemory.copyTo()的具体用法。这些代码示例主要
本文整理了Java中com.yahoo.memory.WritableMemory.clear()方法的一些代码示例,展示了WritableMemory.clear()的具体用法。这些代码示例主要来源
本文整理了Java中com.yahoo.memory.WritableMemory.getCapacity()方法的一些代码示例,展示了WritableMemory.getCapacity()的具体用
本文整理了Java中com.yahoo.memory.WritableMemory.getLong()方法的一些代码示例,展示了WritableMemory.getLong()的具体用法。这些代码示例
本文整理了Java中com.yahoo.memory.WritableMemory.putDouble()方法的一些代码示例,展示了WritableMemory.putDouble()的具体用法。这些
本文整理了Java中com.yahoo.memory.WritableMemory.putByteArray()方法的一些代码示例,展示了WritableMemory.putByteArray()的具
本文整理了Java中com.yahoo.memory.WritableMemory.getByteArray()方法的一些代码示例,展示了WritableMemory.getByteArray()的具
本文整理了Java中com.yahoo.memory.WritableMemory.putShort()方法的一些代码示例,展示了WritableMemory.putShort()的具体用法。这些代码
本文整理了Java中com.yahoo.memory.WritableMemory.getArray()方法的一些代码示例,展示了WritableMemory.getArray()的具体用法。这些代码
本文整理了Java中com.yahoo.memory.WritableMemory.getByte()方法的一些代码示例,展示了WritableMemory.getByte()的具体用法。这些代码示例
本文整理了Java中com.yahoo.memory.WritableMemory.allocateDirect()方法的一些代码示例,展示了WritableMemory.allocateDirect
本文整理了Java中com.yahoo.memory.WritableMemory.clearBits()方法的一些代码示例,展示了WritableMemory.clearBits()的具体用法。这些
本文整理了Java中com.yahoo.memory.WritableMemory.getInt()方法的一些代码示例,展示了WritableMemory.getInt()的具体用法。这些代码示例主要
本文整理了Java中com.yahoo.memory.WritableMemory.writableRegion()方法的一些代码示例,展示了WritableMemory.writableRegion
本文整理了Java中com.yahoo.memory.WritableMemory.wrap()方法的一些代码示例,展示了WritableMemory.wrap()的具体用法。这些代码示例主要来源于G
本文整理了Java中com.yahoo.memory.WritableMemory.map()方法的一些代码示例,展示了WritableMemory.map()的具体用法。这些代码示例主要来源于Git
本文整理了Java中com.yahoo.memory.WritableMemory.putLong()方法的一些代码示例,展示了WritableMemory.putLong()的具体用法。这些代码示例
本文整理了Java中com.yahoo.memory.WritableMemory.allocate()方法的一些代码示例,展示了WritableMemory.allocate()的具体用法。这些代码
我是一名优秀的程序员,十分优秀!