@Test(dataProvider = "longValuesData") public void testRead(int len, long[] values) { MockKryoInput input = new MockKryoInput(len, values); BitSetSerializer serializer = new BitSetSerializer(); BitSet bitSet = serializer.read(mock(Kryo.class), input, BitSet.class); verify(bitSet, len, values); }
@Override public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) { final int bitLen = input.readInt(true); final BitSet bitSet = new BitSet(bitLen); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = input.readLongs(wordNum); for (int i = 0; i < bitLen; ++i) { if ((words[i / Long.SIZE] & (1L << (i % Long.SIZE))) != 0L) { bitSet.set(i, true); } else { bitSet.set(i, false); } } return bitSet; }
BitSetSerializer extends Serializer<BitSet> { @Override public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) { final int bitLen = input.readInt(true); final BitSet bitSet = new BitSet(bitLen); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = input.readLongs(wordNum); for (int i = 0; i < bitLen; ++i) { if ((words[i / Long.SIZE] & (1L << (i % Long.SIZE))) != 0L) { bitSet.set(i, true); } else { bitSet.set(i, false); } } return bitSet; } }
BitSetSerializer extends Serializer<BitSet> { @Override public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) { final int bitLen = input.readInt(true); final BitSet bitSet = new BitSet(bitLen); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = input.readLongs(wordNum); for (int i = 0; i < bitLen; ++i) { if ((words[i / Long.SIZE] & (1L << (i % Long.SIZE))) != 0L) { bitSet.set(i, true); } else { bitSet.set(i, false); } } return bitSet; }  }
BitSetSerializer extends Serializer<BitSet> { @Override public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) { final int bitLen = input.readInt(true); final BitSet bitSet = new BitSet(bitLen); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = input.readLongs(wordNum); for (int i = 0; i < bitLen; ++i) { if ((words[i / Long.SIZE] & (1L << (i % Long.SIZE))) != 0L) { bitSet.set(i, true); } else { bitSet.set(i, false); } } return bitSet; }  @Override BitSet copy(final Kryo kryo, final BitSet original); @Override void write(final Kryo kryo, final Output output, final BitSet bitSet); @Override BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass); }
BitSetSerializer extends Serializer<BitSet> { @Override public BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass) { final int bitLen = input.readInt(true); final BitSet bitSet = new BitSet(bitLen); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = input.readLongs(wordNum); for (int i = 0; i < bitLen; ++i) { if ((words[i / Long.SIZE] & (1L << (i % Long.SIZE))) != 0L) { bitSet.set(i, true); } else { bitSet.set(i, false); } } return bitSet; }  @Override BitSet copy(final Kryo kryo, final BitSet original); @Override void write(final Kryo kryo, final Output output, final BitSet bitSet); @Override BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass);  }