[jira] [Commented] (OFBIZ-6298) Java collection use optimized

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-6298) Java collection use optimized

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-6298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14511179#comment-14511179 ]

Ron Wheeler commented on OFBIZ-6298:
------------------------------------

http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/ is one tutorial.
If you google "java stream tutorial" you will find lots of entries.

I am not sure how collections are used in OFBiz but there was some talk of using a factory to encapsulate creation of collections.
There may be a case for providing high level functions that encapsulate some operations on collections using streams as part of the classes delivered by the factory.
If you combine this with the new Java 8 ability to add code to interfaces, there may be some interesting possibilities to reduce the amount of code required in OFBIz and to hide some of the complexity of dealing with the myriad of OFBiz entities. The classes produced by the factory would share the same interface but have some methods overridden in the classes to provide the class specific behaviour.

I have started to use Streams in other applications that I have written and they do reduce the amount of code required.
They do lock you into Java 8 but so does Oracle's short term view of Java 7- OES this year.
I have only started to look at rewriting some of the interfaces in my applications to add default methods to the interfaces. This has a lot of potential for my application since it has a lot of classes that share processing patterns to implement plug-ins that are configured at runtime using Spring. It seems to have the potential to make creation of custom plug-ins a lot easier since a new plug-in might only have to override one or two methods to implement new functionality.
I would be surprised if this did not apply to OFBiz as well since many business processes have similar flows but require some special processing for different entities within the same family.
The ability to pass methods as arguments also should help in these cases as well.  

If there is an effort to look at collections, it seems that it would be a good time to look at Java 8 since the whole nature of collections is changed and Java 8 does optimization that is not possible in Java 7 without adding a lot of complexity (parallel processing with multi-core optimization).

> Java collection use optimized
> -----------------------------
>
>                 Key: OFBIZ-6298
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6298
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL COMPONENTS
>    Affects Versions: Trunk
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Minor
>              Labels: collection, performance
>
> With the javolution collection cleaning (OFBIZ-5169,OFBIZ-5781) , we need to realize a second pass to control what instantiation would be better.
> For List between LinkedList, ArrayList
> {quote}
> Using ArrayList, rather than LinkedList, as a default is a good approach because ArrayList will work better in most situations (in terms of algorithmic runtimes and memory footprints).
> However I think it is important to wisely choose ArrayList or LinkedList based on the context, because sometimes a linked list may be a better choice: I am not saying we should do it now and we can tackle this at a later moment, possibly focusing only on list that can be very big and analyzing their usage to see if array or linked list is better; it would be also nice, when we use ArrayList, to see if we can predict the capacity of the list and allocate it at creation: if we can do this we will have a more predictable memory usage and less unpredictable peaks under heavy load (when the array capacity is reached and the array is copied to a new one with double capacity).
> {quote}
> more documentation on :
>  * https://docs.oracle.com/javase/tutorial/collections/implementations/list.html
>  * http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist
> For Map between HashMap and LinkedHashMap :
> {quote}
> Javolution Map Iterators return items in insertion sequence (HashMap does not), so any code relying on the original insertion order must use a LinkedHashMap.
> {quote}
>  * http://stackoverflow.com/questions/2889777/difference-between-hashmap-linkedhashmap-and-treemap
> If you detect an optimization, please comments this issues



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Reply | Threaded
Open this post in threaded view
|

java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Adam Heath-2
Not putting this into the jira issue, as it's not related, but with java
1.8, construction of generic objects is nicer.

==
Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
==

Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...

It's should be OK now, but must be done officially

Jacques
PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk

Le 24/04/2015 17:02, Adam Heath a écrit :
> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>
> ==
> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
> ==
>
>
Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
Ha forgot: https://issues.apache.org/jira/issues/?jql=project%20%3D%20OFBIZ%20AND%20text%20~%20%22java%208%22%20ORDER%20BY%20updated%20DESC

So with https://issues.apache.org/jira/browse/OFBIZ-6300 patch committed we should be OK

Jacques

Le 29/04/2015 12:44, Jacques Le Roux a écrit :

> BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...
>
> It's should be OK now, but must be done officially
>
> Jacques
> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>
> Le 24/04/2015 17:02, Adam Heath a écrit :
>> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>>
>> ==
>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>> ==
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Pierre Smits
In reply to this post by Jacques Le Roux
That can be a switchover for the Next Branch. Given the many refactorings
going on.

Best regards,

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com

On Wed, Apr 29, 2015 at 12:44 PM, Jacques Le Roux <
[hidden email]> wrote:

> BTW we should focus on switching to Java 8 before anything else. In 2 days
> Java 7 will no longer be supported, think security...
>
> It's should be OK now, but must be done officially
>
> Jacques
> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>
>
> Le 24/04/2015 17:02, Adam Heath a écrit :
>
>> Not putting this into the jira issue, as it's not related, but with java
>> 1.8, construction of generic objects is nicer.
>>
>> ==
>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>> ==
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
Seems we have another case https://issues.apache.org/jira/browse/OFBIZ-6313

I will group them under an umbrella issue

