List of usage examples for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair
public ImmutablePair(final L left, final R right)
From source file:eu.bittrade.libs.steemj.configuration.PrivateKeyStorage.java
/** * Internal method to convert a WIF private key into an ECKey object. * //from www. jav a 2 s . c o m * @param wifPrivateKey * The key pair to convert. * @return The converted key pair. */ private ImmutablePair<PrivateKeyType, ECKey> convertWifToECKeyPair( ImmutablePair<PrivateKeyType, String> wifPrivateKey) { return new ImmutablePair<>(wifPrivateKey.getLeft(), DumpedPrivateKey.fromBase58(null, wifPrivateKey.getRight(), new Sha256ChecksumProvider()).getKey()); }
From source file:com.quancheng.plugin.common.PrintMessageFile.java
private Map<String, Pair<DescriptorProto, List<FieldDescriptorProto>>> transform( DescriptorProto sourceMessageDesc) { Map<String, Pair<DescriptorProto, List<FieldDescriptorProto>>> nestedFieldMap = Maps.newHashMap(); sourceMessageDesc.getNestedTypeList().forEach(new Consumer<DescriptorProto>() { @Override//from ww w .java 2 s . c om public void accept(DescriptorProto t) { nestedFieldMap.put(t.getName(), new ImmutablePair<DescriptorProto, List<FieldDescriptorProto>>(t, t.getFieldList())); } }); return nestedFieldMap; }
From source file:com.streamsets.pipeline.stage.it.AllSdcTypesIT.java
@Test public void testType() throws Exception { DecimalDefaultsConfig decimalDefaultsConfig = new DecimalDefaultsConfig(); decimalDefaultsConfig.scaleExpression = "${record:attributeOrDefault(str:concat(str:concat('jdbc.', str:toUpper(field:field())), '.scale'), 2)}"; decimalDefaultsConfig.precisionExpression = "${record:attributeOrDefault(str:concat(str:concat('jdbc.', str:toUpper(field:field())), '.precision'), 2)}"; HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder().decimalConfig(decimalDefaultsConfig) .build();/* w w w . j a v a 2s . c o m*/ HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build(); Map<String, Field> map = new LinkedHashMap<>(); map.put("col", field); Record record = RecordCreator.create("s", "s:1"); record.set(Field.create(map)); record.getHeader().setAttribute("jdbc.COL.scale", "1"); //So scale - 1 , precision -1 (at last as scale is set to 1, precision is not set ( default is 2)) try { processRecords(processor, hiveTarget, ImmutableList.of(record)); if (!supported) { Assert.fail("Type is not supported, but yet no exception was thrown"); } } catch (StageException se) { if (supported) { LOG.error("Processing exception", se); Assert.fail("Processing testing record unexpectedly failed: " + se.getMessage()); throw se; } else { Assert.assertEquals(Errors.HIVE_19, se.getErrorCode()); // No additional verification necessary return; } } assertTableExists("default.tbl"); assertQueryResult("select * from tbl", new QueryValidator() { @Override public void validateResultSet(ResultSet rs) throws Exception { assertResultSetStructure(rs, new ImmutablePair("tbl.col", hiveType), new ImmutablePair("tbl.dt", Types.VARCHAR)); Assert.assertTrue("Table tbl doesn't contain any rows", rs.next()); if (hiveValue.getClass().isArray()) { // Only supported array is a byte array Assert.assertArrayEquals((byte[]) hiveValue, (byte[]) rs.getObject(1)); } else { Assert.assertEquals(hiveValue, rs.getObject(1)); } Assert.assertFalse("Table tbl contains more then one row", rs.next()); } }); }
From source file:eu.bittrade.libs.steemj.configuration.SteemJConfig.java
/** * Default constructor that will set all default values. *///w ww. j a v a 2 s .co m private SteemJConfig() { this.clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); try { this.endpointURIs = new ArrayList<>(); this.addEndpointURI(new URI(DEFAULT_STEEM_API_URI)); } catch (URISyntaxException e) { // This can never happen! LOGGER.error("At least one of the configured default URIs has a Syntax error.", e); } this.responseTimeout = 1000; this.idleTimeout = 60000; this.dateTimePattern = "yyyy-MM-dd'T'HH:mm:ss"; this.apiUsername = new AccountName(System.getProperty("steemj.api.username", "")); this.apiPassword = System.getProperty("steemj.api.password", "").toCharArray(); this.maximumExpirationDateOffset = 3600000L; this.timeZoneId = "GMT"; this.encodingCharset = StandardCharsets.UTF_8; this.privateKeyStorage = new PrivateKeyStorage(); this.addressPrefix = AddressPrefixType.STM; this.chainId = "0000000000000000000000000000000000000000000000000000000000000000"; this.steemJWeight = 250; this.validationLevel = ValidationType.ALL; this.synchronizationLevel = SynchronizationType.FULL; this.dollarSymbol = AssetSymbolType.SBD; this.tokenSymbol = AssetSymbolType.STEEM; this.vestsSymbol = AssetSymbolType.VESTS; // Fill the key store with the provided accountName and private keys. this.defaultAccount = new AccountName(System.getProperty("steemj.default.account", "")); if (!this.defaultAccount.isEmpty()) { privateKeyStorage.addAccount(this.defaultAccount); for (PrivateKeyType privateKeyType : PrivateKeyType.values()) { String wifPrivateKey = System .getProperty("steemj.default.account." + privateKeyType.name().toLowerCase() + ".key"); // Only add keys if they are present. if (wifPrivateKey != null && !wifPrivateKey.isEmpty()) { privateKeyStorage.addPrivateKeyToAccount(this.defaultAccount, new ImmutablePair<PrivateKeyType, String>(privateKeyType, wifPrivateKey)); } } } }
From source file:eu.spaziodati.datatxt.stanbol.enhancer.engines.DatatxtNexEngine.java
public void computeEnhancements(ContentItem ci) throws EngineException { // We don't need to call ci.getLock().writeLock().lock() // as we're enhancing synchronously. String text = text(ci);//from w w w . ja v a 2 s. c om try { fTranslator.translate(new ImmutablePair<UriRef, MGraph>(ci.getUri(), ci.getMetadata()), this, text, fClient.doRequest(text, EnhancementEngineHelper.getLanguage(ci))); } catch (UnmanagedLanguageException ex) { fLogger.warn("Unable to process ContentItem {} because Language {} is not supported by DataTXT", ci, ex.getLanguage()); } catch (DatatxtException ex) { throw new EngineException(ex); } }
From source file:com.splicemachine.derby.stream.function.merge.AbstractMergeJoinFlatMapFunction.java
protected void initRightScan(PeekingIterator<LocatedRow> leftPeekingIterator) throws StandardException { ExecRow firstHashRow = joinOperation.getKeyRow(leftPeekingIterator.peek().getRow()); ExecRow startPosition = joinOperation.getRightResultSet().getStartPosition(); int[] columnOrdering = getColumnOrdering(joinOperation.getRightResultSet()); int nCols = startPosition != null ? startPosition.nColumns() : 0; ExecRow scanStartOverride = null;/* w w w .j ava 2 s .c o m*/ int[] scanKeys = null; // If start row of right table scan has as many columns as key colummns of the table, cannot further // narrow down scan space, so return right tabel scan start row. if (nCols == columnOrdering.length) { scanStartOverride = startPosition; scanKeys = columnOrdering; } else { int[] rightHashKeys = joinOperation.getRightHashKeys(); // Find valid hash column values to narrow down right scan. The valid hash columns must: // 1) not be used as a start key for inner table scan // 2) be consecutive // 3) be a key column LinkedList<Pair<Integer, Integer>> hashColumnIndexList = new LinkedList<>(); for (int i = 0; i < rightHashKeys.length; ++i) { if (rightHashKeys[i] > nCols - 1) { if ((hashColumnIndexList.isEmpty() || hashColumnIndexList.getLast().getValue() == rightHashKeys[i] - 1) && isKeyColumn(columnOrdering, rightHashKeys[i])) { hashColumnIndexList.add(new ImmutablePair<Integer, Integer>(i, rightHashKeys[i])); } else { break; } } } scanStartOverride = new ValueRow(nCols + hashColumnIndexList.size()); if (startPosition != null) { for (int i = 1; i <= startPosition.nColumns(); ++i) { scanStartOverride.setColumn(i, startPosition.getColumn(i)); } } for (int i = 0; i < hashColumnIndexList.size(); ++i) { Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i); int index = hashColumnIndex.getKey(); scanStartOverride.setColumn(nCols + i + 1, firstHashRow.getColumn(index + 1)); } // Scan key should include columns // 1) preceding the first hash column, these columns are in the form of "col=constant" // 2) all hash columns that are key columns scanKeys = new int[hashColumnIndexList.size() + rightHashKeys[0]]; for (int i = 0; i < rightHashKeys[0]; ++i) { scanKeys[i] = i; } for (int i = 0; i < hashColumnIndexList.size(); ++i) { Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i); int colPos = hashColumnIndex.getValue(); scanKeys[rightHashKeys[0] + i] = colPos; } } ((BaseActivation) joinOperation.getActivation()).setScanStartOverride(scanStartOverride); ((BaseActivation) joinOperation.getActivation()).setScanKeys(scanKeys); if (startPosition != null) { ((BaseActivation) joinOperation.getActivation()).setScanStopOverride(startPosition); } }
From source file:de.flashpixx.rrd_antlr4.antlr.CASTVisitorPCRE.java
/** * implodes a list of any objects, strings * will be concated into one string/* ww w. j a v a 2 s.co m*/ * * @param p_list list of pairs object & quantifier * @return list with concated objects and used quantifier */ private List<Pair<?, String>> implode(final List<Pair<?, String>> p_list) { // search string within the list final int l_start = this.filter(0, p_list); if (l_start < 0) return p_list; final int l_end = this.filter(l_start + 1, p_list); if (l_end < 0) return p_list; return this.implode(Stream .concat(Stream.of(new ImmutablePair<>( StringUtils.join(p_list.subList(l_start, l_end + 1).stream() .map(i -> i.getLeft().toString()).collect(Collectors.toList()), ""), p_list.get(l_end).getRight())), CASTVisitorPCRE.this.implode(p_list.subList(l_end + 1, p_list.size())).stream()) .collect(Collectors.toList())); }
From source file:com.yahoo.bard.webservice.util.Utils.java
/** * Given an ImmutablePair, and a right value, returns a new ImmutablePair with the same left value, * and the specified right value./* w w w . ja va 2 s . c o m*/ * * @param pair Immutable Pair instance * @param right The right value, may be null * @param <T> Left type of the pair * @param <U> Right type of the pair * @param <V> The right value to have new Immutable Pair * * @return New instance of Immutable Pair */ public static <T, U, V> ImmutablePair<T, V> withRight(ImmutablePair<T, U> pair, V right) { return new ImmutablePair<>(pair.getLeft(), right); }
From source file:com.hp.autonomy.frontend.reports.powerpoint.SlideShowTemplate.java
/** * Given an existing slide, search its relations to find a chart object. * @param slide a slide from the template. * @param error if we can't find a slide, this error message will be returned as the exception. * @return a pair containing the chart.xml data and the graphical object which represented it on the slide. * @throws TemplateLoadException if we can't find a chart object. *///from www. j a v a 2 s .c om private ImmutablePair<XSLFChart, CTGraphicalObjectFrame> getChart(final XSLFSlide slide, final String error) throws TemplateLoadException { for (POIXMLDocumentPart.RelationPart part : slide.getRelationParts()) { if (part.getDocumentPart() instanceof XSLFChart) { final String relId = part.getRelationship().getId(); for (XSLFShape shape : slide.getShapes()) { if (shape instanceof XSLFGraphicFrame) { final CTGraphicalObjectFrame frameXML = (CTGraphicalObjectFrame) shape.getXmlObject(); final XmlObject[] children = frameXML.getGraphic().getGraphicData() .selectChildren(new QName(XSSFRelation.NS_CHART, "chart")); for (final XmlObject child : children) { final String imageRel = child.getDomNode().getAttributes() .getNamedItemNS(RELATION_NAMESPACE, "id").getNodeValue(); if (relId.equals(imageRel)) { return new ImmutablePair<>(part.getDocumentPart(), frameXML); } } } } } } throw new TemplateLoadException(error); }
From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesPanel.java
private void addDependencyNode(MutableTreeTableNode parent, DirectedAcyclicGraphNode<String> node) { String channelId = node.getElement(); String channelName = channelNameMap.get(channelId); if (StringUtils.isNotBlank(channelName)) { MutableTreeTableNode newTreeTableNode = new DefaultMutableTreeTableNode( new ImmutablePair<String, String>(channelId, channelName)); SortableTreeTableModel model = (SortableTreeTableModel) dependencyTreeTable.getTreeTableModel(); model.insertNodeInto(newTreeTableNode, parent); List<DirectedAcyclicGraphNode<String>> dependencyNodes = new ArrayList<DirectedAcyclicGraphNode<String>>( node.getDirectDependencyNodes()); Collections.sort(dependencyNodes, new NodeComparator()); for (DirectedAcyclicGraphNode<String> dependencyNode : dependencyNodes) { addDependencyNode(newTreeTableNode, dependencyNode); }/* ww w. java2 s . co m*/ } }