Forum Stats

  • 3,759,513 Users
  • 2,251,557 Discussions
  • 7,870,690 Comments

Discussions

[Help Needed]

KatAlive
KatAlive Member Posts: 3 Green Ribbon
edited Aug 13, 2021 5:06PM in New To Java

Hi guys,

I need your help regarding JTable population process. I saw more applications that perform a check and actions on Tables with hundreds of thousands rows in less than 2 seconds. My app to find record in a table with 100.000 rows and sum units, needs more than 10 seconds. I'm probably using wrong technique to do this.


Example Method :


static void sum_units(){


String original_data = "DATA_1";

String status = null;

String target_data = null;


int sum_pending = 0, sum_picking = 0, sum_picked = 0;

int values = 0;


DefaultTableModel model_0 = (DefaultTableModel) table_1.getModel();


for(int i = 0; i < model_0.getRowCount(); i++){


target_data = model_0.getValueAt(i, 8).toString();

status = model_0.getValueAt(i, 5).toString();


if(model_0.getValueAt(i, 1) == null){


values = 0;


}else{


values = Integer.parseInt(model_0.getValueAt(i, 1).toString());

}


if(target_data.equals(original_data) && status.equals("Pending")){


sum_pending += values;

this.pending_text.setText(sum_pending);


}else if(target_data.equals(original_data) && status.equals("Picking")){


sum_picking += values;

this.picking_text.setText(sum_picking);


}else if(target_data.equals(original_data) && status.equals("Picked")){


sum_picked += values;

this.picked_text.setText(sum_picked);

}

}

}

Best Regards and Thank you in advance.

Carlo.