@Override public String toString() { return "init=" + FileUtil.humanReadableByteCount(initSize, false) + ",limit=" + FileUtil.humanReadableByteCount(limitBytes, false) + ",overflow_ratio=" + allowedOVerflowRatio + ",inc_ratio=" + incRatio; } }
protected void loadQueries(String dir) throws IOException { // TODO - this code dead?? File queryDir = new File(dir); if(!queryDir.exists()) { queryDir = new File(System.getProperty("user.dir") + "/tajo-core/" + dir); } if(!queryDir.exists()) { return; } int last; String name, query; for (String file : queryDir.list()) { if (file.endsWith(".sql")) { last = file.indexOf(".sql"); name = file.substring(0, last); query = FileUtil.readTextFile(new File(queryDir + "/" + file)); } } }
@Override protected void implCloseChannel() throws IOException { FileUtil.cleanup(null, channel, inputStream); } }
if (queries.length == 0) { Path queryFilePath = getQueryFilePath(getMethodName() + ".sql"); List<ParsedResult> parsedResults = SimpleParser.parseScript(FileUtil.readTextFile(new File(queryFilePath.toUri()))); int i = 0; for (; i < parsedResults.size() - 1; i++) { if (currentResultFS.exists(resultPath)) { assertEquals("Plan Verification for: " + (i + 1) + " th test", FileUtil.readTextFromStream(currentResultFS.open(resultPath)), prefix); } else if (prefix.length() > 0) { FileUtil.writeTextToStream(prefix, currentResultFS.create(resultPath)); LOG.info("New test output for " + current.getDisplayName() + " is written to " + resultPath); if (currentResultFS.exists(resultPath)) { assertEquals("Result Verification for: " + (i + 1) + " th test", FileUtil.readTextFromStream(currentResultFS.open(resultPath)), resultSetToString(result, option.sort())); } else if (!isNull(result)) { FileUtil.writeTextToStream(resultSetToString(result, option.sort()), currentResultFS.create(resultPath)); LOG.info("New test output for " + current.getDisplayName() + " is written to " + resultPath);
private void storeTableContents(String resource, Path path) throws IOException { String csvTable = JavaResourceUtil.readTextFromResource(resource); String fixedCsvTable = fixExtraColumn(csvTable); FileUtil.writeTextToFile(fixedCsvTable, path); }
/** * Read a file stored in a local file system and return the string contents. * * @param resource Resource file name * @return String contents * @throws IOException */ public static String readTextFromResource(String resource) throws IOException { InputStream stream = ClassLoader.getSystemResourceAsStream(resource); if (stream != null) { return FileUtil.readTextFromStream(stream); } else { throw new FileNotFoundException(resource); } } }
rootIndexBuffer.release(); FileUtil.cleanupAndthrowIfFailed(outChannel, outRandomAccessFile, out, rootOutChannel, rootOutRandomAccessFile, rootOut);
private TpchTestBase() throws IOException { names = new String[] {"customer", "lineitem", "nation", "orders", "part", "partsupp", "region", "supplier", "small_supplier", "empty_orders"}; paths = new String[names.length]; for (int i = 0; i < names.length; i++) { nameMap.put(names[i], i); } tpch = new TPCH(); tpch.loadSchemas(); tpch.loadQueries(); schemas = new Schema[names.length]; for (int i = 0; i < names.length; i++) { schemas[i] = tpch.getSchema(names[i]); } // create a temporal table File tpchTablesDir = new File(new File(CommonTestingUtil.getTestDir().toUri()), "tpch"); for (int i = 0; i < names.length; i++) { String str = JavaResourceUtil.readTextFromResource("tpch/" + names[i] + ".tbl"); Path tablePath = new Path(new Path(tpchTablesDir.toURI()), names[i] + ".tbl"); FileUtil.writeTextToFile(str, tablePath); paths[i] = tablePath.toString(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }
/** * Read a file stored in a local file system and return the string contents. * * @param resource Resource file name * @return String contents * @throws IOException */ public static String readTextFromResource(String resource) throws IOException { InputStream stream = ClassLoader.getSystemResourceAsStream(resource); if (stream != null) { return FileUtil.readTextFromStream(stream); } else { throw new FileNotFoundException(resource); } } }
rootIndexBuffer.release(); FileUtil.cleanupAndthrowIfFailed(outChannel, outRandomAccessFile, out, rootOutChannel, rootOutRandomAccessFile, rootOut);
@Override public String toString() { return "init=" + FileUtil.humanReadableByteCount(initSize, false) + ",limit=" + FileUtil.humanReadableByteCount(limitBytes, false) + ",overflow_ratio=" + allowedOVerflowRatio + ",inc_ratio=" + incRatio; } }
protected void loadQueries(String dir) throws IOException { // TODO - this code dead?? File queryDir = new File(dir); if(!queryDir.exists()) { queryDir = new File(System.getProperty("user.dir") + "/tajo-core/" + dir); } if(!queryDir.exists()) { return; } int last; String name, query; for (String file : queryDir.list()) { if (file.endsWith(".sql")) { last = file.indexOf(".sql"); name = file.substring(0, last); query = FileUtil.readTextFile(new File(queryDir + "/" + file)); } } }
@Override protected void implCloseChannel() throws IOException { FileUtil.cleanup(null, channel, inputStream); } }
@Override public String toString() { return "memory=" + FileUtil.humanReadableByteCount(capacity(), false) + "," + limitSpec; } }
private void verifyResultText(String message, ResultSet res, Path resultFile) throws SQLException, IOException { String actualResult = resultSetToString(res); String expectedResult = FileUtil.readTextFile(new File(resultFile.toUri())); assertEquals(message, expectedResult.trim(), actualResult.trim()); }
/** * Close the <code>OutputHandler</code>. * @throws IOException */ public void close() throws IOException { if(!alreadyClosed) { FileUtil.cleanup(LOG, istream, in); in = null; istream = null; alreadyClosed = true; if (this.buf.refCnt() > 0) { this.buf.release(); } } } }
@Override public String toString() { return "memory=" + FileUtil.humanReadableByteCount(capacity(), false) + "," + limitSpec; } }
public static String getResultText(Class clazz, String fileName) throws IOException { FileSystem localFS = FileSystem.getLocal(new Configuration()); Path path = getResultPath(clazz, fileName); Preconditions.checkState(localFS.exists(path) && localFS.isFile(path)); return FileUtil.readTextFile(new File(path.toUri())); } }
/** * Close the <code>OutputHandler</code>. * @throws IOException */ public void close() throws IOException { if(!alreadyClosed) { FileUtil.cleanup(LOG, istream, in); in = null; istream = null; alreadyClosed = true; if (this.buf.refCnt() > 0) { this.buf.release(); } } } }
public int increasedSize(int currentSize) { if (currentSize < initSize) { return (int) initSize; } if (currentSize == Integer.MAX_VALUE) { throw new TajoRuntimeException(new UnsupportedException( "Current size already exceeds the maximum size (" + Integer.MAX_VALUE + " bytes)")); } long nextSize = (long) (currentSize + ((float) currentSize * incRatio)); if (nextSize > limitBytes) { LOG.info("Increasing reaches size limit (" + FileUtil.humanReadableByteCount(limitBytes, false) + ")"); nextSize = limitBytes; } if (nextSize > Integer.MAX_VALUE) { LOG.info("Increasing reaches maximum size (" + FileUtil.humanReadableByteCount(Integer.MAX_VALUE, false) + ")"); nextSize = Integer.MAX_VALUE; } return (int) nextSize; }