lewismc commented on a change in pull request #28: SDAP-80
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/28#discussion_r190307563
 
 

 ##########
 File path: 
core/src/main/java/org/apache/sdap/mudrod/ssearch/ranking/TrainingImporter.java
 ##########
 @@ -63,29 +63,31 @@ public void addMapping() {
   /**
    * Method of importing training set in to Elasticsearch
    *
-   * @param dataFolder the path to the traing set
-   * @throws IOException IOException
+   * @param dataFolder
+   *          the path to the traing set
+   * @throws IOException
+   *           IOException
    */
   public void importTrainingSet(String dataFolder) throws IOException {
     es.createBulkProcessor();
 
     File[] files = new File(dataFolder).listFiles();
     for (File file : files) {
-      BufferedReader br = new BufferedReader(new 
FileReader(file.getAbsolutePath()));
-      br.readLine();
-      String line = br.readLine();
-      while (line != null) {
-        String[] list = line.split(",");
-        String query = file.getName().replace(".csv", "");
-        if (list.length > 0) {
-          IndexRequest ir = new 
IndexRequest(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
"trainingranking")
-              .source(jsonBuilder().startObject().field("query", 
query).field("dataID", list[0]).field("label", list[list.length - 
1]).endObject());
-          es.getBulkProcessor().add(ir);
+      try (BufferedReader br = new BufferedReader(new 
FileReader(file.getAbsolutePath()))) {
+        String line = null;
+        line = br.readLine(); // cvs header
+        while ((line = br.readLine()) != null) {
 
 Review comment:
   Have you tested this code? It look suspicious.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to