Hi,

I am attempting to convert an existing application to use Apache Ignite. 

The current logic does an “upsert”  from a stream of data. And it will be very 
difficult to modify the existing code.

Something like this: 

public void upsertEntry(TKey key, NewInstanceFunctor<TValue> newInstFunc, 
UpsertFunctor<TValue> upsertFunc) {
        TValue document = getAndNewIfReqd(key, newInstFunc);
        document = upsertFunc.modifyForUpsert(document);
        getIgniteCache().put(key, document);
}

public TValue getAndNewIfReqd(TKey key, NewInstanceFunctor<TValue> newInstFunc) 
{
        TValue document = getEntry(key);
        if (document == null) {
            document = newInstFunc.newInstance();
            getIgniteCache().put(key, document);
        }
        return document;
}

So, in pseudo-code

1) get the document from the cache
2) if null, create a document and put it to the cache
3) modify the document
4) put the updated document to the cache
This is clearly inefficient.

I am pretty certain that I can accomplish this using a DataStreamer and a 
StreamTransformer??
I wonder if someone could point me at an example of how to do this??

Thanks,
— Chris 




 

 

Reply via email to