Jacques

Le 29/04/2015 12:46, Jacques Le Roux a écrit :

> Ha forgot: https://issues.apache.org/jira/issues/?jql=project%20%3D%20OFBIZ%20AND%20text%20~%20%22java%208%22%20ORDER%20BY%20updated%20DESC
>
> So with https://issues.apache.org/jira/browse/OFBIZ-6300 patch committed we should be OK
>
> Jacques
>
> Le 29/04/2015 12:44, Jacques Le Roux a écrit :
>> BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...
>>
>> It's should be OK now, but must be done officially
>>
>> Jacques
>> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>>
>> Le 24/04/2015 17:02, Adam Heath a écrit :
>>> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>>>
>>> ==
>>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>>> ==
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
Ha no it's already fixed with OFBIZ-6309 <https://issues.apache.org/jira/browse/OFBIZ-6309>, I have some backlog to read...

Jacques

Le 29/04/2015 19:20, Jacques Le Roux a écrit :

> Seems we have another case https://issues.apache.org/jira/browse/OFBIZ-6313
>
> I will group them under an umbrella issue
>
> Jacques
>
> Le 29/04/2015 12:46, Jacques Le Roux a écrit :
>> Ha forgot: https://issues.apache.org/jira/issues/?jql=project%20%3D%20OFBIZ%20AND%20text%20~%20%22java%208%22%20ORDER%20BY%20updated%20DESC
>>
>> So with https://issues.apache.org/jira/browse/OFBIZ-6300 patch committed we should be OK
>>
>> Jacques
>>
>> Le 29/04/2015 12:44, Jacques Le Roux a écrit :
>>> BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...
>>>
>>> It's should be OK now, but must be done officially
>>>
>>> Jacques
>>> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>>>
>>> Le 24/04/2015 17:02, Adam Heath a écrit :
>>>> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>>>>
>>>> ==
>>>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>>>> ==
>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
Ha no it's already fixed with OFBIZ-6309 <https://issues.apache.org/jira/browse/OFBIZ-6309>, I have some backlog to read...

Jacques

Le 29/04/2015 19:20, Jacques Le Roux a écrit :

> Seems we have another case https://issues.apache.org/jira/browse/OFBIZ-6313
>
> I will group them under an umbrella issue
>
> Jacques
>
> Le 29/04/2015 12:46, Jacques Le Roux a écrit :
>> Ha forgot: https://issues.apache.org/jira/issues/?jql=project%20%3D%20OFBIZ%20AND%20text%20~%20%22java%208%22%20ORDER%20BY%20updated%20DESC
>>
>> So with https://issues.apache.org/jira/browse/OFBIZ-6300 patch committed we should be OK
>>
>> Jacques
>>
>> Le 29/04/2015 12:44, Jacques Le Roux a écrit :
>>> BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...
>>>
>>> It's should be OK now, but must be done officially
>>>
>>> Jacques
>>> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>>>
>>> Le 24/04/2015 17:02, Adam Heath a écrit :
>>>> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>>>>
>>>> ==
>>>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>>>> ==
>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: java 1.8 features: Re: [jira] [Commented] (OFBIZ-6298) Java collection use optimized

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
Unless you use IBM ... https://www.voxxed.com/blog/2015/04/reminder-april-marked-the-end-of-public-support-for-java-7-support/

Jacques

Le 29/04/2015 19:23, Jacques Le Roux a écrit :

> Ha no it's already fixed with OFBIZ-6309 <https://issues.apache.org/jira/browse/OFBIZ-6309>, I have some backlog to read...
>
> Jacques
>
> Le 29/04/2015 19:20, Jacques Le Roux a écrit :
>> Seems we have another case https://issues.apache.org/jira/browse/OFBIZ-6313
>>
>> I will group them under an umbrella issue
>>
>> Jacques
>>
>> Le 29/04/2015 12:46, Jacques Le Roux a écrit :
>>> Ha forgot: https://issues.apache.org/jira/issues/?jql=project%20%3D%20OFBIZ%20AND%20text%20~%20%22java%208%22%20ORDER%20BY%20updated%20DESC
>>>
>>> So with https://issues.apache.org/jira/browse/OFBIZ-6300 patch committed we should be OK
>>>
>>> Jacques
>>>
>>> Le 29/04/2015 12:44, Jacques Le Roux a écrit :
>>>> BTW we should focus on switching to Java 8 before anything else. In 2 days Java 7 will no longer be supported, think security...
>>>>
>>>> It's should be OK now, but must be done officially
>>>>
>>>> Jacques
>>>> PS: my last call was http://markmail.org/message/fs36a4tkwfm42vhk
>>>>
>>>> Le 24/04/2015 17:02, Adam Heath a écrit :
>>>>> Not putting this into the jira issue, as it's not related, but with java 1.8, construction of generic objects is nicer.
>>>>>
>>>>> ==
>>>>> Map<String, List<Map<String, Object>>> myVar = new HashMap<>();
>>>>> ==
>>>>>
>>>>>
>>>>
>>>
>>
>
>