use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class BufferPoolTest method takeInputBuffer_whenPooledInstance.
// ======================= in ==========================================
@Test
public void takeInputBuffer_whenPooledInstance() {
Data data = new HeapData(new byte[] {});
BufferObjectDataInput found1 = bufferPool.takeInputBuffer(data);
bufferPool.returnInputBuffer(found1);
BufferObjectDataInput found2 = bufferPool.takeInputBuffer(data);
assertSame(found1, found2);
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class NearCachePreloader method loadKeySet.
private int loadKeySet(BufferingInputStream bis, DataStructureAdapter<Data, ?> adapter) throws IOException {
int loadedKeys = 0;
Builder<Data> builder = InflatableSet.newBuilder(LOAD_BATCH_SIZE);
while (readFullyOrNothing(bis, tmpBytes)) {
int dataSize = readIntB(tmpBytes, 0);
byte[] payload = new byte[dataSize];
if (!readFullyOrNothing(bis, payload)) {
break;
}
builder.add(new HeapData(payload));
if (builder.size() == LOAD_BATCH_SIZE) {
adapter.getAll(builder.build());
builder = InflatableSet.newBuilder(LOAD_BATCH_SIZE);
}
loadedKeys++;
}
if (builder.size() > 0) {
adapter.getAll(builder.build());
}
return loadedKeys;
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class StringSerializationTest method testLargeStringEncodeDecode.
@Test
public void testLargeStringEncodeDecode() {
StringBuilder sb = new StringBuilder();
int i = 0, j = 0;
while (j < TEST_STR_SIZE) {
int ch = i++ % Character.MAX_VALUE;
if (Character.isLetter(ch)) {
sb.append(ch);
j++;
}
}
String actualStr = sb.toString();
byte[] strBytes = actualStr.getBytes(Charset.forName("utf8"));
byte[] actualDataBytes = serializationService.toBytes(actualStr);
byte[] expectedDataByte = toDataByte(strBytes, actualStr.length());
String decodedStr = serializationService.toObject(new HeapData(expectedDataByte));
assertArrayEquals("Deserialized byte array do not match utf-8 encoding", expectedDataByte, actualDataBytes);
assertEquals(decodedStr, actualStr);
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class SerializationTest method testNullData.
@Test
public void testNullData() {
Data data = new HeapData();
SerializationService ss = new DefaultSerializationServiceBuilder().build();
assertNull(ss.toObject(data));
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class DataRecordFactoryTest method setUp.
@Before
public void setUp() {
mockSerializationService = mock(SerializationService.class);
mockPartitioningStrategy = mock(PartitioningStrategy.class);
object = new Object();
data = new HeapData();
when(mockSerializationService.toData(object, mockPartitioningStrategy)).thenReturn(data);
}
Aggregations