@Test public void testValidate() throws Exception { SplitInput st = new SplitInput(); assertValidateException(st); st.setTestSplitSize(100); assertValidateException(st); st.setTestOutputDirectory(tempTestDirectory); assertValidateException(st); st.setTrainingOutputDirectory(tempTrainingDirectory); st.validate(); st.setTestSplitPct(50); assertValidateException(st); st = new SplitInput(); st.setTestRandomSelectionPct(50); st.setTestOutputDirectory(tempTestDirectory); st.setTrainingOutputDirectory(tempTrainingDirectory); st.validate(); st.setTestSplitPct(50); assertValidateException(st); st = new SplitInput(); st.setTestRandomSelectionPct(50); st.setTestOutputDirectory(tempTestDirectory); st.setTrainingOutputDirectory(tempTrainingDirectory); st.validate(); st.setTestSplitSize(100); assertValidateException(st); }
public void validate() throws IOException { Preconditions.checkArgument(testSplitSize >= 1 || testSplitSize == -1, "Invalid testSplitSize: " + testSplitSize + ". Must be: testSplitSize >= 1 or testSplitSize = -1"); Preconditions.checkArgument(splitLocation >= 0 && splitLocation <= 100 || splitLocation == -1, "Invalid splitLocation percentage: " + splitLocation + ". Must be: 0 <= splitLocation <= 100 or splitLocation = -1"); Preconditions.checkArgument(testSplitPct >= 0 && testSplitPct <= 100 || testSplitPct == -1, "Invalid testSplitPct percentage: " + testSplitPct + ". Must be: 0 <= testSplitPct <= 100 or testSplitPct = -1"); Preconditions.checkArgument(testRandomSelectionPct >= 0 && testRandomSelectionPct <= 100 || testRandomSelectionPct == -1,"Invalid testRandomSelectionPct percentage: " + testRandomSelectionPct + ". Must be: 0 <= testRandomSelectionPct <= 100 or testRandomSelectionPct = -1"); Preconditions.checkArgument(trainingOutputDirectory != null || useMapRed, "No training output directory was specified"); Preconditions.checkArgument(testOutputDirectory != null || useMapRed, "No test output directory was specified"); int count = 0; if (testSplitSize > 0) { count++; } if (testSplitPct > 0) { count++; } if (testRandomSelectionSize > 0) { count++; } if (testRandomSelectionPct > 0) { count++; } Preconditions.checkArgument(count == 1, "Exactly one of testSplitSize, testSplitPct, testRandomSelectionSize, " + "testRandomSelectionPct should be set"); if (!useMapRed) { Configuration conf = getConf(); FileSystem fs = trainingOutputDirectory.getFileSystem(conf); FileStatus trainingOutputDirStatus = fs.getFileStatus(trainingOutputDirectory); Preconditions.checkArgument(trainingOutputDirStatus != null && trainingOutputDirStatus.isDir(), "%s is not a directory", trainingOutputDirectory); FileStatus testOutputDirStatus = fs.getFileStatus(testOutputDirectory); Preconditions.checkArgument(testOutputDirStatus != null && testOutputDirStatus.isDir(), "%s is not a directory", testOutputDirectory); } }
SplitInput extends AbstractJob { public void validate() throws IOException { Preconditions.checkArgument(testSplitSize >= 1 || testSplitSize == -1, "Invalid testSplitSize: " + testSplitSize + ". Must be: testSplitSize >= 1 or testSplitSize = -1"); Preconditions.checkArgument(splitLocation >= 0 && splitLocation <= 100 || splitLocation == -1, "Invalid splitLocation percentage: " + splitLocation + ". Must be: 0 <= splitLocation <= 100 or splitLocation = -1"); Preconditions.checkArgument(testSplitPct >= 0 && testSplitPct <= 100 || testSplitPct == -1, "Invalid testSplitPct percentage: " + testSplitPct + ". Must be: 0 <= testSplitPct <= 100 or testSplitPct = -1"); Preconditions.checkArgument(testRandomSelectionPct >= 0 && testRandomSelectionPct <= 100 || testRandomSelectionPct == -1,"Invalid testRandomSelectionPct percentage: " + testRandomSelectionPct + ". Must be: 0 <= testRandomSelectionPct <= 100 or testRandomSelectionPct = -1"); Preconditions.checkArgument(trainingOutputDirectory != null || useMapRed, "No training output directory was specified"); Preconditions.checkArgument(testOutputDirectory != null || useMapRed, "No test output directory was specified"); int count = 0; if (testSplitSize > 0) { count++; } if (testSplitPct > 0) { count++; } if (testRandomSelectionSize > 0) { count++; } if (testRandomSelectionPct > 0) { count++; } Preconditions.checkArgument(count == 1, "Exactly one of testSplitSize, testSplitPct, testRandomSelectionSize, " + "testRandomSelectionPct should be set"); if (!useMapRed) { Configuration conf = getConf(); FileSystem fs = trainingOutputDirectory.getFileSystem(conf); FileStatus trainingOutputDirStatus = fs.getFileStatus(trainingOutputDirectory); Preconditions.checkArgument(trainingOutputDirStatus != null && trainingOutputDirStatus.isDir(), "%s is not a directory", trainingOutputDirectory); FileStatus testOutputDirStatus = fs.getFileStatus(testOutputDirectory); Preconditions.checkArgument(testOutputDirStatus != null && testOutputDirStatus.isDir(), "%s is not a directory", testOutputDirectory); } } }
SplitInput extends AbstractJob { public void validate() throws IOException { Preconditions.checkArgument(testSplitSize >= 1 || testSplitSize == -1, "Invalid testSplitSize: " + testSplitSize + ". Must be: testSplitSize >= 1 or testSplitSize = -1"); Preconditions.checkArgument(splitLocation >= 0 && splitLocation <= 100 || splitLocation == -1, "Invalid splitLocation percentage: " + splitLocation + ". Must be: 0 <= splitLocation <= 100 or splitLocation = -1"); Preconditions.checkArgument(testSplitPct >= 0 && testSplitPct <= 100 || testSplitPct == -1, "Invalid testSplitPct percentage: " + testSplitPct + ". Must be: 0 <= testSplitPct <= 100 or testSplitPct = -1"); Preconditions.checkArgument(testRandomSelectionPct >= 0 && testRandomSelectionPct <= 100 || testRandomSelectionPct == -1,"Invalid testRandomSelectionPct percentage: " + testRandomSelectionPct + ". Must be: 0 <= testRandomSelectionPct <= 100 or testRandomSelectionPct = -1"); Preconditions.checkArgument(trainingOutputDirectory != null || useMapRed, "No training output directory was specified"); Preconditions.checkArgument(testOutputDirectory != null || useMapRed, "No test output directory was specified"); int count = 0; if (testSplitSize > 0) { count++; } if (testSplitPct > 0) { count++; } if (testRandomSelectionSize > 0) { count++; } if (testRandomSelectionPct > 0) { count++; } Preconditions.checkArgument(count == 1, "Exactly one of testSplitSize, testSplitPct, testRandomSelectionSize, " + "testRandomSelectionPct should be set"); if (!useMapRed) { Configuration conf = getConf(); FileSystem fs = trainingOutputDirectory.getFileSystem(conf); FileStatus trainingOutputDirStatus = fs.getFileStatus(trainingOutputDirectory); Preconditions.checkArgument(trainingOutputDirStatus != null && trainingOutputDirStatus.isDir(), "%s is not a directory", trainingOutputDirectory); FileStatus testOutputDirStatus = fs.getFileStatus(testOutputDirectory); Preconditions.checkArgument(testOutputDirStatus != null && testOutputDirStatus.isDir(), "%s is not a directory", testOutputDirectory); } }  }
SplitInput extends AbstractJob { public void validate() throws IOException { Preconditions.checkArgument(testSplitSize >= 1 || testSplitSize == -1, "Invalid testSplitSize: " + testSplitSize + ". Must be: testSplitSize >= 1 or testSplitSize = -1"); Preconditions.checkArgument(splitLocation >= 0 && splitLocation <= 100 || splitLocation == -1, "Invalid splitLocation percentage: " + splitLocation + ". Must be: 0 <= splitLocation <= 100 or splitLocation = -1"); Preconditions.checkArgument(testSplitPct >= 0 && testSplitPct <= 100 || testSplitPct == -1, "Invalid testSplitPct percentage: " + testSplitPct + ". Must be: 0 <= testSplitPct <= 100 or testSplitPct = -1"); Preconditions.checkArgument(testRandomSelectionPct >= 0 && testRandomSelectionPct <= 100 || testRandomSelectionPct == -1,"Invalid testRandomSelectionPct percentage: " + testRandomSelectionPct + ". Must be: 0 <= testRandomSelectionPct <= 100 or testRandomSelectionPct = -1"); Preconditions.checkArgument(trainingOutputDirectory != null || useMapRed, "No training output directory was specified"); Preconditions.checkArgument(testOutputDirectory != null || useMapRed, "No test output directory was specified"); int count = 0; if (testSplitSize > 0) { count++; } if (testSplitPct > 0) { count++; } if (testRandomSelectionSize > 0) { count++; } if (testRandomSelectionPct > 0) { count++; } Preconditions.checkArgument(count == 1, "Exactly one of testSplitSize, testSplitPct, testRandomSelectionSize, " + "testRandomSelectionPct should be set"); if (!useMapRed) { Configuration conf = getConf(); FileSystem fs = trainingOutputDirectory.getFileSystem(conf); FileStatus trainingOutputDirStatus = fs.getFileStatus(trainingOutputDirectory); Preconditions.checkArgument(trainingOutputDirStatus != null && trainingOutputDirStatus.isDir(), "%s is not a directory", trainingOutputDirectory); FileStatus testOutputDirStatus = fs.getFileStatus(testOutputDirectory); Preconditions.checkArgument(testOutputDirStatus != null && testOutputDirStatus.isDir(), "%s is not a directory", testOutputDirectory); } }  @Override int run(String[] args); static void main(String[] args); void splitDirectory(); void splitDirectory(Path inputDir); void splitDirectory(Configuration conf, Path inputDir); void splitFile(Path inputFile); int getTestSplitSize(); void setTestSplitSize(int testSplitSize); int getTestSplitPct(); void setTestSplitPct(int testSplitPct); void setKeepPct(int keepPct); void setUseMapRed(boolean useMapRed); void setMapRedOutputDirectory(Path mapRedOutputDirectory); int getSplitLocation(); void setSplitLocation(int splitLocation); Charset getCharset(); void setCharset(Charset charset); Path getInputDirectory(); void setInputDirectory(Path inputDir); Path getTrainingOutputDirectory(); void setTrainingOutputDirectory(Path trainingOutputDir); Path getTestOutputDirectory(); void setTestOutputDirectory(Path testOutputDir); SplitCallback getCallback(); void setCallback(SplitCallback callback); int getTestRandomSelectionSize(); void setTestRandomSelectionSize(int testRandomSelectionSize); int getTestRandomSelectionPct(); void setTestRandomSelectionPct(int randomSelectionPct); void validate(); static int countLines(FileSystem fs, Path inputFile, Charset charset); }
SplitInput extends AbstractJob { public void validate() throws IOException { Preconditions.checkArgument(testSplitSize >= 1 || testSplitSize == -1, "Invalid testSplitSize: " + testSplitSize + ". Must be: testSplitSize >= 1 or testSplitSize = -1"); Preconditions.checkArgument(splitLocation >= 0 && splitLocation <= 100 || splitLocation == -1, "Invalid splitLocation percentage: " + splitLocation + ". Must be: 0 <= splitLocation <= 100 or splitLocation = -1"); Preconditions.checkArgument(testSplitPct >= 0 && testSplitPct <= 100 || testSplitPct == -1, "Invalid testSplitPct percentage: " + testSplitPct + ". Must be: 0 <= testSplitPct <= 100 or testSplitPct = -1"); Preconditions.checkArgument(testRandomSelectionPct >= 0 && testRandomSelectionPct <= 100 || testRandomSelectionPct == -1,"Invalid testRandomSelectionPct percentage: " + testRandomSelectionPct + ". Must be: 0 <= testRandomSelectionPct <= 100 or testRandomSelectionPct = -1"); Preconditions.checkArgument(trainingOutputDirectory != null || useMapRed, "No training output directory was specified"); Preconditions.checkArgument(testOutputDirectory != null || useMapRed, "No test output directory was specified"); int count = 0; if (testSplitSize > 0) { count++; } if (testSplitPct > 0) { count++; } if (testRandomSelectionSize > 0) { count++; } if (testRandomSelectionPct > 0) { count++; } Preconditions.checkArgument(count == 1, "Exactly one of testSplitSize, testSplitPct, testRandomSelectionSize, " + "testRandomSelectionPct should be set"); if (!useMapRed) { Configuration conf = getConf(); FileSystem fs = trainingOutputDirectory.getFileSystem(conf); FileStatus trainingOutputDirStatus = fs.getFileStatus(trainingOutputDirectory); Preconditions.checkArgument(trainingOutputDirStatus != null && trainingOutputDirStatus.isDir(), "%s is not a directory", trainingOutputDirectory); FileStatus testOutputDirStatus = fs.getFileStatus(testOutputDirectory); Preconditions.checkArgument(testOutputDirStatus != null && testOutputDirStatus.isDir(), "%s is not a directory", testOutputDirectory); } }  @Override int run(String[] args); static void main(String[] args); void splitDirectory(); void splitDirectory(Path inputDir); void splitDirectory(Configuration conf, Path inputDir); void splitFile(Path inputFile); int getTestSplitSize(); void setTestSplitSize(int testSplitSize); int getTestSplitPct(); void setTestSplitPct(int testSplitPct); void setKeepPct(int keepPct); void setUseMapRed(boolean useMapRed); void setMapRedOutputDirectory(Path mapRedOutputDirectory); int getSplitLocation(); void setSplitLocation(int splitLocation); Charset getCharset(); void setCharset(Charset charset); Path getInputDirectory(); void setInputDirectory(Path inputDir); Path getTrainingOutputDirectory(); void setTrainingOutputDirectory(Path trainingOutputDir); Path getTestOutputDirectory(); void setTestOutputDirectory(Path testOutputDir); SplitCallback getCallback(); void setCallback(SplitCallback callback); int getTestRandomSelectionSize(); void setTestRandomSelectionSize(int testRandomSelectionSize); int getTestRandomSelectionPct(); void setTestRandomSelectionPct(int randomSelectionPct); void validate(); static int countLines(FileSystem fs, Path inputFile, Charset charset);  }