Skip to content

Commit

Permalink
feat: limit number of chars when retrieving file metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
lmanelphe committed Jan 22, 2024
1 parent 27560aa commit dc8c413
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<NormeRules> listeNorme;
Expand All @@ -47,18 +48,18 @@ 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);
}
if (line == null) {
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");
Expand All @@ -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) {
Expand Down

0 comments on commit dc8c413

Please sign in to comment.