details:   https://code.openbravo.com/erp/devel/pi/rev/1c94691c4704
changeset: 33096:1c94691c4704
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Fri Dec 01 13:39:02 2017 +0100
summary:   fixed bug 37424: export to CSV too slow with high volumes

  Wehn exporting to CSV from grid, all the properties of the entity were 
calculated
  even if they weren't included in the final file. This computation added 
overhead,
  specially for computed columns.

  Now only those properties that are going to be included in the CSV file are 
calulated.

details:   https://code.openbravo.com/erp/devel/pi/rev/abaa47f3a421
changeset: 33097:abaa47f3a421
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Fri Dec 01 13:45:14 2017 +0100
summary:   related to bug 37424: export to CSV too slow with high volumes

  Small optimization: selectedProperties field is used to only check whether a
  propertie is selected. Use a HashSet that has an O(1) contains instead of
  ArrayList, which is O(n).

diffstat:

 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
 |  4 ++++
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java
           |  4 +++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diffs (37 lines):

diff -r 03feee46a26b -r abaa47f3a421 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
--- 
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
      Fri Dec 01 11:36:50 2017 +0100
+++ 
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
      Fri Dec 01 13:45:14 2017 +0100
@@ -262,6 +262,10 @@
                 request, parameters));
             // when exporting a OB grid, the isActive filter should not be set
             parameters.put(JsonConstants.NO_ACTIVE_FILTER, "true");
+
+            // set selected properties those that will finally be exported
+            parameters.put(JsonConstants.SELECTEDPROPERTIES_PARAMETER,
+                Utility.commaSeparated(writer.fieldProperties, false));
             ((DefaultDataSourceService) 
getDataSource(request)).fetch(parameters, writer);
           } else {
             String result = getDataSource(request).fetch(parameters);
diff -r 03feee46a26b -r abaa47f3a421 
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java
        Fri Dec 01 11:36:50 2017 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java
        Fri Dec 01 13:45:14 2017 +0100
@@ -24,8 +24,10 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
@@ -77,7 +79,7 @@
   private List<String> additionalProperties = new ArrayList<String>();
 
   // limit the json serialization to these properties
-  private List<String> selectedProperties = new ArrayList<String>();
+  private Set<String> selectedProperties = new HashSet<>();
 
   // display property used for table reference fields
   private String displayProperty = null;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to