@SuppressWarnings("resource") private FileChannel createSpillingChannel() throws IOException { if (spillFile != null) { throw new IllegalStateException("Spilling file already exists."); } String directory = tempDirs[rnd.nextInt(tempDirs.length)]; spillFile = new File(directory, randomString(rnd) + ".inputchannel"); return new RandomAccessFile(spillFile, "rw").getChannel(); }
@SuppressWarnings("resource") private FileChannel createSpillingChannel() throws IOException { if (spillFile != null) { throw new IllegalStateException("Spilling file already exists."); } // try to find a unique file name for the spilling channel int maxAttempts = 10; for (int attempt = 0; attempt < maxAttempts; attempt++) { String directory = tempDirs[rnd.nextInt(tempDirs.length)]; spillFile = new File(directory, randomString(rnd) + ".inputchannel"); if (spillFile.createNewFile()) { return new RandomAccessFile(spillFile, "rw").getChannel(); } } throw new IOException( "Could not find a unique file channel name in '" + Arrays.toString(tempDirs) + "' for spilling large records during deserialization."); }
@SuppressWarnings("resource") private FileChannel createSpillingChannel() throws IOException { if (spillFile != null) { throw new IllegalStateException("Spilling file already exists."); } // try to find a unique file name for the spilling channel int maxAttempts = 10; for (int attempt = 0; attempt < maxAttempts; attempt++) { String directory = tempDirs[rnd.nextInt(tempDirs.length)]; spillFile = new File(directory, randomString(rnd) + ".inputchannel"); if (spillFile.createNewFile()) { return new RandomAccessFile(spillFile, "rw").getChannel(); } } throw new IOException( "Could not find a unique file channel name in '" + Arrays.toString(tempDirs) + "' for spilling large records during deserialization."); }