@Override public Path getName(int index) { return delegate.getName(index); }
private void parseV1Prefix(Path remoteFilePath) { if (remoteFilePath.getNameCount() < 4) throw new RuntimeException( "Not enough no. of elements to parseV1Prefix : " + remoteFilePath); baseDir = remoteFilePath.getName(0).toString(); region = remoteFilePath.getName(1).toString(); clusterName = remoteFilePath.getName(2).toString(); token = remoteFilePath.getName(3).toString(); }
@Override public boolean accept( File file ) { Path path = file.toPath(); if ( !path.toAbsolutePath().startsWith( indexRoot ) ) { // This file isn't even under the schema/index root directory return false; } Path schemaPath = indexRoot.relativize( path ); int nameCount = schemaPath.getNameCount(); // - schema/index/lucene/..... boolean isPureLuceneProviderFile = nameCount >= 1 && schemaPath.getName( 0 ).toString().equals( "lucene" ); // - schema/index/lucene_native-x.y/<indexId>/lucene-x.y/x/..... boolean isFusionLuceneProviderFile = nameCount >= 3 && schemaPath.getName( 2 ).toString().startsWith( "lucene-" ); return !isPureLuceneProviderFile && !isFusionLuceneProviderFile; } }
public AWTTextureFormat() { this(Texture.FilterMode.NEAREST, path -> { if (path.getName(1).toString().equals(ModuleAssetDataProducer.OVERRIDE_FOLDER)) { return path.getName(3).toString().equals("textures"); } else { return path.getName(2).toString().equals("textures"); } }); } public AWTTextureFormat(Texture.FilterMode defaultFilterMode, PathMatcher pathMatcher) {
private void parseV2Prefix(Path remoteFilePath) { if (remoteFilePath.getNameCount() < 3) throw new RuntimeException( "Not enough no. of elements to parseV2Prefix : " + remoteFilePath); baseDir = remoteFilePath.getName(0).toString(); clusterName = parseAndValidateAppNameWithHash(remoteFilePath.getName(1).toString()); token = remoteFilePath.getName(2).toString(); }
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) { if (path.equals(rootPath)) { return FileVisitResult.CONTINUE; } // compare only the first subfolder String relPath = rootPath.relativize(path).getName(0).toString(); try { Date folderDate = TIMESTAMP_FORMAT.parse(relPath); long ageInSecs = folderDate.toInstant().until(Instant.now(), ChronoUnit.SECONDS); return ageInSecs > maxAgeInSecs ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; } catch (ParseException e) { return FileVisitResult.SKIP_SUBTREE; } }
private static int getGlobIndex(final Path path) { int nameCount = path.getNameCount(); for (int i = 0; i < nameCount; i++) { String current = path.getName(i).toString(); int length = current.length(); for (int j = 0; j < length; j++) { if (isGlobMeta(current.charAt(j))) { return i; } } } return -1; }
@Override public String getShard() { return getPrefix().getName(0).toString(); }
private String getPath(final FlowFile flowFile) { Path path = Paths.get(flowFile.getAttribute(CoreAttributes.PATH.key())); if (path.getNameCount() == 0) { return ""; } if (".".equals(path.getName(0).toString())) { path = path.getNameCount() == 1 ? null : path.subpath(1, path.getNameCount()); } return path == null ? "" : path.toString() + "/"; }
throw new RuntimeException(e); currentFileMatch.put("port", truncatePathToLastElements(firstLogAbsPath, 2).getName(0).toString()); newMatches.add(currentFileMatch);
private void parseV1Location(Path remoteFilePath) { parseV1Prefix(remoteFilePath); if (remoteFilePath.getNameCount() < 7) throw new IndexOutOfBoundsException( String.format( "Too few elements (expected: [%d]) in path: %s", 7, remoteFilePath)); time = DateUtil.getDate(remoteFilePath.getName(4).toString()); type = BackupFileType.valueOf(remoteFilePath.getName(5).toString()); if (BackupFileType.isDataFile(type)) { keyspace = remoteFilePath.getName(6).toString(); columnFamily = remoteFilePath.getName(7).toString(); } // append the rest fileName = remoteFilePath.getName(remoteFilePath.getNameCount() - 1).toString(); }
private static String getExplicitIndexDirectory( DatabaseLayout databaseLayout ) { File schemaIndexDirectory = LuceneDataSource.getLuceneIndexStoreDirectory( databaseLayout ); Path relativeIndexPath = databaseLayout.databaseDirectory().toPath().relativize( schemaIndexDirectory.toPath() ); return relativeIndexPath.getName( 0 ).toString(); }
@Override public FileVisitResult visitFile( Path path, BasicFileAttributes attrs ) { File file = path.toFile(); Path name = path.getName( path.getNameCount() - 3 ); boolean isLuceneFile = (path.getNameCount() >= 3 && name.toString().startsWith( "lucene-" )) || (path.getNameCount() >= 4 && path.getName( path.getNameCount() - 4 ).toString().equals( "lucene" )); if ( !FailureStorage.DEFAULT_FAILURE_FILE_NAME.equals( file.getName() ) ) { (isLuceneFile ? luceneTotal : pageCacheTotal).add( file.length() ); } return FileVisitResult.CONTINUE; } } );
assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> { if (path.getName(1).toString().equals(ModuleAssetDataProducer.OVERRIDE_FOLDER)) { return path.getName(3).toString().equals("textures"); } else { return path.getName(2).toString().equals("textures"); if (path.getName(1).toString().equals(ModuleAssetDataProducer.OVERRIDE_FOLDER)) { return path.getName(3).toString().equals("fonts"); } else { return path.getName(2).toString().equals("fonts");
@Override public Path remoteV2Prefix(Path location, BackupFileType fileType) { if (location.getNameCount() <= 1) { baseDir = config.getBackupLocation(); clusterName = config.getAppName(); } else if (location.getNameCount() >= 3) { baseDir = location.getName(1).toString(); clusterName = parseAndValidateAppNameWithHash(location.getName(2).toString()); } token = instanceIdentity.getInstance().getToken(); return Paths.get(getV2Prefix().toString(), fileType.toString()); }
@Override public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) { assetTypeManager.registerCoreAssetType(Font.class, (AssetFactory<Font, FontData>) FontImpl::new, "fonts"); assetTypeManager.registerCoreAssetType(Texture.class, (AssetFactory<Texture, TextureData>) HeadlessTexture::new, "textures", "fonts"); assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getName(2).toString().equals("textures"))); assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getName(2).toString().equals("fonts"))); assetTypeManager.registerCoreAssetType(Shader.class, (AssetFactory<Shader, ShaderData>) HeadlessShader::new, "shaders"); assetTypeManager.registerCoreAssetType(Material.class, (AssetFactory<Material, MaterialData>) HeadlessMaterial::new, "materials"); assetTypeManager.registerCoreAssetType(Mesh.class, (AssetFactory<Mesh, MeshData>) HeadlessMesh::new, "mesh"); assetTypeManager.registerCoreAssetType(SkeletalMesh.class, (AssetFactory<SkeletalMesh, SkeletalMeshData>) HeadlessSkeletalMesh::new, "skeletalMesh"); assetTypeManager.registerCoreAssetType(MeshAnimation.class, (AssetFactory<MeshAnimation, MeshAnimationData>) MeshAnimationImpl::new, "animations"); assetTypeManager.registerCoreAssetType(Atlas.class, (AssetFactory<Atlas, AtlasData>) Atlas::new, "atlas"); assetTypeManager.registerCoreAssetType(Subtexture.class, (AssetFactory<Subtexture, SubtextureData>) Subtexture::new); }
private void parseV2Location(String remoteFile) { Path remoteFilePath = Paths.get(remoteFile); parseV2Prefix(remoteFilePath); if (remoteFilePath.getNameCount() < 8) throw new IndexOutOfBoundsException( String.format( "Too few elements (expected: [%d]) in path: %s", 8, remoteFilePath)); int name_count_idx = 3; type = BackupFileType.valueOf(remoteFilePath.getName(name_count_idx++).toString()); setLastModified( Instant.ofEpochMilli( Long.parseLong(remoteFilePath.getName(name_count_idx++).toString()))); if (type == BackupFileType.SST_V2) { keyspace = remoteFilePath.getName(name_count_idx++).toString(); columnFamily = remoteFilePath.getName(name_count_idx++).toString(); } setCompression( ICompression.CompressionAlgorithm.valueOf( remoteFilePath.getName(name_count_idx++).toString())); setEncryption( IFileCryptography.CryptographyAlgorithm.valueOf( remoteFilePath.getName(name_count_idx++).toString())); fileName = remoteFilePath.getName(name_count_idx).toString(); }
HeadlessTexture::new, "textures", "fonts"); assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getName(2).toString().equals("textures"))); assetTypeManager.registerCoreFormat(Texture.class, new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getName(2).toString().equals("fonts")));
/** * Retrieves all the children of the given {@link ConfigKeyPath} using {@link Files#walk} to list files */ @Override public Collection<ConfigKeyPath> getChildren(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException { Preconditions.checkNotNull(configKey, "configKey cannot be null!"); Preconditions.checkArgument(version.equals(getCurrentVersion())); List<ConfigKeyPath> children = new ArrayList<>(); Path datasetDir = getDatasetDirForKey(configKey); try { if (!Files.exists(this.fs.getPath(datasetDir.toString()))) { return children; } Stream<Path> files = Files.walk(datasetDir, 1); for (Iterator<Path> it = files.iterator(); it.hasNext();) { Path path = it.next(); if (Files.isDirectory(path) && !path.equals(datasetDir)) { children.add(configKey.createChild(StringUtils.removeEnd(path.getName(path.getNameCount() - 1).toString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER))); } } return children; } catch (IOException e) { throw new RuntimeException(String.format("Error while getting children for configKey: \"%s\"", configKey), e); } }
Path deviceName = device.getName( device.getNameCount() - 1 );