Skip to content

Commit

Permalink
parallelise file parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
frankisawesome committed Oct 31, 2021
1 parent 0ff9a2a commit dd86242
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified out/production/promoter/parallel/ParallelStreaming.class
Binary file not shown.
Binary file modified out/production/promoter/qut/Sequential.class
Binary file not shown.
9 changes: 3 additions & 6 deletions src/parallel/ParallelStreaming.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ public void run(String referenceFile, String dir) throws IOException {
List<GenbankRecord> records = new LinkedList<>();

// we might want to parallelise this for maxmimum performance
for (String filename : ListGenbankFiles(dir)) {
System.out.println(filename);
records.add(Parse(filename));
}
records = ListGenbankFiles(dir).parallelStream()
.map(Sequential::Parse)
.collect(Collectors.toList());

// have all dependencies ready to run in parallel stream
for (GenbankRecord record : records) {
Expand All @@ -68,8 +67,6 @@ public void run(String referenceFile, String dir) throws IOException {

ForkJoinPool customThreadPool = new ForkJoinPool(11);

customThreadPool = new ForkJoinPool(11);

try {
customThreadPool.submit(
() -> {
Expand Down
12 changes: 8 additions & 4 deletions src/qut/Sequential.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ protected static List<String> ListGenbankFiles(String dir) {
return list;
}

protected static GenbankRecord Parse(String file) throws IOException {
protected static GenbankRecord Parse(String file) {
GenbankRecord record = new GenbankRecord();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
record.Parse(reader);
reader.close();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
record.Parse(reader);
reader.close();
} catch (Exception e) {
//
}
return record;
}

Expand Down

0 comments on commit dd86242

Please sign in to comment.