// meanwhile remove keys which are not in txMap
@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();
        QueryResult result = queryEngine.invokeQueryAllPartitions(name, predicate, IterationType.KEY);
        Set<Object> queryResult = new QueryResultCollection(serializationService, IterationType.KEY, false, true, result);
        // TODO: Can't we just use the original set?
        Set<Object> keySet = new HashSet<Object>(queryResult);
        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;
    }
}
} else {
// meanwhile remove keys which are not in txMap
Object keyObject = serializationService.toObject(keyData);
keySet.remove(keyObject);
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;
}
MapQueryEngine queryEngine = mapServiceContext.getMapQueryEngine(name);
SerializationService serializationService = getNodeEngine().getSerializationService();
QueryResult result = queryEngine.invokeQueryAllPartitions(name, predicate, IterationType.KEY);
Set<Object> queryResult = new QueryResultCollection(serializationService, IterationType.KEY, false, true, result);
// TODO: Can't we just use the original set?
Set<Object> keySet = new HashSet<Object>(queryResult);
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;
}