Search in sources :

Example 1 with InternalResultSender

use of org.apache.geode.internal.cache.execute.InternalResultSender in project geode by apache.

the class RetrieveRegionFunction method retrieveFullRegion.

/** ------------------------------------------ */
/**         Retrieve full region data          */
/** ------------------------------------------ */
private void retrieveFullRegion(InternalRegionFunctionContext context, boolean partitioned, String desc) {
    Iterator<Object[]> entries;
    if (partitioned) {
        PREntriesIterator<Region.Entry> iter = (PREntriesIterator<Region.Entry>) ((LocalDataSet) PartitionRegionHelper.getLocalDataForContext(context)).entrySet().iterator();
        // entries = getPREntryIterator(iter);
        entries = getSimpleEntryIterator(iter);
    } else {
        LocalRegion owner = (LocalRegion) context.getDataSet();
        Iterator<Region.Entry> iter = (Iterator<Region.Entry>) owner.entrySet().iterator();
        // entries = getRREntryIterator(iter, owner);
        entries = getSimpleEntryIterator(iter);
    }
    InternalResultSender irs = (InternalResultSender) context.getResultSender();
    StructStreamingResultSender sender = new StructStreamingResultSender(irs, null, entries, desc);
    sender.send();
}
Also used : PREntriesIterator(org.apache.geode.internal.cache.partitioned.PREntriesIterator) Iterator(java.util.Iterator) PREntriesIterator(org.apache.geode.internal.cache.partitioned.PREntriesIterator) Region(org.apache.geode.cache.Region) InternalResultSender(org.apache.geode.internal.cache.execute.InternalResultSender)

Example 2 with InternalResultSender

use of org.apache.geode.internal.cache.execute.InternalResultSender in project geode by apache.

the class RetrieveRegionFunction method retrieveRegionWithWhereClause.

/** ------------------------------------------ */
/**    Retrieve region data with where clause  */
/** ------------------------------------------ */
private void retrieveRegionWithWhereClause(InternalRegionFunctionContext context, LocalRegion localRegion, boolean partitioned, String where, String desc) {
    String regionPath = localRegion.getFullPath();
    String qstr = "select key, value from " + regionPath + ".entries where " + where;
    logger.info(desc + ": " + qstr);
    try {
        Cache cache = CacheFactory.getAnyInstance();
        QueryService queryService = cache.getQueryService();
        Query query = queryService.newQuery(qstr);
        SelectResults<Struct> results = (SelectResults<Struct>) (partitioned ? query.execute(context) : query.execute());
        Iterator<Object[]> entries = getStructIteratorWrapper(results.asList().iterator());
        InternalResultSender irs = (InternalResultSender) context.getResultSender();
        StructStreamingResultSender sender = new StructStreamingResultSender(irs, null, entries, desc);
        sender.send();
    } catch (Exception e) {
        throw new FunctionException(e);
    }
}
Also used : SelectResults(org.apache.geode.cache.query.SelectResults) Query(org.apache.geode.cache.query.Query) QueryService(org.apache.geode.cache.query.QueryService) FunctionException(org.apache.geode.cache.execute.FunctionException) InternalResultSender(org.apache.geode.internal.cache.execute.InternalResultSender) FunctionException(org.apache.geode.cache.execute.FunctionException) Cache(org.apache.geode.cache.Cache) Struct(org.apache.geode.cache.query.Struct)

Aggregations

InternalResultSender (org.apache.geode.internal.cache.execute.InternalResultSender)2 Iterator (java.util.Iterator)1 Cache (org.apache.geode.cache.Cache)1 Region (org.apache.geode.cache.Region)1 FunctionException (org.apache.geode.cache.execute.FunctionException)1 Query (org.apache.geode.cache.query.Query)1 QueryService (org.apache.geode.cache.query.QueryService)1 SelectResults (org.apache.geode.cache.query.SelectResults)1 Struct (org.apache.geode.cache.query.Struct)1 PREntriesIterator (org.apache.geode.internal.cache.partitioned.PREntriesIterator)1