Exemple #1
0
 public Data toData(Object object) {
   if (object == null) return null;
   if (object instanceof Data) {
     return (Data) object;
   } else {
     return nodeEngine.getSerializationService().toData(object);
   }
 }
Exemple #2
0
 public Data toData(Object object, PartitioningStrategy partitionStrategy) {
   if (object == null) return null;
   if (object instanceof Data) {
     return (Data) object;
   } else {
     return nodeEngine.getSerializationService().toData(object, partitionStrategy);
   }
 }
Exemple #3
0
 public QueryResult queryOnPartition(String mapName, Predicate predicate, int partitionId) {
   final QueryResult result = new QueryResult();
   List<QueryEntry> list = new LinkedList<QueryEntry>();
   PartitionContainer container = getPartitionContainer(partitionId);
   RecordStore recordStore = container.getRecordStore(mapName);
   Map<Data, Record> records = recordStore.getReadonlyRecordMap();
   SerializationService serializationService = nodeEngine.getSerializationService();
   final PagingPredicate pagingPredicate =
       predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
   Comparator<Map.Entry> wrapperComparator = SortingUtil.newComparator(pagingPredicate);
   for (Record record : records.values()) {
     Data key = record.getKey();
     Object value = record.getValue();
     if (value == null) {
       continue;
     }
     QueryEntry queryEntry = new QueryEntry(serializationService, key, key, value);
     if (predicate.apply(queryEntry)) {
       if (pagingPredicate != null) {
         Map.Entry anchor = pagingPredicate.getAnchor();
         if (anchor != null
             && SortingUtil.compare(
                     pagingPredicate.getComparator(),
                     pagingPredicate.getIterationType(),
                     anchor,
                     queryEntry)
                 >= 0) {
           continue;
         }
       }
       list.add(queryEntry);
     }
   }
   if (pagingPredicate != null) {
     Collections.sort(list, wrapperComparator);
     if (list.size() > pagingPredicate.getPageSize()) {
       list = list.subList(0, pagingPredicate.getPageSize());
     }
   }
   for (QueryEntry entry : list) {
     result.add(
         new QueryResultEntryImpl(entry.getKeyData(), entry.getKeyData(), entry.getValueData()));
   }
   return result;
 }
Exemple #4
0
 public SerializationService getSerializationService() {
   return nodeEngine.getSerializationService();
 }