@Override public Tuple2<String, StructType> sourceSchema(SQLContext sqlContext, Option<StructType> schema, String providerName, Map<String, String> parameters) { return Tuple2.<String, StructType>apply(providerName, KafkaConnectStreamSource.DATA_SCHEMA); } }
private Map<String, String> buildSslConfig(JsonObject config) { Map<String, String> sslConfig = Map$.MODULE$.empty(); if (config.getString("sslMode")!= null) { sslConfig = sslConfig.$plus(Tuple2.apply("sslmode", config.getString("sslMode"))); } if (config.getString("sslRootCert") != null) { sslConfig = sslConfig.$plus(Tuple2.apply("sslrootcert", config.getString("sslRootCert"))); } return sslConfig; }
return Tuple2.apply(new TransformK() { private Sort sort;
private void forEachKLabel(Consumer<Tuple2<KLabel, Long>> action) { for (KLabel label : iterable(mainModule.definedKLabels())) { if (ConvertDataStructureToLookup.isLookupKLabel(label) || label.name().equals("#KToken")) continue; stream(mainModule.productionsFor().apply(label)).map(p -> Tuple2.apply(p.klabel().get(), stream(p.items()).filter(pi -> pi instanceof NonTerminal).count())).distinct().forEach(action); } }
static Tuple2<Either<Set<ParseFailedException>, Term>, Set<VarInfo>> visitPolyChildrenSets(TermCons tc, Function<Term, Tuple2<Either<Set<ParseFailedException>, Term>, Set<VarInfo>>> apply) { Set<ParseFailedException> errors = new HashSet<>(); Set<VarInfo> info = new HashSet<>(); for (int i : getPolyChildren(tc)) { Tuple2<Either<Set<ParseFailedException>, Term>, Set<VarInfo>> res = apply.apply(tc.get(i - 1)); info.addAll(res._2()); if (res._1().isLeft()) errors.addAll(res._1().left().get()); } if (errors.isEmpty()) return Tuple2.apply(Right.apply(tc), info); else return Tuple2.apply(Left.apply(errors), info); }
@Override public Tuple2<RewriterResult, K> executeAndMatch(K k, Optional<Integer> depth, Rule rule) { String ocaml = converter.executeAndMatch(k, depth.orElse(-1), rule, files.resolveTemp("run.out").getAbsolutePath(), files.resolveTemp("run.subst").getAbsolutePath()); files.saveToTemp("pgm.ml", ocaml); byte[] output = compileAndExecOcaml("pgm.ml"); byte[] subst = files.loadBytesFromTemp("run.subst"); return Tuple2.apply(parseOcamlRewriterOutput(output), parseOcamlSearchOutput(subst)); }
public Tuple2<RewriterResult, K> executeAndMatch(K k, Optional<Integer> depth, Rule rule) { RewriterResult res = execute(k, depth); return Tuple2.apply(res, match(res.k(), rule)); }
public static Map<KLabel, KLabel> collectionFor(Module m) { return stream(m.productions()).filter(p -> p.att().contains(Attribute.ASSOCIATIVE_KEY)).flatMap(p -> { Set<Tuple2<KLabel, KLabel>> set = new HashSet<>(); set.add(Tuple2.apply(p.klabel().get(), p.klabel().get())); if (p.att().contains(Attribute.UNIT_KEY)) { set.add(Tuple2.apply(KLabel(p.att().<String>get(Attribute.UNIT_KEY)), p.klabel().get())); } if (p.att().contains("element")) { set.add(Tuple2.apply(KLabel(p.att().<String>get("element")), p.klabel().get())); } if (p.att().contains("wrapElement")) { set.add(Tuple2.apply(KLabel(p.att().<String>get("wrapElement")), p.klabel().get())); } return set.stream(); }).distinct().collect(Collectors.toMap(Tuple2::_1, Tuple2::_2)); }
public static Map<KLabel, KLabel> collectionFor(Module m) { return stream(m.productions()).filter(p -> p.att().contains(Attribute.ASSOCIATIVE_KEY)).flatMap(p -> { Set<Tuple2<KLabel, KLabel>> set = new HashSet<>(); set.add(Tuple2.apply(p.klabel().get(), p.klabel().get())); if (p.att().contains(Attribute.UNIT_KEY)) { set.add(Tuple2.apply(KLabel(p.att().get(Attribute.UNIT_KEY)), p.klabel().get())); } if (p.att().contains("element")) { set.add(Tuple2.apply(KLabel(p.att().get("element")), p.klabel().get())); } if (p.att().contains("filterElement")) { set.add(Tuple2.apply(KLabel(p.att().get("filterElement")), p.klabel().get())); } if (p.att().contains("wrapElement")) { set.add(Tuple2.apply(KLabel(p.att().get("wrapElement")), p.klabel().get())); } return set.stream(); }).distinct().collect(Collectors.toMap(Tuple2::_1, Tuple2::_2)); }
public static org.kframework.attributes.Att convertAttributes(ASTNode t) { Attributes attributes = t.getAttributes(); Map<String, String> attributesSet = attributes .keySet() .stream() .map(key -> { String keyString = key.toString(); String valueString = attributes.get(key).getValue().toString(); if (keyString.equals("klabel")) { return Tuple2.apply("klabel", valueString); } else { return Tuple2.apply(keyString, valueString); } }).collect(Collectors.toMap(Tuple2::_1, Tuple2::_2)); return Att().addAll(attributesSet) .addAll(attributesFromLocation(t.getLocation())) .addAll(attributesFromSource(t.getSource())); }
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); K result = BinaryParser.parse(buf); return Tuple2.apply(result, exit); } catch (IOException e) { throw KEMException.internalError("Could not read from file in temp directory.", e);
assert sorts.size() <= 1; if (sorts.size() == 1) { rules.add(Tuple2.apply(rule, sorts.get(0)));
if (lhsVars.contains(var)) { if (k1 != k2) { edges.add(Tuple2.apply(k2, k1)); break;
if (lhsVars.contains(var)) { if (k1 != k2) { edges.add(Tuple2.apply(k2, k1)); break;
public static Tuple2<Definition, Module> getProofDefinition(File proofFile, String defModuleName, String specModuleName, CompiledDefinition compiledDefinition, Backend backend, FileUtil files, KExceptionManager kem, Stopwatch sw) { Kompile kompile = new Kompile(compiledDefinition.kompileOptions, files, kem, sw, true); if (defModuleName == null) { defModuleName = compiledDefinition.kompiledDefinition.mainModule().name(); } if (specModuleName == null) { specModuleName = FilenameUtils.getBaseName(proofFile.getName()).toUpperCase(); } java.util.Set<Module> modules = kompile.parseModules(compiledDefinition, defModuleName, files.resolveWorkingDirectory(proofFile).getAbsoluteFile()); Map<String, Module> modulesMap = new HashMap<>(); modules.forEach(m -> modulesMap.put(m.name(), m)); Module defModule = getModule(defModuleName, modulesMap, compiledDefinition.getParsedDefinition()); Module specModule = getModule(specModuleName, modulesMap, compiledDefinition.getParsedDefinition()); specModule = backend.specificationSteps(compiledDefinition.kompiledDefinition).apply(specModule); specModule = spliceModule(specModule, compiledDefinition.kompiledDefinition); Definition combinedDef = Definition.apply(defModule, compiledDefinition.getParsedDefinition().entryModules(), compiledDefinition.getParsedDefinition().att()); Definition compiled = compileDefinition(backend, combinedDef); return Tuple2.apply(compiled, specModule); }
@Override public K apply(KApply k) { if (k.klabel() instanceof KVariable) { return super.apply(k); } Att att = test.attributesFor().apply(KLabel(k.klabel().name())); if (att.contains("comm") && att.contains("assoc") && att.contains("unit")) { List<K> items = new ArrayList<>(Assoc.flatten(k.klabel(), k.klist().items(), KLabel(att.get("unit")))); List<Tuple2<String, K>> printed = new ArrayList<>(); for (K item : items) { String s = unparseInternal(test, apply(item), ColorSetting.OFF); printed.add(Tuple2.apply(s, item)); } printed.sort(Comparator.comparing(Tuple2::_1, new AlphanumComparator())); items = printed.stream().map(Tuple2::_2).map(this::apply).collect(Collectors.toList()); return items.stream().reduce((k1, k2) -> KApply(k.klabel(), k1, k2)).orElse(KApply(KLabel(att.get("unit")))); } return super.apply(k); } }.apply(input);
/** * Parses a string with a particular start symbol/sort. * * @param startSymbol the start symbol/sort * @param toParse the String to parse * @param fromSource the Source of the String toParse * @return a pair: the left projection is a parsed string as a K, if successful; * the right projection is the set of issues encountered while parsing */ @SuppressWarnings("unchecked") public Tuple2<Option<K>, Set<Warning>> apply(Sort startSymbol, String toParse, Source fromSource) { Tuple2<Either<Set<ParseFailedException>, K>, Set<ParseFailedException>> res = parseInModule.parseString(toParse, startSymbol, fromSource); Set<Warning> problemSet = new HashSet<>(); problemSet.addAll((Set<Warning>) (Object) res._2()); if (res._1().isLeft()) problemSet.addAll((Set<Warning>) (Object) res._1().left().get()); return Tuple2.apply(res._1().right().toOption(), problemSet); }
parsedPattern = pattern; return Tuple2.apply(rewriter.search(k, Optional.ofNullable(kRunOptions.depth), Optional.ofNullable(kRunOptions.bound), pattern, kRunOptions.searchType()), 0); return Tuple2.apply(res._1().k(), KRun.getExitCode(kem, res._2())); return Tuple2.apply(res._2(), 0); return Tuple2.apply(res.k(), res.exitCode().orElse(0));
private static Tuple2<String, String> getCellProperty(K k) { if (k instanceof KApply) { KApply kapp = (KApply) k; if (kapp.klabel().name().equals("#cellProperty")) { if (kapp.klist().size() == 2) { if (kapp.klist().items().get(0) instanceof KToken) { KToken keyToken = (KToken) kapp.klist().items().get(0); if (keyToken.sort().equals(Sort("#CellName"))) { String key = keyToken.s(); if (kapp.klist().items().get(0) instanceof KToken) { KToken valueToken = (KToken) kapp.klist().items().get(1); if (valueToken.sort().equals(Sorts.KString())) { String value = StringUtil.unquoteKString(valueToken.s()); return Tuple2.apply(key, value); } } } } } } } throw KEMException.compilerError("Malformed cell property", k); }