List of usage examples for java.util LinkedHashMap remove
V remove(Object key);
From source file:com.qwazr.search.index.IndexInstance.java
void deleteField(String field_name) throws IOException, ServerException { LinkedHashMap<String, FieldDefinition> fields = (LinkedHashMap<String, FieldDefinition>) fieldMap.clone(); if (fields.remove(field_name) == null) throw new ServerException(Response.Status.NOT_FOUND, "Field not found: " + field_name); setFields(fields);/*from w w w.ja v a 2 s .c om*/ }
From source file:org.talend.dataprep.api.dataset.row.DataSetRow.java
public DataSetRow filter(List<ColumnMetadata> filteredColumns) { final Set<String> columnsToKeep = filteredColumns.stream().map(ColumnMetadata::getId) .collect(Collectors.toSet()); final Set<String> columnsToDelete = values.entrySet().stream() .filter(e -> !columnsToKeep.contains(e.getKey())) // .map(Map.Entry::getKey).collect(Collectors.toSet()); final RowMetadata rowMetadataClone = rowMetadata.clone(); final LinkedHashMap<String, String> filteredValues = new LinkedHashMap<>(this.values); for (String columnId : columnsToDelete) { filteredValues.remove(columnId); rowMetadataClone.deleteColumnById(columnId); }/*from ww w. j a v a 2 s. com*/ final DataSetRow filteredDataSetRow = new DataSetRow(rowMetadataClone, filteredValues); filteredDataSetRow.invalidColumnIds.addAll(invalidColumnIds); return filteredDataSetRow; }
From source file:org.apache.kylin.common.persistence.JDBCConnectionManager.java
private Map<String, String> initDbcpProps(KylinConfig config) { // metadataUrl is like "kylin_default_instance@jdbc,url=jdbc:mysql://localhost:3306/kylin,username=root,password=xxx" StorageURL metadataUrl = config.getMetadataUrl(); JDBCResourceStore.checkScheme(metadataUrl); LinkedHashMap<String, String> ret = new LinkedHashMap<>(metadataUrl.getAllParameters()); List<String> mandatoryItems = Arrays.asList("url", "username", "password"); for (String item : mandatoryItems) { Preconditions.checkNotNull(ret.get(item), "Setting item \"" + item + "\" is mandatory for Jdbc connections."); }// w w w . j a va2 s . c om // Check whether password encrypted if ("true".equals(ret.get("passwordEncrypted"))) { String password = ret.get("password"); ret.put("password", EncryptUtil.decrypt(password)); ret.remove("passwordEncrypted"); } logger.info("Connecting to Jdbc with url:{0} by user {1}", ret.get("url"), ret.get("username")); putIfMissing(ret, "driverClassName", "com.mysql.jdbc.Driver"); putIfMissing(ret, "maxActive", "5"); putIfMissing(ret, "maxIdle", "5"); putIfMissing(ret, "maxWait", "1000"); putIfMissing(ret, "removeAbandoned", "true"); putIfMissing(ret, "removeAbandonedTimeout", "180"); putIfMissing(ret, "testOnBorrow", "true"); putIfMissing(ret, "testWhileIdle", "true"); putIfMissing(ret, "validationQuery", "select 1"); return ret; }
From source file:com.qwazr.search.index.IndexInstance.java
void deleteAnalyzer(String analyzerName) throws IOException, ServerException { LinkedHashMap<String, AnalyzerDefinition> analyzers = (LinkedHashMap<String, AnalyzerDefinition>) analyzerMap .clone();/*from w w w . j av a 2 s . c om*/ if (analyzers.remove(analyzerName) == null) throw new ServerException(Response.Status.NOT_FOUND, "Analyzer not found: " + analyzerName); setAnalyzers(analyzers); }
From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java
private void remapOrder(LinkedHashMap<String, SortOrder> order, Map<String, String> orderMap) { ArrayList<String> list = new ArrayList<String>(order.keySet()); for (String key : list) { SortOrder value = order.remove(key); String newKey = orderMap.get(key); if (newKey != null) { order.put(newKey, value);//from w w w. j av a 2 s . co m } else { order.put(key, value); } } }
From source file:com.streamsets.pipeline.stage.lib.hive.HiveQueryExecutor.java
/** * Returns {@link Pair} of Column Type Info and Partition Type Info. * @param qualifiedTableName qualified table name. * @return {@link Pair} of Column Type Info and Partition Type Info. * @throws StageException in case of any {@link SQLException} *///from ww w.j a v a 2 s .c om public Pair<LinkedHashMap<String, HiveType>, LinkedHashMap<String, HiveType>> executeDescTableQuery( String qualifiedTableName) throws StageException { String sql = buildDescTableQuery(qualifiedTableName); LOG.debug("Executing SQL:", sql); Statement statement = null; try (Connection con = DriverManager.getConnection(jdbcUrl)) { statement = con.createStatement(); ResultSet rs = statement.executeQuery(sql); LinkedHashMap<String, HiveType> columnTypeInfo = extractTypeInfo(rs); processDelimiter(rs, "#"); processDelimiter(rs, "#"); processDelimiter(rs, ""); LinkedHashMap<String, HiveType> partitionTypeInfo = extractTypeInfo(rs); //Remove partition columns from the columns map. for (String partitionCol : partitionTypeInfo.keySet()) { columnTypeInfo.remove(partitionCol); } return Pair.of(columnTypeInfo, partitionTypeInfo); } catch (SQLException e) { LOG.error("SQL Exception happened when adding partition", e); throw new StageException(Errors.HIVE_20, sql, e.getMessage()); } finally { closeStatement(statement); } }
From source file:com.opengamma.component.ComponentManager.java
/** * Sets the properties on the factory.// w ww .j av a 2s .com * * @param factory the factory, not null * @param remainingConfig the config data, not null * @throws Exception allowing throwing of a checked exception */ protected void setFactoryProperties(ComponentFactory factory, LinkedHashMap<String, String> remainingConfig) throws Exception { if (factory instanceof Bean) { Bean bean = (Bean) factory; for (MetaProperty<?> mp : bean.metaBean().metaPropertyIterable()) { String value = remainingConfig.remove(mp.name()); setProperty(bean, mp, value); } } }
From source file:net.sf.jasperreports.engine.fill.DelayedFillActions.java
public void moveActions(FillPageKey fromKey, FillPageKey toKey) { if (log.isDebugEnabled()) { log.debug(id + " moving actions from " + fromKey + " to " + toKey); }//from www .j a va2s . c o m for (LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> map : actionsMap.values()) { fillContext.lockVirtualizationContext(); try { synchronized (map) { LinkedMap<Object, EvaluationBoundAction> subreportMap = map.remove(fromKey); if (subreportMap != null && !subreportMap.isEmpty()) { LinkedMap<Object, EvaluationBoundAction> masterMap = pageActionsMap(map, toKey); masterMap.addAll(subreportMap); } } } finally { fillContext.unlockVirtualizationContext(); } } }
From source file:net.sf.jasperreports.engine.fill.DelayedFillActions.java
protected void moveMasterEvaluations(DelayedFillActions sourceActions, FillPageKey sourcePageKey, FillPageKey destinationPageKey) { if (log.isDebugEnabled()) { log.debug(id + " moving master actions from " + sourceActions.id + ", source " + sourcePageKey + ", destination " + destinationPageKey); }// w ww .j a v a 2 s . c o m fillContext.lockVirtualizationContext(); try { LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> actions = sourceActions.actionsMap .get(JREvaluationTime.EVALUATION_TIME_MASTER); synchronized (actions) { LinkedMap<Object, EvaluationBoundAction> pageActions = actions.remove(sourcePageKey);//FIXMEBOOK deregister virt listener if (pageActions == null || pageActions.isEmpty()) { return; } moveMasterActions(pageActions, destinationPageKey); // copy fill elements Ids for all master actions for (Integer elementId : sourceActions.masterFillElementIds) { if (!fillElements.containsKey(elementId)) { fillElements.put(elementId, sourceActions.fillElements.get(elementId)); masterFillElementIds.add(elementId); } } } } finally { fillContext.unlockVirtualizationContext(); } }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
/** * Test method for 'java.util.LinkedHashMap.remove(Object)'. *///from www. ja va2s .c o m public void testRemove() { LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>(); checkEmptyLinkedHashMapAssumptions(hashMap); assertNull(hashMap.remove(null)); hashMap.put(null, VALUE_TEST_REMOVE); assertNotNull(hashMap.remove(null)); hashMap.put(KEY_TEST_REMOVE, VALUE_TEST_REMOVE); assertEquals(hashMap.remove(KEY_TEST_REMOVE), VALUE_TEST_REMOVE); assertNull(hashMap.remove(KEY_TEST_REMOVE)); }