use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class ListProxyImpl method subList.
@Override
public List<E> subList(int fromIndex, int toIndex) {
ListSubOperation operation = new ListSubOperation(name, fromIndex, toIndex);
SerializableList result = invoke(operation);
List<Data> collection = result.getCollection();
SerializationService serializationService = getNodeEngine().getSerializationService();
return new UnmodifiableLazyList<E>(collection, serializationService);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class TransactionalMapProxy method keySet.
@Override
@SuppressWarnings("unchecked")
public Set keySet(Predicate predicate) {
checkTransactionState();
checkNotNull(predicate, "Predicate should not be null!");
checkNotInstanceOf(PagingPredicate.class, predicate, "Paging is not supported for Transactional queries!");
MapQueryEngine queryEngine = mapServiceContext.getMapQueryEngine(name);
SerializationService serializationService = getNodeEngine().getSerializationService();
Query query = Query.of().mapName(name).predicate(predicate).iterationType(IterationType.KEY).build();
QueryResult queryResult = queryEngine.execute(query, Target.ALL_NODES);
Set result = QueryResultUtils.transformToSet(serializationService, queryResult, predicate, IterationType.KEY, true);
// TODO: Can't we just use the original set?
Set<Object> keySet = new HashSet<Object>(result);
Extractors extractors = mapServiceContext.getExtractors(name);
for (Map.Entry<Data, TxnValueWrapper> entry : txMap.entrySet()) {
Data keyData = entry.getKey();
if (!Type.REMOVED.equals(entry.getValue().type)) {
Object value = (entry.getValue().value instanceof Data) ? toObjectIfNeeded(entry.getValue().value) : entry.getValue().value;
QueryableEntry queryEntry = new CachedQueryEntry((InternalSerializationService) serializationService, keyData, value, extractors);
// apply predicate on txMap
if (predicate.apply(queryEntry)) {
Object keyObject = serializationService.toObject(keyData);
keySet.add(keyObject);
}
} else {
// meanwhile remove keys which are not in txMap
Object keyObject = serializationService.toObject(keyData);
keySet.remove(keyObject);
}
}
return keySet;
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class ReadResultSetImpl method get.
@Override
public E get(int index) {
checkNotNegative(index, "index should not be negative");
checkTrue(index < size, "index should not be equal or larger than size");
SerializationService serializationService = getSerializationService();
Data item = items[index];
return serializationService.toObject(item);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class WanConsumerConfigTest method testSerialization.
@Test
public void testSerialization() {
Map<String, Comparable> properties = new HashMap<String, Comparable>();
properties.put("key", "value");
config.setProperties(properties);
config.setClassName("className");
config.setImplementation("implementation");
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Data serialized = serializationService.toData(config);
WanConsumerConfig deserialized = serializationService.toObject(serialized);
assertWanConsumerConfig(config, deserialized);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class WanReplicationConfigTest method testSerialization_withEmpyConfigs.
@Test
public void testSerialization_withEmpyConfigs() {
config.setName("name");
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Data serialized = serializationService.toData(config);
WanReplicationConfig deserialized = serializationService.toObject(serialized);
assertWanReplicationConfig(config, deserialized);
}
Aggregations