From dc8c413b95aa42ae5db5f06715a0db3e8491b0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Manelphe?= Date: Mon, 22 Jan 2024 16:03:50 +0100 Subject: [PATCH] feat: limit number of chars when retrieving file metadata --- .../p2chargement/operation/ChargementBrut.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/operation/ChargementBrut.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/operation/ChargementBrut.java index 4abb5b72f..c6bcc5e50 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/operation/ChargementBrut.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/operation/ChargementBrut.java @@ -31,8 +31,9 @@ public class ChargementBrut { /** Combien de boucle au maximum */ private static final int LIMIT_BOUCLE = 1; /** Combien de ligne on charge pour chacune des boucles */ - private static final int LIMIT_CHARGEMENT_BRUTAL = 50; - + private static final int LIMIT_CHARGEMENT_BRUTAL_NB_LIGNE = 50; + private static final int LIMIT_CHARGEMENT_BRUTAL_NB_CHAR = 10000; + private static final Logger LOGGER = LogManager.getLogger(ChargementBrut.class); private Connection connexion; private List listeNorme; @@ -47,10 +48,10 @@ private String requeteFichierBrutalement(String idSource, BufferedReader br, int StringBuilder requete=new StringBuilder(); - int idLigne = nbBoucle * LIMIT_CHARGEMENT_BRUTAL; + int idLigne = nbBoucle * LIMIT_CHARGEMENT_BRUTAL_NB_LIGNE; String line; try { - line = br.readLine(); + line = br.readLine().substring(0, LIMIT_CHARGEMENT_BRUTAL_NB_CHAR); } catch (IOException e) { throw new ArcException(e, ArcExceptionMessage.FILE_READ_FAILED, idSource); } @@ -58,7 +59,7 @@ private String requeteFichierBrutalement(String idSource, BufferedReader br, int throw new ArcException(ArcExceptionMessage.FILE_IS_EMPTY, idSource); } boolean start=true; - while (line != null && idLigne < (nbBoucle + 1) * LIMIT_CHARGEMENT_BRUTAL) { + while (line != null && idLigne < (nbBoucle + 1) * LIMIT_CHARGEMENT_BRUTAL_NB_LIGNE) { if (start) { requete.append("\nSELECT "+FormatSQL.quoteText(idSource)+"::text as "+ColumnEnum.ID_SOURCE.getColumnName()+","+ idLigne +"::int as id_ligne,"+FormatSQL.quoteText(line)+"::text as ligne"); @@ -70,7 +71,7 @@ private String requeteFichierBrutalement(String idSource, BufferedReader br, int } idLigne++; - if (idLigne < (nbBoucle + 1) * LIMIT_CHARGEMENT_BRUTAL) { + if (idLigne < (nbBoucle + 1) * LIMIT_CHARGEMENT_BRUTAL_NB_LIGNE) { try { line = br.readLine(); } catch (IOException e) {