polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Merlin <p...@nosphere.org>
Subject Re: Stream creation...
Date Sun, 06 Sep 2015 15:25:16 GMT
Hi guys,

Niclas Hedhman a écrit :
> I am also curious about this change;
>
> -        ).distinct().forEach( unitOfWork::remove );
> +        ).distinct().collect( Collectors.toList() ).stream().forEach(
> unitOfWork::remove );
>
> From my understanding it is the same thing (except slower). Do you recall
> what this is about?

For other readers, this code comes from the
EntityInstance::removeAggregatedEntities method, in runtime.
 

Kent Sølvsten a écrit :
> It fixed a problem  in an Aggregate test (don't recall the exact name of
> the test).
>
> My guess is that the previous version was streaming and removing
> concurrently
>  - the new implementation finds all items that should be removed before
> starting the actual removal.

I don't think there's any concurency involved here as there's no
parallel stream.

Collecting the stream has the effect of loading all the entities in the
uow before starting to remove them. That's what the pre-streams impl did.

Removing aggregated entities without loading them all upfront fails in
AggregatedTest because the Company's director (an Employee), is also
referenced in the 'employees' ManyAssociation. Removing the director
entity before querying/loading the employees association leads to an
exception because the employees association then references a removed
entity -> NoSuchEntityException.

Cheers

/Paul


Mime
View raw message