List of usage examples for java.util Map forEach
default void forEach(BiConsumer<? super K, ? super V> action)
From source file:io.pravega.segmentstore.storage.impl.extendeds3.S3FileSystemImpl.java
@Synchronized @Override/*from ww w . j av a 2 s . c o m*/ public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest request) { Map<Integer, CopyPartRequest> partMap = multipartUploads.get(request.getKey()); if (partMap == null) { throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", ""); } try { partMap.forEach((index, copyPart) -> { if (copyPart.getKey() != copyPart.getSourceKey()) { Path sourcePath = Paths.get(this.baseDir, copyPart.getBucketName(), copyPart.getSourceKey()); Path targetPath = Paths.get(this.baseDir, copyPart.getBucketName(), copyPart.getKey()); try (FileChannel sourceChannel = FileChannel.open(sourcePath, StandardOpenOption.READ); FileChannel targetChannel = FileChannel.open(targetPath, StandardOpenOption.WRITE)) { targetChannel.transferFrom(sourceChannel, Files.size(targetPath), copyPart.getSourceRange().getLast() + 1 - copyPart.getSourceRange().getFirst()); targetChannel.close(); AclSize aclMap = this.aclMap.get(copyPart.getKey()); this.aclMap.put(copyPart.getKey(), aclMap.withSize(Files.size(targetPath))); } catch (IOException e) { throw new S3Exception("NoSuchKey", 404, "NoSuchKey", ""); } } }); } finally { multipartUploads.remove(request.getKey()); } return new CompleteMultipartUploadResult(); }
From source file:org.opencb.opencga.storage.hadoop.variant.converters.annotation.VariantAnnotationToHBaseConverter.java
Put buildPut(VariantAnnotation variantAnnotation, Map<PhoenixHelper.Column, ?> map) { byte[] bytesRowKey = genomeHelper.generateVariantRowKey(variantAnnotation.getChromosome(), variantAnnotation.getStart(), variantAnnotation.getReference(), variantAnnotation.getAlternate()); Put put = new Put(bytesRowKey); map.forEach((column, value) -> add(put, column, value)); return put;/*ww w . ja va 2 s . c o m*/ }
From source file:org.janusgraph.graphdb.management.ConfigurationManagementGraph.java
private void updateVertexWithProperties(String propertyKey, Object propertyValue, Map<Object, Object> map) { if (graph.traversal().V().has(propertyKey, propertyValue).hasNext()) { final Vertex v = graph.traversal().V().has(propertyKey, propertyValue).next(); map.forEach((key, value) -> v.property((String) key, value)); graph.tx().commit();/*w ww . j a va 2 s .c o m*/ } }
From source file:org.talend.dataprep.dataset.StatisticsAdapter.java
private void injectPatternFrequency(final ColumnMetadata column, final Analyzers.Result result) { if (result.exist(PatternFrequencyStatistics.class)) { final Statistics statistics = column.getStatistics(); final PatternFrequencyStatistics patternFrequencyStatistics = result .get(PatternFrequencyStatistics.class); final Map<String, Long> topTerms = patternFrequencyStatistics.getTopK(15); if (topTerms != null) { statistics.getPatternFrequencies().clear(); topTerms.forEach((s, o) -> statistics.getPatternFrequencies().add(new PatternFrequency(s, o))); }// w w w .j a v a 2s . c o m } }
From source file:org.apache.samza.webapp.TestApplicationMasterRestClient.java
private Map<String, Map<String, Object>> buildExpectedContainerResponse( Map<String, YarnContainer> runningYarnContainers, SamzaApplicationState samzaAppState) throws IOException { Map<String, Map<String, Object>> containers = new HashMap<>(); runningYarnContainers.forEach((containerId, container) -> { String yarnContainerId = container.id().toString(); Map<String, Object> containerMap = new HashMap(); Map<TaskName, TaskModel> taskModels = samzaAppState.jobModelManager.jobModel().getContainers() .get(containerId).getTasks(); containerMap.put("yarn-address", container.nodeHttpAddress()); containerMap.put("start-time", String.valueOf(container.startTime())); containerMap.put("up-time", String.valueOf(container.upTime())); containerMap.put("task-models", taskModels); containerMap.put("container-id", containerId); containers.put(yarnContainerId, containerMap); });/*from w w w .j a v a2 s.co m*/ return jsonMapper.readValue(jsonMapper.writeValueAsString(containers), new TypeReference<Map<String, Map<String, Object>>>() { }); }
From source file:ijfx.explorer.core.DefaultFolderManagerService.java
private synchronized void load() { Map<String, String> folderMap = jsonPrefService.loadMapFromJson(FOLDER_PREFERENCE_FILE, String.class, String.class); folderMap.forEach((name, folderPath) -> { File file = new File(folderPath); if (file.exists() == false) { return; }/*from ww w . jav a 2 s .c o m*/ Folder folder; if (file.isDirectory()) { folder = new DefaultFolder(context, file); folderList.add(folder); } else if (file.getName().endsWith(ExplorableIOService.DB_EXTENSION)) { folder = new DatabaseFolder(context, file); folderList.add(folder); } else { return; } }); }
From source file:com.qwazr.search.annotations.AnnotatedIndexService.java
private T toRecord(Map<String, Object> fields) throws ReflectiveOperationException { if (fields == null) return null; final T record = indexDefinitionClass.newInstance(); fields.forEach(new BiConsumer<String, Object>() { @Override//w ww .j av a 2 s . com public void accept(String fieldName, Object fieldValue) { Field field = fieldMap.get(fieldName); if (field == null) return; try { field.set(record, fieldValue); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }); return record; }
From source file:org.springframework.boot.context.logging.LoggingApplicationListener.java
protected void setLogLevels(LoggingSystem system, Environment environment) { if (!(environment instanceof ConfigurableEnvironment)) { return;// w w w . j a v a 2 s.c om } Binder binder = Binder.get(environment); Map<String, String[]> groups = getGroups(); binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups)); Map<String, String> levels = binder.bind("logging.level", STRING_STRING_MAP) .orElseGet(Collections::emptyMap); levels.forEach((name, level) -> { String[] groupedNames = groups.get(name); if (ObjectUtils.isEmpty(groupedNames)) { setLogLevel(system, name, level); } else { setLogLevel(system, groupedNames, level); } }); }
From source file:org.ballerinalang.composer.service.workspace.swagger.SwaggerConverterUtils.java
/** * @param pathMap// ww w .ja v a2 s. c o m * @return */ public static Resource[] mapPathsToResources(Map<String, Path> pathMap) { //TODO this logic need to be reviewed and fix issues. This is temporary commit to test swagger UI flow List<Resource> resourceList = new ArrayList<Resource>(); for (Map.Entry<String, Path> entry : pathMap.entrySet()) { Path path = entry.getValue(); Resource.ResourceBuilder resourceBuilder = new Resource.ResourceBuilder( new BLangPackage(GlobalScope.getInstance())); for (Map.Entry<HttpMethod, Operation> operationEntry : path.getOperationMap().entrySet()) { resourceBuilder.addAnnotation( new Annotation(null, new SymbolName(operationEntry.getKey().toString()), null, null)); resourceBuilder.setSymbolName(new SymbolName(operationEntry.getKey().name())); } Resource resource = resourceBuilder.buildResource(); resourceList.add(resource); } pathMap.forEach((pathString, pathObject) -> { }); return resourceList.toArray(new Resource[resourceList.size()]); }
From source file:org.nanoframework.orm.jdbc.record.AbstractJdbcRecord.java
protected T toBean(Map<String, Object> beanMap) { if (CollectionUtils.isEmpty(beanMap)) { return null; }/* w ww.j a va 2s. com*/ try { final T bean = this.entity.newInstance(); beanMap.forEach((key, value) -> { final Field field = columnMapper.get(key); if (field != null) { final String fieldName = field.getName(); bean.setAttributeValue(fieldName, value); } }); return bean; } catch (final InstantiationException | IllegalAccessException e) { throw new EntityException(e.getMessage(), e); } }