@Override public byte[] toBytes() { return bitmap.toByteArray(); }
public void setIncludedBuckets(BitSet includedBuckets) { // see comment next to the field this.includedBuckets = includedBuckets == null ? null : includedBuckets.toByteArray(); }
/** * Convert a value from its logical format (BitSet) to it's encoded format. * * @param schema the schema * @param value the logical value * @return the encoded value */ public static byte[] fromBitSet(Schema schema, BitSet value) { return value.toByteArray(); }
public void serialize(ByteBuffer buffer) { buffer.put(this.bitmap.toByteArray()); } }
public void setIncludedBuckets(BitSet includedBuckets) { // see comment next to the field this.includedBuckets = includedBuckets.toByteArray(); }
<a href="http://download.oracle.com/javase/7/docs/api/java/util/%42it%53et.html#to%42yte%41rray%28%29"> BitSet.toByteArray() </a>
public byte[] toBytes() { byte[] ret = new byte[BLOOM_BYTES]; byte[] bytes = mask.toByteArray(); System.arraycopy(bytes, 0, ret, 0, bytes.length); return ret; }
@Override public void serialize(ImmutableBitSet value, ByteBuffer out) { BytesUtil.writeByteArray(value.set.toByteArray(), out); }
@Override public byte[] toBytes(BloomFilter bloomFilter) { ByteBuffer byteBuffer = ByteBuffer.allocate(getObjectSize()); byteBuffer.put(bloomFilter.getBitSet().toByteArray()); return byteBuffer.array(); }
/** * Features supported by the current node. * * @return Byte array representing all supported features by current node. */ public static byte[] allFeatures() { final BitSet set = new BitSet(); for (IgniteFeatures value : IgniteFeatures.values()) { final int featureId = value.getFeatureId(); assert !set.get(featureId) : "Duplicate feature ID found for [" + value + "] having same ID [" + featureId + "]"; set.set(featureId); } return set.toByteArray(); } }
@Override public Object asJSON(Object value, MaxwellOutputConfig outputConfig) { byte[] bytes; if( value instanceof Boolean ){ bytes = new byte[]{(byte) (( Boolean ) value ? 1 : 0)}; } else if ( value instanceof BitSet ) { BitSet bs = (BitSet) value; bytes = bs.toByteArray(); } else { bytes = (byte[]) value; } if ( bytes.length == 8 && ((bytes[7] & 0xFF) > 127) ) { return bytesToBigInteger(bytes); } else { return bytesToLong(bytes); } }
ByteBuffer byteBuffer = ByteBuffer.wrap(abortedBits.toByteArray()); GetOpenTxnsResponse otr = new GetOpenTxnsResponse(hwm, openList, byteBuffer); if(minOpenTxn < Long.MAX_VALUE) {
byte[] bytes = ((BitSet) data).toByteArray(); r.deliver(padLittleEndian(numBytes, bytes));
ByteBuffer byteBuffer = ByteBuffer.wrap(abortedBits.toByteArray()); TableValidWriteIds owi = new TableValidWriteIds(fullTableName, writeIdHwm, invalidWriteIdList, byteBuffer); if (minOpenWriteId < Long.MAX_VALUE) {
public byte[] toByteArray() {return myBits.toByteArray();} public long[] toLongArray() {return myBits.toLongArray();}
@Override public void writeMeta(DataBuffer buff) { buff.putVarLong(tid); buff.putVarInt(logId); if (rowLock) { buff.put((byte) 0); } else { buff.put((byte) 1); byte[] bytes = lockedColumns.toByteArray(); int len = bytes.length; buff.putVarInt(len); for (int i = 0; i < len; i++) { buff.put(bytes[i]); } } if (oldValue == null) { buff.put((byte) 0); } else { buff.put((byte) 1); oldValueType.write(buff, oldValue); } ValueString.type.write(buff, hostAndPort); ValueString.type.write(buff, globalReplicationName); buff.putVarLong(version); }
public Map<String, String> bin(String hash) throws DecoderException { Random r = new Random(0); byte[] h = Hex.decodeHex(hash.substring(2 * checksumOption.getChecksumLength()).toCharArray()); BitSet vector = BitSet.valueOf(h); int n = vector.length(); Map<String, String> ret = new HashMap<>(); boolean singleHash = hashes.size() == 1; for (int numHashes : hashes) { BitSet projection = new BitSet(); for (int i = 0; i < numHashes; ++i) { int index = r.nextInt(n); projection.set(i, vector.get(index)); } String outputHash = numHashes + Hex.encodeHexString(projection.toByteArray()); if (singleHash) { ret.put(TLSH_BIN_KEY, outputHash); } else { ret.put(TLSH_BIN_KEY + "_" + numHashes, outputHash); } } return ret; }
@Override public void writeToDataOutputStream(DataOutputStream dos) throws IOException { dos.writeInt(size); byte[] outputBits = bits.toByteArray(); if (outputBits.length != getByteSize()) { outputBits = Arrays.copyOf(outputBits, getByteSize()); } dos.write(outputBits); }
@Test public void fromBitSet() { final Random random = new Random(234); final BitSet bits = new BitSet(2343); for (int i = 0; i < bits.size(); ++i) { bits.set(i, random.nextBoolean()); } final BitChromosome c = BitChromosome.of(bits); Assert.assertEquals(c.toByteArray(), bits.toByteArray()); }
@Test public void fromByteArrayBitSet() { final Random random = new Random(123); final byte[] bytes = new byte[234]; random.nextBytes(bytes); final BitSet bits = BitSet.valueOf(bytes); final BitChromosome c = BitChromosome.of(bits); Assert.assertEquals(c.toByteArray(), bytes); Assert.assertEquals(bits.toByteArray(), bytes); }