@Override public void selectMembers(ObjectPredicate predicate, ObjectOperation operation) { for (Pair<String, Expression> entry : cases) { select(entry.getSecond(), predicate, operation); } }
/** For testing only */ public Set<String> getInjectedComponentIds() { Set<String> injectedIds = new HashSet<>(); for (Pair<String, Component> injected : injectedComponents) { injectedIds.add(injected.getSecond().getSubId()); } return injectedIds; }
/** * Creates an instance of the class mapped to by the given identifier. This method proxies {@link * #createFromClass(Constructor)}. * * @param id The id of the class to create. * @return The instantiated object. */ private Identifiable createFromId(int id) { Pair<Class<? extends Identifiable>, Constructor<? extends Identifiable>> pair = typeMap.get(id); return createFromClass((pair != null) ? pair.getSecond() : null); }
@Override public String toString() { StringBuilder ret = new StringBuilder(); ret.append("select_input { "); for (Pair<String, Expression> entry : cases) { ret.append(entry.getFirst()).append(": "); Expression exp = entry.getSecond(); ret.append(exp).append("; "); } ret.append("}"); return ret.toString(); }
private Compressor.Compression compress(List<Pair<String, String>> properties) { StringBuilder b = new StringBuilder(); for (Pair<String, String> property : properties) b.append(property.getFirst()).append(keyEndMarker).append(property.getSecond()).append(valueEndMarker); return compressor.compress(b.toString().getBytes(Charset.forName("utf8"))); }
public Map<String, String> getDocMap(String docType) { Map<String, String> cached = docMapCache.get(docType); if (cached!=null) { return cached; } Map<String, String> ret = new HashMap<>(); for (Entry<Pair<String, String>, String> e : fieldMap.entrySet()) { // Remember to include tuple if doctype is unset in mapping if (docType.equals(e.getKey().getFirst()) || e.getKey().getFirst()==null || "".equals(e.getKey().getFirst())) { ret.put(e.getKey().getSecond(), e.getValue()); } } docMapCache.put(docType, ret); return ret; }
private static String parseNodeNum(String nodes, List<NodeSelection> into) { Pair<String, String> numAndRest = halveAt(',', nodes); int nodeNum = Integer.parseInt(numAndRest.getFirst()); into.add(new NodeSelection(nodeNum, nodeNum + 1)); return numAndRest.getSecond(); }
public void commit() { for (Pair<Path, PathChildrenCacheEvent> event : events) listeners.notify(event.getFirst(), event.getSecond()); }
private Object handleParameter(Node node, Injector fallbackInjector, Pair<Type, List<Annotation>> annotatedParameterType) { Type parameterType = annotatedParameterType.getFirst(); List<Annotation> annotations = annotatedParameterType.getSecond(); if (parameterType instanceof Class && parameterType.equals(ComponentId.class)) { return node.componentId(); } else if (parameterType instanceof Class && ConfigInstance.class.isAssignableFrom((Class<?>) parameterType)) { return handleConfigParameter((ComponentNode) node, (Class<?>) parameterType); } else if (parameterType instanceof ParameterizedType && ((ParameterizedType) parameterType).getRawType().equals(ComponentRegistry.class)) { ParameterizedType registry = (ParameterizedType) parameterType; return getComponentRegistry(registry.getActualTypeArguments()[0]); } else if (parameterType instanceof Class) { return handleComponentParameter(node, fallbackInjector, (Class<?>) parameterType, annotations); } else if (parameterType instanceof ParameterizedType) { throw new RuntimeException("Injection of parameterized type " + parameterType + " is not supported."); } else { throw new RuntimeException("Injection of type " + parameterType + " is not supported"); } }
public boolean isComplete(StringBuilder firstMissingName, Map<String,String> context) { // Are all types reachable from this complete? if ( ! reachableTypesAreComplete(CompoundName.empty, profile, firstMissingName, context)) return false; // Are all runtime references in this complete? if (references == null) return true; for (Pair<CompoundName, CompiledQueryProfile> reference : references) { if ( ! reachableTypesAreComplete(reference.getFirst(), reference.getSecond(), firstMissingName, context)) return false; } return true; }
public Expression innerConvert(SelectInputExpression exp) { List<Pair<String, Expression>> cases = new LinkedList<>(); for (Pair<String, Expression> pair : exp.getCases()) { cases.add(new Pair<>(pair.getFirst(), branch().convert(pair.getSecond()))); } return new SelectInputExpression(cases); }
private static List<Components.Inject.Builder> componentsToInject( Collection<Pair<String, Component>> injectedComponents) { List<Components.Inject.Builder> result = new ArrayList<>(); for (Pair<String, Component> injected : injectedComponents) { Components.Inject.Builder builder = new Components.Inject.Builder(); builder.id(injected.getSecond().getGlobalComponentId().stringValue()); builder.name(injected.getFirst()); result.add(builder); } return result; } }
private static SearchPath parseElement(String element) { Pair<String, String> nodesAndGroup = halveAt('/', element); List<NodeSelection> nodes = parseNodes(nodesAndGroup.getFirst()); Integer group = parseGroup(nodesAndGroup.getSecond()); return new SearchPath(nodes, group); }
private boolean execValidate(String configId, SearchCluster sc, String sdName, DeployLogger deployLogger) { String job = "vespa-verify-ranksetup-bin " + configId; ProcessExecuter executer = new ProcessExecuter(); try { Pair<Integer, String> ret = executer.exec(job); if (ret.getFirst() != 0) { validateFail(ret.getSecond(), sc, sdName, deployLogger); } } catch (IOException e) { validateWarn(e, deployLogger); return false; } return true; }
@Inject public StandaloneContainerApplication(Injector injector) { this.injector = injector; ConfiguredApplication.ensureVespaLoggingInitialized(); this.applicationPath = injectedApplicationPath().orElseGet(this::installApplicationPath); this.distributedFiles = new LocalFileDb(applicationPath); this.configModelRepo = resolveConfigModelRepo(); this.networkingOption = resolveNetworkingOption(); try { Pair<VespaModel, Container> tpl = withTempDir(preprocessedApplicationDir -> createContainerModel(applicationPath, distributedFiles, preprocessedApplicationDir, networkingOption, configModelRepo)); this.modelRoot = tpl.getFirst(); this.container = tpl.getSecond(); } catch (RuntimeException r) { throw r; } catch (Exception e) { throw new RuntimeException("Failed to create ContainerModel", e); } this.configuredApplication = createConfiguredApplication(container); }
private static Map<String, ExpressionFunction> convertStored(ModelStore store, RankProfile profile) { for (Pair<String, Tensor> constant : store.readSmallConstants()) profile.addConstant(constant.getFirst(), asValue(constant.getSecond())); for (RankingConstant constant : store.readLargeConstants()) { if ( ! profile.rankingConstants().asMap().containsKey(constant.getName())) profile.rankingConstants().add(constant); } for (Pair<String, RankingExpression> function : store.readFunctions()) { addGeneratedFunctionToProfile(profile, function.getFirst(), function.getSecond()); } return store.readExpressions(); }
@Override protected void doExecute(ExecutionContext ctx) { FieldValue input = ctx.getValue(); for (Pair<String, Expression> entry : cases) { FieldValue val = ctx.getInputValue(entry.getFirst()); if (val != null) { ctx.setValue(val).execute(entry.getSecond()); break; } } ctx.setValue(input); }
/** Gets a value from the query profile, or from the nested profile if the value is null */ @Override public Object get(CompoundName name, Map<String,String> context, com.yahoo.processing.request.Properties substitution) { name = unalias(name, context); Object value = null; if (values != null) value = values.get(name); if (value == null) { Pair<CompoundName, CompiledQueryProfile> reference = findReference(name); if (reference != null) return reference.getSecond().get(name.rest(reference.getFirst().size()), context, substitution); // yes; even if null } if (value == null) value = profile.get(name, context, substitution); if (value == null) value = super.get(name, context, substitution); return value; }
@Override protected void doVerify(VerificationContext context) { DataType input = context.getValue(); for (Pair<String, Expression> entry : cases) { DataType val = context.getInputType(this, entry.getFirst()); if (val == null) { throw new VerificationException(this, "Field '" + entry.getFirst() + "' not found."); } context.setValue(val).execute(entry.getSecond()); } context.setValue(input); }
private void getRankProperties(RankProfilesConfig.Rankprofile.Builder b) { RankProfilesConfig.Rankprofile.Fef.Builder fefB = new RankProfilesConfig.Rankprofile.Fef.Builder(); for (Pair<String, String> p : decompress(compressedProperties)) fefB.property(new RankProfilesConfig.Rankprofile.Fef.Property.Builder().name(p.getFirst()).value(p.getSecond())); b.fef(fefB); }