@Override public void close() throws IOException { _parser.close(); } }
@Override public void close() throws IOException { csvParser.close(); } }
@Override public void rewind() throws IOException { _parser.close(); init(); }
public synchronized List<Result> read() throws IOException { CSVParser parser = null; util.ensureBaseResultDirExists(); try { File file = new File(resultFileName); parser = CSVParser.parse(file, Charset.defaultCharset(), CSVFormat.DEFAULT); List<CSVRecord> records = parser.getRecords(); List<Result> results = new ArrayList<>(); String header = null; for (CSVRecord record : records) { // First record is the CSV Header if (record.getRecordNumber() == 1) { header = record.toString(); continue; } List<ResultValue> resultValues = new ArrayList<>(); for (String val : record.toString().split(PherfConstants.RESULT_FILE_DELIMETER)) { resultValues.add(new ResultValue(val)); } Result result = new Result(resultFileDetails, header, resultValues); results.add(result); } return results; } finally { parser.close(); } }
parser.close();
csvParser.close();
parser.close(); if (conn != null) conn.close();
parser.close(); if (conn != null) conn.close();
parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
@Test public void testCSVUpsertWithInvalidNumericalData_StrictMode() throws Exception { CSVParser parser = null; PhoenixConnection conn = null; try { String stockTableName = generateUniqueName(); // Create table String statements = "CREATE TABLE IF NOT EXISTS " + stockTableName + "(SYMBOL VARCHAR NOT NULL PRIMARY KEY, COMPANY_ID BIGINT);"; conn = DriverManager.getConnection(getUrl()) .unwrap(PhoenixConnection.class); PhoenixRuntime.executeStatements(conn, new StringReader(statements), null); // Upsert CSV file in strict mode CSVCommonsLoader csvUtil = new CSVCommonsLoader(conn, stockTableName, Arrays.asList("SYMBOL", "COMPANY_ID"), true); try { csvUtil.upsert(new StringReader(STOCK_CSV_VALUES)); fail("Running an upsert with data that can't be upserted in strict mode " + "should throw an exception"); } catch (IllegalDataException e) { // Expected } } finally { if (parser != null) parser.close(); if (conn != null) conn.close(); } }
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (conn != null) conn.close();
} finally { if (parser != null) parser.close(); if (tenantConn != null) tenantConn.close();