List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:net.yacy.yacy.java
/** * Call the shutdown-page of YaCy to tell it to shut down. This method is * called if you start yacy with the argument -shutdown. * * @param homePath Root-path where all the information is to be found. *///from w w w. j av a 2 s . c o m public static void shutdown(final File homePath) { // start up System.out.println(copyright); System.out.println(hline); final LinkedHashMap<String, ContentBody> post = new LinkedHashMap<String, ContentBody>(); post.put("shutdown", UTF8.StringBody("")); submitPostURL(homePath, "Steering.html", "Terminate YaCy", post); }
From source file:aldenjava.opticalmapping.data.data.OptMapDataReader.java
private static LinkedHashMap<Integer, LinkedHashMap<String, DataNode>> getLabelMap(OptMapDataReader omdr) throws IOException { LinkedHashMap<Integer, LinkedHashMap<String, DataNode>> fragmentMapLabelMap = new LinkedHashMap<Integer, LinkedHashMap<String, DataNode>>(); DataNode fragment;/*from w ww . ja va 2 s. co m*/ while ((fragment = omdr.read()) != null) { LinkedHashMap<String, DataNode> fragmentMap; if ((fragmentMap = fragmentMapLabelMap.get(fragment.getTotalSegment())) == null) { fragmentMap = new LinkedHashMap<String, DataNode>(); fragmentMapLabelMap.put(fragment.getTotalSegment(), fragmentMap); } fragmentMap.put(fragment.name, fragment); } omdr.close(); return fragmentMapLabelMap; }
From source file:gov.llnl.lc.smt.command.route.SmtMulticast.java
public static LinkedHashMap<String, SBN_MulticastGroup> preenMCastGroups(OpenSmMonitorService oms) { // the arrays seem to hold redundant junk, not sure why, but try to save // only unique entries LinkedHashMap<String, SBN_MulticastGroup> mcGroups = new LinkedHashMap<String, SBN_MulticastGroup>(500 + 1, .75F, false);/*from w w w .jav a2s . c om*/ if ((oms != null) && (oms.getFabric() != null) && (oms.getFabric().getOsmSubnet() != null)) { SBN_MulticastGroup[] MCGroups = preenMcastGroups(oms.getFabric().getOsmSubnet().MCGroups); if ((MCGroups != null) && (MCGroups.length > 0)) for (SBN_MulticastGroup mg : MCGroups) { String key = Integer.toString(mg.mlid).trim(); mcGroups.put(key, mg); } } return mcGroups; }
From source file:com.px100systems.util.SpringELCtx.java
/** * Create a String to T map/*w w w .ja v a 2 s. com*/ * @param values map entries as a list e.g. {"key1", new Date(), "key2", date2, ...} etc. * @param <T> value class * @return the map */ @SuppressWarnings("unchecked") public static <T> LinkedHashMap<String, T> map(Object... values) { LinkedHashMap<String, T> result = new LinkedHashMap<String, T>(); for (int i = 0; i < values.length; i += 2) result.put(values[i].toString(), (i + 1) < values.length ? (T) values[i + 1] : null); return result; }
From source file:com.espertech.esper.core.start.EPStatementStartMethodHelperSubselect.java
protected static SubSelectStrategyCollection planSubSelect(EPServicesContext services, StatementContext statementContext, boolean queryPlanLogging, SubSelectActivationCollection subSelectStreamDesc, String[] outerStreamNames, EventType[] outerEventTypesSelect, String[] outerEventTypeNamees, List<StopCallback> stopCallbacks, Annotation[] annotations, ExprDeclaredNode[] declaredExpressions, ContextPropertyRegistry contextPropertyRegistry) throws ExprValidationException, ViewProcessingException { int subqueryNum = -1; SubSelectStrategyCollection collection = new SubSelectStrategyCollection(); IndexHint indexHint = IndexHint.getIndexHint(statementContext.getAnnotations()); for (Map.Entry<ExprSubselectNode, SubSelectActivationHolder> entry : subSelectStreamDesc.getSubqueries() .entrySet()) {/*from www .j a va2s . c o m*/ subqueryNum++; ExprSubselectNode subselect = entry.getKey(); SubSelectActivationHolder subSelectActivation = entry.getValue(); if (queryPlanLogging && queryPlanLog.isInfoEnabled()) { queryPlanLog.info( "For statement '" + statementContext.getStatementName() + "' subquery " + subqueryNum); } StatementSpecCompiled statementSpec = subselect.getStatementSpecCompiled(); StreamSpecCompiled filterStreamSpec = statementSpec.getStreamSpecs()[0]; String subselecteventTypeName = null; if (filterStreamSpec instanceof FilterStreamSpecCompiled) { subselecteventTypeName = ((FilterStreamSpecCompiled) filterStreamSpec).getFilterSpec() .getFilterForEventTypeName(); } else if (filterStreamSpec instanceof NamedWindowConsumerStreamSpec) { subselecteventTypeName = ((NamedWindowConsumerStreamSpec) filterStreamSpec).getWindowName(); } ViewFactoryChain viewFactoryChain = subSelectStreamDesc.getViewFactoryChain(subselect); EventType eventType = viewFactoryChain.getEventType(); // determine a stream name unless one was supplied String subexpressionStreamName = filterStreamSpec.getOptionalStreamName(); int subselectStreamNumber = subSelectStreamDesc.getStreamNumber(subselect); if (subexpressionStreamName == null) { subexpressionStreamName = "$subselect_" + subselectStreamNumber; } // Named windows don't allow data views if (filterStreamSpec instanceof NamedWindowConsumerStreamSpec) { EPStatementStartMethodHelperValidate .validateNoDataWindowOnNamedWindow(viewFactoryChain.getViewFactoryChain()); } // Expression declarations are copies of a predefined expression body with their own stream context. // Should only be invoked if the subselect belongs to that instance. if (declaredExpressions.length > 0) { // Find that subselect within that declaration ExprNodeSubselectDeclaredDotVisitor visitor = new ExprNodeSubselectDeclaredDotVisitor(); for (ExprDeclaredNode declaration : declaredExpressions) { visitor.reset(); declaration.accept(visitor); if (visitor.getSubselects().contains(subselect)) { declaration.setSubselectOuterStreamNames(outerStreamNames, outerEventTypesSelect, outerEventTypeNamees, services.getEngineURI(), subselect, subexpressionStreamName, eventType, subselecteventTypeName); } } } EventType[] outerEventTypes; StreamTypeService subselectTypeService; // Use the override provided by the subselect if applicable if (subselect.getFilterSubqueryStreamTypes() != null) { subselectTypeService = subselect.getFilterSubqueryStreamTypes(); outerEventTypes = new EventType[subselectTypeService.getEventTypes().length - 1]; System.arraycopy(subselectTypeService.getEventTypes(), 1, outerEventTypes, 0, subselectTypeService.getEventTypes().length - 1); } else { // Streams event types are the original stream types with the stream zero the subselect stream LinkedHashMap<String, Pair<EventType, String>> namesAndTypes = new LinkedHashMap<String, Pair<EventType, String>>(); namesAndTypes.put(subexpressionStreamName, new Pair<EventType, String>(eventType, subselecteventTypeName)); for (int i = 0; i < outerEventTypesSelect.length; i++) { Pair<EventType, String> pair = new Pair<EventType, String>(outerEventTypesSelect[i], outerEventTypeNamees[i]); namesAndTypes.put(outerStreamNames[i], pair); } subselectTypeService = new StreamTypeServiceImpl(namesAndTypes, services.getEngineURI(), true, true); outerEventTypes = outerEventTypesSelect; } ViewResourceDelegateUnverified viewResourceDelegateSubselect = new ViewResourceDelegateUnverified(); // Validate select expression SelectClauseSpecCompiled selectClauseSpec = subselect.getStatementSpecCompiled().getSelectClauseSpec(); AggregationServiceFactoryDesc aggregationServiceFactoryDesc = null; List<ExprNode> selectExpressions = new ArrayList<ExprNode>(); List<String> assignedNames = new ArrayList<String>(); boolean isWildcard = false; boolean isStreamWildcard = false; if (selectClauseSpec.getSelectExprList().length > 0) { List<ExprAggregateNode> aggExprNodes = new LinkedList<ExprAggregateNode>(); ExprEvaluatorContextStatement evaluatorContextStmt = new ExprEvaluatorContextStatement( statementContext); ExprValidationContext validationContext = new ExprValidationContext(subselectTypeService, statementContext.getMethodResolutionService(), viewResourceDelegateSubselect, statementContext.getSchedulingService(), statementContext.getVariableService(), evaluatorContextStmt, statementContext.getEventAdapterService(), statementContext.getStatementName(), statementContext.getStatementId(), statementContext.getAnnotations(), statementContext.getContextDescriptor()); for (int i = 0; i < selectClauseSpec.getSelectExprList().length; i++) { SelectClauseElementCompiled element = selectClauseSpec.getSelectExprList()[i]; if (element instanceof SelectClauseExprCompiledSpec) { // validate SelectClauseExprCompiledSpec compiled = (SelectClauseExprCompiledSpec) element; ExprNode selectExpression = compiled.getSelectExpression(); selectExpression = ExprNodeUtility.getValidatedSubtree(selectExpression, validationContext); selectExpressions.add(selectExpression); assignedNames.add(compiled.getAssignedName()); // handle aggregation ExprAggregateNodeUtil.getAggregatesBottomUp(selectExpression, aggExprNodes); if (aggExprNodes.size() > 0) { // This stream (stream 0) properties must either all be under aggregation, or all not be. List<Pair<Integer, String>> propertiesNotAggregated = ExprNodeUtility .getExpressionProperties(selectExpression, false); for (Pair<Integer, String> pair : propertiesNotAggregated) { if (pair.getFirst() == 0) { throw new ExprValidationException( "Subselect properties must all be within aggregation functions"); } } } } else if (element instanceof SelectClauseElementWildcard) { isWildcard = true; } else if (element instanceof SelectClauseStreamCompiledSpec) { isStreamWildcard = true; } } // end of for loop if (!selectExpressions.isEmpty()) { subselect.setSelectClause(selectExpressions.toArray(new ExprNode[selectExpressions.size()])); subselect.setSelectAsNames(assignedNames.toArray(new String[assignedNames.size()])); if (isWildcard || isStreamWildcard) { throw new ExprValidationException( "Subquery multi-column select does not allow wildcard or stream wildcard when selecting multiple columns."); } if (selectExpressions.size() > 1 && !subselect.isAllowMultiColumnSelect()) { throw new ExprValidationException( "Subquery multi-column select is not allowed in this context."); } if ((selectExpressions.size() > 1 && aggExprNodes.size() > 0)) { // all properties must be aggregated if (!ExprNodeUtility.getNonAggregatedProps(subselectTypeService.getEventTypes(), selectExpressions, contextPropertyRegistry).isEmpty()) { throw new ExprValidationException( "Subquery with multi-column select requires that either all or none of the selected columns are under aggregation."); } } } if (aggExprNodes.size() > 0) { List<ExprAggregateNode> havingAgg = Collections.emptyList(); List<ExprAggregateNode> orderByAgg = Collections.emptyList(); aggregationServiceFactoryDesc = AggregationServiceFactoryFactory.getService(aggExprNodes, havingAgg, orderByAgg, false, evaluatorContextStmt, annotations, statementContext.getVariableService(), false, statementSpec.getFilterRootNode(), statementSpec.getHavingExprRootNode(), statementContext.getAggregationServiceFactoryService(), subselectTypeService.getEventTypes()); // Other stream properties, if there is aggregation, cannot be under aggregation. for (ExprAggregateNode aggNode : aggExprNodes) { List<Pair<Integer, String>> propertiesNodesAggregated = ExprNodeUtility .getExpressionProperties(aggNode, true); for (Pair<Integer, String> pair : propertiesNodesAggregated) { if (pair.getFirst() != 0) { throw new ExprValidationException( "Subselect aggregation functions cannot aggregate across correlated properties"); } } } } } // no aggregation functions allowed in filter if (statementSpec.getFilterRootNode() != null) { List<ExprAggregateNode> aggExprNodesFilter = new LinkedList<ExprAggregateNode>(); ExprAggregateNodeUtil.getAggregatesBottomUp(statementSpec.getFilterRootNode(), aggExprNodesFilter); if (aggExprNodesFilter.size() > 0) { throw new ExprValidationException( "Aggregation functions are not supported within subquery filters, consider using insert-into instead"); } } // Validate filter expression, if there is one ExprNode filterExpr = statementSpec.getFilterRootNode(); boolean correlatedSubquery = false; if (filterExpr != null) { ExprEvaluatorContextStatement evaluatorContextStmt = new ExprEvaluatorContextStatement( statementContext); ExprValidationContext validationContext = new ExprValidationContext(subselectTypeService, statementContext.getMethodResolutionService(), viewResourceDelegateSubselect, statementContext.getSchedulingService(), statementContext.getVariableService(), evaluatorContextStmt, statementContext.getEventAdapterService(), statementContext.getStatementName(), statementContext.getStatementId(), statementContext.getAnnotations(), statementContext.getContextDescriptor()); filterExpr = ExprNodeUtility.getValidatedSubtree(filterExpr, validationContext); if (JavaClassHelper.getBoxedType(filterExpr.getExprEvaluator().getType()) != Boolean.class) { throw new ExprValidationException("Subselect filter expression must return a boolean value"); } // check the presence of a correlated filter, not allowed with aggregation ExprNodeIdentifierVisitor visitor = new ExprNodeIdentifierVisitor(true); filterExpr.accept(visitor); List<Pair<Integer, String>> propertiesNodes = visitor.getExprProperties(); for (Pair<Integer, String> pair : propertiesNodes) { if (pair.getFirst() != 0) { correlatedSubquery = true; break; } } } ViewResourceDelegateVerified viewResourceDelegateVerified = EPStatementStartMethodHelperViewResources .verifyPreviousAndPriorRequirements(new ViewFactoryChain[] { viewFactoryChain }, viewResourceDelegateSubselect); List<ExprPriorNode> priorNodes = viewResourceDelegateVerified.getPerStream()[0] .getPriorRequestsAsList(); List<ExprPreviousNode> previousNodes = viewResourceDelegateVerified.getPerStream()[0] .getPreviousRequests(); // Set the aggregated flag // This must occur here as some analysis of return type depends on aggregated or not. subselect.setAggregatedSubquery(aggregationServiceFactoryDesc != null); // Set the filter. ExprEvaluator filterExprEval = (filterExpr == null) ? null : filterExpr.getExprEvaluator(); ExprEvaluator assignedFilterExpr = aggregationServiceFactoryDesc != null ? null : filterExprEval; subselect.setFilterExpr(assignedFilterExpr); // validation for correlated subqueries against named windows contained-event syntax if ((filterStreamSpec instanceof NamedWindowConsumerStreamSpec && correlatedSubquery)) { NamedWindowConsumerStreamSpec namedSpec = (NamedWindowConsumerStreamSpec) filterStreamSpec; if (namedSpec.getOptPropertyEvaluator() != null) { throw new ExprValidationException( "Failed to validate named window use in subquery, contained-event is only allowed for named windows when not correlated"); } } // Determine strategy factories // // handle named window index share first boolean disableIndexShare = HintEnum.DISABLE_WINDOW_SUBQUERY_INDEXSHARE.getHint(annotations) != null; if ((filterStreamSpec instanceof NamedWindowConsumerStreamSpec) && (!disableIndexShare)) { NamedWindowConsumerStreamSpec namedSpec = (NamedWindowConsumerStreamSpec) filterStreamSpec; if (namedSpec.getFilterExpressions().isEmpty()) { NamedWindowProcessor processor = services.getNamedWindowService() .getProcessor(namedSpec.getWindowName()); if (processor == null) { throw new ExprValidationException( "A named window by name '" + namedSpec.getWindowName() + "' does not exist"); } if (processor.isEnableSubqueryIndexShare()) { if (queryPlanLogging && queryPlanLog.isInfoEnabled()) { queryPlanLog.info("prefering shared index"); } boolean fullTableScan = HintEnum.SET_NOINDEX.getHint(annotations) != null; SubordPropPlan joinedPropPlan = QueryPlanIndexBuilder.getJoinProps(filterExpr, outerEventTypes.length, subselectTypeService.getEventTypes()); NamedWindowProcessorInstance processorInstanceSubq = processor.getProcessorInstance(null); SubordTableLookupStrategy namedWindowSubqueryLookup = processorInstanceSubq .getRootViewInstance().getAddSubqueryLookupStrategy( statementContext.getStatementName(), statementContext.getStatementId(), statementContext.getAnnotations(), outerEventTypesSelect, joinedPropPlan, fullTableScan, subqueryNum, indexHint); stopCallbacks.add(new NamedWindowSubqueryStopCallback(processorInstanceSubq, namedWindowSubqueryLookup)); SubSelectStrategyFactory factory = new SubSelectStrategyFactoryNamedWinIndexShare( namedWindowSubqueryLookup, filterExprEval, aggregationServiceFactoryDesc); SubSelectStrategyFactoryDesc factoryDesc = new SubSelectStrategyFactoryDesc( subSelectActivation, factory, aggregationServiceFactoryDesc, priorNodes, previousNodes); collection.add(subselect, factoryDesc); continue; } } } // determine unique keys, if any Set<String> optionalUniqueProps = null; if (viewFactoryChain.getDataWindowViewFactoryCount() > 0) { optionalUniqueProps = ViewServiceHelper .getUniqueCandidateProperties(viewFactoryChain.getViewFactoryChain(), annotations); } if (filterStreamSpec instanceof NamedWindowConsumerStreamSpec) { NamedWindowConsumerStreamSpec namedSpec = (NamedWindowConsumerStreamSpec) filterStreamSpec; NamedWindowProcessor processor = services.getNamedWindowService() .getProcessor(namedSpec.getWindowName()); optionalUniqueProps = processor.getOptionalUniqueKeyProps(); } // handle local stream + named-window-stream boolean fullTableScan = HintEnum.SET_NOINDEX.getHint(annotations) != null; Pair<EventTableFactory, SubordTableLookupStrategyFactory> indexPair = determineSubqueryIndexFactory( filterExpr, eventType, outerEventTypes, subselectTypeService, fullTableScan, queryPlanLogging, optionalUniqueProps, annotations, subqueryNum); SubSelectStrategyFactory factory = new SubSelectStrategyFactoryLocalViewPreloaded(subqueryNum, subSelectActivation, indexPair, filterExprEval, correlatedSubquery, aggregationServiceFactoryDesc, viewResourceDelegateVerified); SubSelectStrategyFactoryDesc factoryDesc = new SubSelectStrategyFactoryDesc(subSelectActivation, factory, aggregationServiceFactoryDesc, priorNodes, previousNodes); collection.add(subselect, factoryDesc); } return collection; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.java
public static LinkedHashMap<String, String> getModelParams(VitroRequest vreq) { LinkedHashMap<String, String> specialParams = new LinkedHashMap<String, String>(); if (vreq != null) { //this parameter is sufficient to switch to menu model String useMenuModelParam = vreq.getParameter(DisplayVocabulary.SWITCH_TO_DISPLAY_MODEL); //the parameters below allow for using a different model String useMainModelUri = vreq.getParameter(DisplayVocabulary.USE_MODEL_PARAM); String useTboxModelUri = vreq.getParameter(DisplayVocabulary.USE_TBOX_MODEL_PARAM); String useDisplayModelUri = vreq.getParameter(DisplayVocabulary.USE_DISPLAY_MODEL_PARAM); if (useMenuModelParam != null && !useMenuModelParam.isEmpty()) { specialParams.put(DisplayVocabulary.SWITCH_TO_DISPLAY_MODEL, useMenuModelParam); } else if (useMainModelUri != null && !useMainModelUri.isEmpty()) { specialParams.put(DisplayVocabulary.USE_MODEL_PARAM, useMainModelUri); if (useTboxModelUri != null && !useTboxModelUri.isEmpty()) { specialParams.put(DisplayVocabulary.USE_TBOX_MODEL_PARAM, useTboxModelUri); }/*from w w w. java 2 s . com*/ if (useDisplayModelUri != null && !useDisplayModelUri.isEmpty()) { specialParams.put(DisplayVocabulary.USE_DISPLAY_MODEL_PARAM, useDisplayModelUri); } } } return specialParams; }
From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java
private static void initSampleGroups(LinkedHashSet<String> sampleGroups, Map<File, String> fileToSampleGroup, LinkedHashMap<String, Set<File>> groupToFile) { sampleGroups.addAll(fileToSampleGroup.values()); for (String sampleGroup : sampleGroups) { for (File key : fileToSampleGroup.keySet()) { if (fileToSampleGroup.get(key).equals(sampleGroup)) { if (groupToFile.containsKey(sampleGroup)) { Set<File> s = groupToFile.get(sampleGroup); s.add(key);// ww w .j a v a 2s. co m } else { Set<File> s = new LinkedHashSet<>(); s.add(key); groupToFile.put(sampleGroup, s); } } } } }
From source file:org.kitodo.data.index.elasticsearch.type.DocketType.java
@SuppressWarnings("unchecked") @Override/* w ww. j a v a2 s .c o m*/ public HttpEntity createDocument(Docket docket) { LinkedHashMap<String, String> orderedDocketMap = new LinkedHashMap<>(); orderedDocketMap.put("name", docket.getName()); orderedDocketMap.put("file", docket.getFile()); JSONObject docketObject = new JSONObject(orderedDocketMap); return new NStringEntity(docketObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:org.kitodo.data.index.elasticsearch.type.RulesetType.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a v a 2 s . c o m*/ public HttpEntity createDocument(Ruleset ruleset) { LinkedHashMap<String, String> orderedRulesetMap = new LinkedHashMap<>(); orderedRulesetMap.put("title", ruleset.getTitle()); orderedRulesetMap.put("file", ruleset.getFile()); orderedRulesetMap.put("fileContent", ""); JSONObject rulesetObject = new JSONObject(orderedRulesetMap); return new NStringEntity(rulesetObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.java
/** * /*w w w .j a va 2 s .c o m*/ * @param dim -- Dimension * @return Dimension */ public static Dimension convertDim2Dim(Dimension dim) { StandardDimension rs = new StandardDimension(dim.getName()); rs.setCaption(dim.getCaption()); rs.setDescription(dim.getDescription()); rs.setTableName(dim.getTableName()); rs.setFacttableCaption(dim.getFacttableCaption()); rs.setFacttableColumn(dim.getFacttableColumn()); rs.setPrimaryKey(dim.getPrimaryKey()); rs.setType(dim.getType()); rs.setVisible(true); rs.setId(dim.getId()); rs.setName(dim.getName()); LinkedHashMap<String, Level> levels = Maps.newLinkedHashMap(); dim.getLevels().values().forEach(level -> { level.setDimension(dim); levels.put(level.getName(), level); }); rs.setLevels(levels); return rs; }