Java Code Examples for com.indeed.util.io.Files#delete()
The following examples show how to use
com.indeed.util.io.Files#delete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSquallArchive.java From imhotep with Apache License 2.0 | 6 votes |
private static void checkDirectory(FileSystem fs, Path tempDir, File localTempDir, File localArchiveDir) throws IOException { Files.delete(localArchiveDir.getAbsolutePath()); final SquallArchiveReader reader = new SquallArchiveReader(fs, tempDir); reader.copyToLocal("tmp/tempfile", localTempDir.getAbsolutePath()); assertTrue(ByteStreams.equal( com.google.common.io.Files.newInputStreamSupplier(new File(localArchiveDir, "tempfile")), ByteStreams.newInputStreamSupplier(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) )); Files.delete(localArchiveDir.getAbsolutePath()); reader.copyAllToLocal(localTempDir.getAbsolutePath()); assertTrue(ByteStreams.equal( com.google.common.io.Files.newInputStreamSupplier(new File(localArchiveDir, "tempfile")), ByteStreams.newInputStreamSupplier(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) )); }
Example 2
Source File: SimpleFlamdexTest.java From imhotep with Apache License 2.0 | 6 votes |
@Test public void testEmptyFields() throws IOException { final String dir = Files.getTempDirectory("flamdex-test", "foo"); try { SimpleFlamdexWriter w = new SimpleFlamdexWriter(dir, 5L, true); w.getIntFieldWriter("if1").close(); w.getStringFieldWriter("sf1").close(); w.close(); SimpleFlamdexReader r = SimpleFlamdexReader.open(dir); IntTermIterator it = r.getIntTermIterator("if1"); assertFalse(it.next()); StringTermIterator sit = r.getStringTermIterator("sf1"); assertFalse(sit.next()); it.close(); sit.close(); r.close(); } finally { Files.delete(dir); } }
Example 3
Source File: SmartDictionarySerializer.java From mph-table with Apache License 2.0 | 5 votes |
private GOV4Function<String> buildMphFunction() throws IOException { final File tempFolder = File.createTempFile("smartDictionarySerializer", ".tmp"); if (!Files.delete(tempFolder.getAbsolutePath())) { throw new IOException("Can't delete tempFolder: " + tempFolder); } if (!tempFolder.mkdir()) { throw new IOException("Can't create tempFolder: " + tempFolder); } return new GOV4Function.Builder<String>() .keys(Arrays.asList(words)) .tempDir(tempFolder) .transform(new TableWriter.SerializerTransformationStrategy<>(new SmartStringSerializer())) .build(); }
Example 4
Source File: TestSquallArchive.java From imhotep with Apache License 2.0 | 5 votes |
private static void doTheTest(FileSystem fs, Path tempDir, File localTempDir, SquallArchiveCompressor compressor) throws IOException { final Random rand = new Random(); final List<File> tempFiles = new ArrayList<File>(); for (int i = 0; i < 10; ++i) { final File tempFile = new File(localTempDir, "tempfile" + i); tempFiles.add(tempFile); final int len = rand.nextInt(1024) + 1024; final OutputStream os = new FileOutputStream(tempFile); for (int j = 0; j < len; ++j) { os.write(rand.nextInt(256)); } os.close(); } Collections.shuffle(tempFiles); long bytesWritten = writeHalfTheFiles(fs, tempDir, tempFiles, compressor); if (compressor == NONE) { assertEquals(bytesWritten, getArchiveBytesWritten(fs, tempDir)); } final File localTempDir2 = new File(getTempDir()); try { readHalfTheFiles(fs, tempDir, localTempDir2, tempFiles); } finally { Files.delete(localTempDir2.getAbsolutePath()); } bytesWritten += writeTheOtherHalf(fs, tempDir, tempFiles, compressor); if (compressor == NONE) { assertEquals(bytesWritten, getArchiveBytesWritten(fs, tempDir)); } if (!localTempDir2.mkdirs()) throw new IOException(); try { readAllTheFiles(fs, tempDir, localTempDir2, tempFiles); } finally { Files.delete(localTempDir2.getAbsolutePath()); } }
Example 5
Source File: TestImhotepClient.java From imhotep with Apache License 2.0 | 5 votes |
@Override protected void tearDown() throws Exception { if (daemon1 != null) { daemon1.stop(); } if (daemon2 != null) { daemon2.stop(); } Files.delete(tempDir1); Files.delete(tempDir2); }
Example 6
Source File: SimpleFlamdexTest.java From imhotep with Apache License 2.0 | 5 votes |
@Test public void testIt() throws IOException { final String dir = Files.getTempDirectory("flamdex-test", "foo"); try { writeAndRead(dir); } finally { Files.delete(dir); } }
Example 7
Source File: SimpleFlamdexTest.java From imhotep with Apache License 2.0 | 5 votes |
@Test public void testGetMetric() throws IOException, FlamdexOutOfMemoryException { final String dir = Files.getTempDirectory("flamdex-test", "foo"); try { internalTestGetMetric(dir); } finally { Files.delete(dir); } }
Example 8
Source File: TestZooKeeperConnection.java From util with Apache License 2.0 | 5 votes |
@After public void stopZK() { if (zk != null) { zk.shutdown(); } Files.delete(tempDir); }
Example 9
Source File: TestCloseSessionDuringFTGS.java From imhotep with Apache License 2.0 | 4 votes |
@Test public void testCloseSessionDuringFTGS() throws ImhotepOutOfMemoryException, IOException, InterruptedException { String tempDir = Files.getTempDirectory("asdf", ""); try { IndexWriter w = new IndexWriter(tempDir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); Random rand = new Random(); for (int i = 0; i < 1000000; ++i) { int numTerms = rand.nextInt(5) + 5; Document doc = new Document(); for (int t = 0; t < numTerms; ++t) { doc.add(new Field("sf1", Integer.toString(rand.nextInt(10000)), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); } w.addDocument(doc); } w.close(); final AtomicBoolean closed = new AtomicBoolean(false); FlamdexReader r = new LuceneFlamdexReader(IndexReader.open(tempDir)) { @Override public void close() throws IOException { super.close(); closed.set(true); } }; final ExecutorService executor = Executors.newCachedThreadPool(); try { ImhotepSession session = new MTImhotepMultiSession(new ImhotepLocalSession[] { new ImhotepLocalSession(r) }, new MemoryReservationContext( new ImhotepMemoryPool( Long.MAX_VALUE)), executor, null); // FTGSIterator iter = session.getFTGSIterator(new String[]{}, new String[]{"sf1"}); //TODO fix this session.close(); assertTrue(closed.get()); } finally { executor.shutdown(); } } finally { Files.delete(tempDir); } }
Example 10
Source File: TestSimpleFlamdexDocWriter.java From imhotep with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { Files.delete(tempDir); }
Example 11
Source File: TestSimpleIterators.java From imhotep with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { Files.delete(tempDir); }