1 year ago

#359271

test-img

HachigoUzumaki

Efficient ways to do a bulk partial update on a google cloud datastore entries using spring data

I have a kind in google datastore with tens thousands of entries. I am using spring data to connect to and work on the datastore. I am trying to update one entity on a few (hundreds) rows on datastore.

The method I am trying to use does multiple gets with pagination and update the required attribute and saves all entries using dataStoreRepo.saveAll(list) and repeat until there are rows available for the query criteria. Something like :

void partialUpdateSomething () { 
    List<Trains> trains = repo.findBySourceAndIsRunning("cityCode", false, Pageable.ofSize(50)); 
    while (!trains.isEmpty()) { 
        for(Train t:trains) { 
            train.isRunning(true); // updating isRunning to true 
        } 
        repo.saveAll(trains); // saving all the updated train objects 
        trains = repo.findBySourceAndIsRunning("cityCode", false, Pageable.ofSize(50)); 
    } 
}

Is there a better way to update just one or more entities ?

java

google-app-engine

spring-data

google-cloud-datastore

0 Answers

Your Answer

Accepted video resources