Search in sources :

Example 6 with Extractors

use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.

the class LikePredicateTest method createIndex.

@Nonnull
private Index createIndex(IndexType indexType) {
    InternalSerializationService mockSerializationService = mock(InternalSerializationService.class);
    Extractors mockExtractors = Extractors.newBuilder(mockSerializationService).build();
    IndexConfig config = IndexUtils.createTestIndexConfig(indexType, "this");
    return new IndexImpl(config, mockSerializationService, mockExtractors, IndexCopyBehavior.COPY_ON_READ, PerIndexStats.EMPTY, MemberPartitionStateImpl.DEFAULT_PARTITION_COUNT);
}
Also used : Extractors(com.hazelcast.query.impl.getters.Extractors) IndexConfig(com.hazelcast.config.IndexConfig) IndexImpl(com.hazelcast.query.impl.IndexImpl) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) Nonnull(javax.annotation.Nonnull)

Example 7 with Extractors

use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.

the class GenericQueryTargetTest method createTarget.

private static GenericQueryTarget createTarget(boolean key) {
    InternalSerializationService ss = new DefaultSerializationServiceBuilder().build();
    Extractors extractors = Extractors.newBuilder(ss).build();
    GenericQueryTargetDescriptor descriptor = new GenericQueryTargetDescriptor();
    GenericQueryTarget target = (GenericQueryTarget) descriptor.create(ss, extractors, key);
    assertEquals(key, target.isKey());
    return target;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) Extractors(com.hazelcast.query.impl.getters.Extractors) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 8 with Extractors

use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.

the class PartitionScanRunner method run.

@SuppressWarnings("unchecked")
public Collection<QueryableEntry> run(String mapName, Predicate predicate, int partitionId) {
    PagingPredicate pagingPredicate = predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
    List<QueryableEntry> resultList = new LinkedList<QueryableEntry>();
    PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Iterator<Record> iterator = partitionContainer.getRecordStore(mapName).loadAwareIterator(getNow(), false);
    Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(pagingPredicate);
    boolean useCachedValues = isUseCachedDeserializedValuesEnabled(mapContainer);
    Extractors extractors = mapServiceContext.getExtractors(mapName);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data key = (Data) toData(record.getKey());
        Object value = toData(useCachedValues ? Records.getValueOrCachedValue(record, serializationService) : record.getValue());
        if (value == null) {
            continue;
        }
        //we want to always use CachedQueryEntry as these are short-living objects anyway
        QueryableEntry queryEntry = new CachedQueryEntry(serializationService, key, value, extractors);
        if (predicate.apply(queryEntry) && compareAnchor(pagingPredicate, queryEntry, nearestAnchorEntry)) {
            resultList.add(queryEntry);
        }
    }
    return getSortedSubList(resultList, pagingPredicate, nearestAnchorEntry);
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Data(com.hazelcast.nio.serialization.Data) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PagingPredicate(com.hazelcast.query.PagingPredicate) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) PagingPredicateAccessor.getNearestAnchorEntry(com.hazelcast.query.PagingPredicateAccessor.getNearestAnchorEntry) Extractors(com.hazelcast.query.impl.getters.Extractors) Record(com.hazelcast.map.impl.record.Record) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) Map(java.util.Map) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 9 with Extractors

use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.

the class HazelcastJsonQueryTargetDescriptorTest method test_create.

@Test
@Parameters({ "true", "false" })
public void test_create(boolean key) {
    Extractors extractors = Extractors.newBuilder(SERIALIZATION_SERVICE).build();
    HazelcastJsonQueryTargetDescriptor descriptor = HazelcastJsonQueryTargetDescriptor.INSTANCE;
    // when
    QueryTarget target = descriptor.create(SERIALIZATION_SERVICE, extractors, key);
    // then
    assertThat(target).isInstanceOf(HazelcastJsonQueryTarget.class);
}
Also used : QueryTarget(com.hazelcast.sql.impl.extract.QueryTarget) Extractors(com.hazelcast.query.impl.getters.Extractors) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 10 with Extractors

use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.

the class AvroQueryTargetDescriptorTest method test_create.

@Test
@Parameters({ "true", "false" })
public void test_create(boolean key) {
    Extractors extractors = Extractors.newBuilder(SERIALIZATION_SERVICE).build();
    AvroQueryTargetDescriptor descriptor = AvroQueryTargetDescriptor.INSTANCE;
    // when
    QueryTarget target = descriptor.create(SERIALIZATION_SERVICE, extractors, key);
    // then
    assertThat(target).isInstanceOf(AvroQueryTarget.class);
}
Also used : QueryTarget(com.hazelcast.sql.impl.extract.QueryTarget) Extractors(com.hazelcast.query.impl.getters.Extractors) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

Extractors (com.hazelcast.query.impl.getters.Extractors)13 Data (com.hazelcast.internal.serialization.Data)4 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)4 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)4 QueryTarget (com.hazelcast.sql.impl.extract.QueryTarget)4 Map (java.util.Map)4 Parameters (junitparams.Parameters)4 Test (org.junit.Test)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)3 IndexConfig (com.hazelcast.config.IndexConfig)2 ToHeapDataConverter.toHeapData (com.hazelcast.internal.util.ToHeapDataConverter.toHeapData)2 LazyMapEntry (com.hazelcast.map.impl.LazyMapEntry)2 MapContainer (com.hazelcast.map.impl.MapContainer)2 Query (com.hazelcast.map.impl.query.Query)2 QueryEngine (com.hazelcast.map.impl.query.QueryEngine)2 QueryResult (com.hazelcast.map.impl.query.QueryResult)2 Record (com.hazelcast.map.impl.record.Record)2 TransactionalMap (com.hazelcast.transaction.TransactionalMap)2 HashMap (java.util.HashMap)2