Nan-

You set "read-serialized" to *true* [1], then a Region.get(key) returns a
o.a.g.pdx.PdxInstance [2], from which you can call
PdxInstance.getField(fieldName); [3]

-John




[1]
http://gemfire-91-javadocs.docs.pivotal.io/org/apache/geode/cache/CacheFactory.html#setPdxReadSerialized-boolean-
[2]
http://gemfire-91-javadocs.docs.pivotal.io/org/apache/geode/pdx/PdxInstance.html
[3]
http://gemfire-91-javadocs.docs.pivotal.io/org/apache/geode/pdx/PdxInstance.html#getField-java.lang.String-


On Thu, Sep 7, 2017 at 10:42 AM, Xu, Nan <[email protected]> wrote:

> Hi,
>
>     Trying to access particular field on a server side function, and want
> to utilize “Provides single field access of serialized data, without full
> deserialization - supported also for OQL querying.”  But if I do
> PartitionRegionHelper.getLocalDataForContext(context).get("key1"), that
> give me the whole object, how do I use pdxserilizer to get a partial
> constructed object—basically access a single field?
>
>
>
> public class Simple {
>
> String id;
>
>     String name;
>
>     Timestamp time;
>
> }
>
> public class GetTimeStampFunction implements Function{
>
>     @Override
>
>     public void execute(FunctionContext fc) {
>
>         if(! (fc instanceof RegionFunctionContext)){
>
>             throw new FunctionException("This is a data aware function,
> and has to be called using FunctionService.onRegion.");
>
>         }
>
>         RegionFunctionContext context = (RegionFunctionContext)fc;
>
>         Object value = 
> PartitionRegionHelper.getLocalDataForContext(context).get("key1");
> //need partial object with only id and time fields populated.
>
>         context.getResultSender().lastResult(value);
>
>     }
>
> ------------------------------
> This message, and any attachments, is for the intended recipient(s) only,
> may contain information that is privileged, confidential and/or proprietary
> and subject to important terms and conditions available at
> http://www.bankofamerica.com/emaildisclaimer. If you are not the intended
> recipient, please delete this message.
>



-- 
-John
john.blum10101 (skype)

Reply via email to