public static String getSpecName(Path specUri) { return Files.getNameWithoutExtension(specUri.getName()); }
@Override public String getName() { final String ext = Files.getFileExtension(path); return Files.getNameWithoutExtension(path) + (Strings.isNullOrEmpty(ext) ? "" : ("." + ext)); }
public FilenameVdexProvider(File oatFile) { File oatParent = oatFile.getAbsoluteFile().getParentFile(); String baseName = Files.getNameWithoutExtension(oatFile.getAbsolutePath()); vdexFile = new File(oatParent, baseName + ".vdex"); }
public String getFlowName(final File flowFile) { checkArgument(flowFile != null && flowFile.exists()); checkArgument(flowFile.getName().endsWith(Constants.FLOW_FILE_SUFFIX)); return Files.getNameWithoutExtension(flowFile.getName()); } }
public BenchmarkQuery(File file) throws IOException { requireNonNull(file, "file is null"); name = Files.getNameWithoutExtension(file.getName()); // file can have 2 sections separated by a line of equals signs String text = Files.toString(file, StandardCharsets.UTF_8); List<String> sections = SECTION_SPLITTER.splitToList(text); if (sections.size() == 2) { this.tags = ImmutableMap.copyOf(TAGS_SPLITTER.split(sections.get(0))); this.sql = sections.get(1); } else { // no tags this.tags = ImmutableMap.of(); this.sql = sections.get(0); } }
/** * Construct a new file path by appending record count to the filename of the given file path, separated by SEPARATOR. * For example, given path: "/a/b/c/file.avro" and record count: 123, * the new path returned will be: "/a/b/c/file.123.avro" */ public static String constructFilePath(String oldFilePath, long recordCounts) { return new Path(new Path(oldFilePath).getParent(), Files.getNameWithoutExtension(oldFilePath).toString() + SEPARATOR + recordCounts + SEPARATOR + Files.getFileExtension(oldFilePath)).toString(); }
/** * Get the file name without the .gz extension * * @param fname The name of the gzip file * * @return fname without the ".gz" extension * * @throws IAE if fname is not a valid "*.gz" file name */ public static String getGzBaseName(String fname) { final String reducedFname = Files.getNameWithoutExtension(fname); if (isGz(fname) && !reducedFname.isEmpty()) { return reducedFname; } throw new IAE("[%s] is not a valid gz file name", fname); }
private void loadCatalog(File file) throws Exception { String catalogName = Files.getNameWithoutExtension(file.getName()); if (disabledCatalogs.contains(catalogName)) { log.info("Skipping disabled catalog %s", catalogName); return; } log.info("-- Loading catalog %s --", file); Map<String, String> properties = new HashMap<>(loadProperties(file)); String connectorName = properties.remove("connector.name"); checkState(connectorName != null, "Catalog configuration %s does not contain connector.name", file.getAbsoluteFile()); connectorManager.createConnection(catalogName, connectorName, ImmutableMap.copyOf(properties)); log.info("-- Added catalog %s using connector %s --", catalogName, connectorName); }
/** * The job template name is derived from the {@link org.apache.gobblin.runtime.api.JobTemplate} URI. It is the * simple name of the path component of the URI. * @param jobExecutionPlan * @return the simple name of the job template from the URI of its path. */ private static String getJobTemplateName(JobExecutionPlan jobExecutionPlan) { Optional<URI> jobTemplateUri = jobExecutionPlan.getJobSpec().getTemplateURI(); if (jobTemplateUri.isPresent()) { return Files.getNameWithoutExtension(new Path(jobTemplateUri.get()).getName()); } else { return null; } }
public void testGetNameWithoutExtension() { assertEquals("", Files.getNameWithoutExtension(".txt")); assertEquals("blah", Files.getNameWithoutExtension("blah.txt")); assertEquals("blah.", Files.getNameWithoutExtension("blah..txt")); assertEquals(".blah", Files.getNameWithoutExtension(".blah.txt")); assertEquals("blah", Files.getNameWithoutExtension("/tmp/blah.txt")); assertEquals("blah.tar", Files.getNameWithoutExtension("blah.tar.gz")); assertEquals("", Files.getNameWithoutExtension("/")); assertEquals("", Files.getNameWithoutExtension(".")); assertEquals(".", Files.getNameWithoutExtension("..")); assertEquals("..", Files.getNameWithoutExtension("...")); assertEquals("blah", Files.getNameWithoutExtension("blah")); assertEquals("blah", Files.getNameWithoutExtension("blah.")); assertEquals(".blah", Files.getNameWithoutExtension(".blah.")); assertEquals("blah", Files.getNameWithoutExtension("/foo.bar/blah")); assertEquals("blah", Files.getNameWithoutExtension("/foo/.bar/blah")); }
/** * Helper that overrides the flow edge properties with name derived from the edge file path * @param edgeConfig edge config * @param edgeFilePath path of the edge file * @return config with overridden edge properties */ private Config getEdgeConfigWithOverrides(Config edgeConfig, Path edgeFilePath) { String source = edgeFilePath.getParent().getParent().getName(); String destination = edgeFilePath.getParent().getName(); String edgeName = Files.getNameWithoutExtension(edgeFilePath.getName()); return edgeConfig.withValue(FlowGraphConfigurationKeys.FLOW_EDGE_SOURCE_KEY, ConfigValueFactory.fromAnyRef(source)) .withValue(FlowGraphConfigurationKeys.FLOW_EDGE_DESTINATION_KEY, ConfigValueFactory.fromAnyRef(destination)) .withValue(FlowGraphConfigurationKeys.FLOW_EDGE_ID_KEY, ConfigValueFactory.fromAnyRef(getEdgeId(source, destination, edgeName))); }
File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash"); if (hashFile.exists())
@Test public void simpleDirectoryTest() throws IOException, SegmentLoadingException { File srcDir = temporaryFolder.newFolder(); File tmpFile = File.createTempFile("test", "file", srcDir); File expectedOutput = new File(tmpDir, Files.getNameWithoutExtension(tmpFile.getAbsolutePath())); Assert.assertFalse(expectedOutput.exists()); puller.getSegmentFiles(srcDir, tmpDir); Assert.assertTrue(expectedOutput.exists()); } }
@Test public void simpleGZTest() throws IOException, SegmentLoadingException { File zipFile = File.createTempFile("gztest", ".gz"); File unZipFile = new File( tmpDir, Files.getNameWithoutExtension( zipFile.getAbsolutePath() ) ); unZipFile.delete(); zipFile.delete(); try (OutputStream fOutStream = new FileOutputStream(zipFile)) { try (OutputStream outputStream = new GZIPOutputStream(fOutStream)) { outputStream.write(new byte[0]); outputStream.flush(); } } Assert.assertTrue(zipFile.exists()); Assert.assertFalse(unZipFile.exists()); puller.getSegmentFiles(zipFile, tmpDir); Assert.assertTrue(unZipFile.exists()); }
return Description.NO_MATCH; String filename = Files.getNameWithoutExtension(ASTHelpers.getFileName(tree)); List<String> names = new ArrayList<>(); for (Tree member : tree.getTypeDecls()) {
final String fname = Files.getNameWithoutExtension(uri.getPath()); final File outFile = new File(outDir, fname);
Pattern.compile(Pattern.quote(Files.getNameWithoutExtension(originalFilename)) + suffixPattern + "\\.avro"); Path secondOutput = lateFileRecordCountProvider.constructLateFilePath(firstOutput.getName(), fs, testDir); Assert.assertEquals(testDir, secondOutput.getParent()); Pattern.compile(Files.getNameWithoutExtension(originalFilename) + suffixPattern + suffixPattern + "\\.avro"); Path thirdOutput = lateFileRecordCountProvider.constructLateFilePath(secondOutput.getName(), fs, testDir); Assert.assertEquals(testDir, thirdOutput.getParent());
if (simplifyOpts.getOutFile() == null) { String fileName = simplifyOpts.getInFile().toString(); String baseName = Files.getNameWithoutExtension(fileName); String outFileName = baseName + "_simple";
URI topologySpecUri = new URI(Files.getNameWithoutExtension(fileStatus.getPath().getName())); Config topologyConfig = ConfigFactory.parseFile(new File(PathUtils.getPathWithoutSchemeAndAuthority(fileStatus.getPath()).toString())); Class specExecutorClass = Class.forName(topologyConfig.getString(ServiceConfigKeys.SPEC_EXECUTOR_KEY));
String jobSpecUri = Files.getNameWithoutExtension(new Path(jobTemplate.getUri()).getName()); jobExecutionPlans.add(new JobExecutionPlan(JobSpec.builder(jobSpecUri).withConfig(jobTemplate.getRawTemplateConfig()). withVersion("1").withTemplate(jobTemplate.getUri()).build(), specExecutor));