/** * @param sndId Sender node ID. * @param reqId Request ID. * @return Recipient ID. */ private static Object recipient(UUID sndId, long reqId) { assert sndId != null; return new IgniteBiTuple<>(sndId, reqId); }
/** * Merge left and right statistics from partitions. * * @param left Left. * @param right Right. * @return merged value. */ private IgniteBiTuple<Double, Long> reduce(IgniteBiTuple<Double, Long> left, IgniteBiTuple<Double, Long> right) { if (left == null) { if (right != null) return right; else return new IgniteBiTuple<>(0.0, 0L); } if (right == null) return left; return new IgniteBiTuple<>( left.getKey() + right.getKey(), right.getValue() + left.getValue() ); } }
data -> { double sum = Arrays.stream(data.getLabels()).map(this::externalLabelToInternal).sum(); return new IgniteBiTuple<>(sum, (long)data.getLabels().length); }, (a, b) -> { return a; a.set1(a.get1() + b.get1()); a.set2(a.get2() + b.get2()); return a; meanTuple.set1(meanTuple.get1() / meanTuple.get2()); return meanTuple;
/** * @return Written blocks. */ long writeBlocks() { return blocksWritten.get1().longValue(); }
/** * @param cfgUrl Config URL. * @param jdbcName Appended to instance name or used as default. * @return Ignite config and Spring context. */ private IgniteBiTuple<IgniteConfiguration, ? extends GridSpringResourceContext> loadConfiguration(String cfgUrl, String jdbcName) { try { IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); if (cfg.getIgniteInstanceName() == null) cfg.setIgniteInstanceName(jdbcName); else cfg.setIgniteInstanceName(cfg.getIgniteInstanceName() + "-" + jdbcName); cfg.setClientMode(true); // Force client mode. return new IgniteBiTuple<>(cfg, cfgMap.getValue()); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
/** * @return Topology version future registered for multi-update. */ @Nullable public GridDhtTopologyFuture multiUpdateTopologyFuture() { IgniteBiTuple<IgniteUuid, GridDhtTopologyFuture> tup = multiTxHolder.get(); return tup == null ? null : tup.get2(); }
/** * @param req Request. * @return Response. */ private ClientListenerResponse processStreamingBatch(OdbcStreamingBatchRequest req) { assert cliCtx.isStream(); // Send back only the first error. Others will be written to the log. IgniteBiTuple<Integer, String> firstErr = new IgniteBiTuple<>(); SqlFieldsQueryEx qry = null; for (OdbcQuery q : req.queries()) { if (q.sql() != null) { // If we have a new query string in the batch, if (qry != null) // then execute the previous sub-batch and create a new SqlFieldsQueryEx. processStreamingBatch(qry, firstErr); qry = makeQuery(req.schemaName(), q.sql()); } assert qry != null; qry.addBatchedArgs(q.args()); } if (qry != null) processStreamingBatch(qry, firstErr); if (req.last()) cliCtx.disableStreaming(); if (firstErr.isEmpty()) return new OdbcResponse(new OdbcStreamingBatchResult(req.order())); else { assert firstErr.getKey() != null; return new OdbcResponse(new OdbcStreamingBatchResult(firstErr.getKey(), firstErr.getValue(), req.order())); } }
/** * Starts new grid with given name. * * @param gridName Grid name. * @param client Client mode. * @param cfgUrl Config URL. * @return Started grid. * @throws Exception If failed. */ protected Ignite startGridWithSpringCtx(String gridName, boolean client, String cfgUrl) throws Exception { IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); cfg.setIgniteInstanceName(gridName); cfg.setClientMode(client); return IgnitionEx.start(cfg, cfgMap.getValue()); }
/** * Calculates indexes of WAL segments covered by last checkpoint. * * @return list of indexes or empty list if there are no checkpoints. */ private IgniteBiTuple<Long, Long> calculateWalSegmentsCovered() { IgniteBiTuple<Long, Long> tup = new IgniteBiTuple<>(-1L, -1L); Map.Entry<Long, CheckpointEntry> lastEntry = histMap.lastEntry(); if (lastEntry == null) return tup; Map.Entry<Long, CheckpointEntry> previousEntry = histMap.lowerEntry(lastEntry.getKey()); WALPointer lastWALPointer = lastEntry.getValue().checkpointMark(); long lastIdx = 0; long prevIdx = 0; if (lastWALPointer instanceof FileWALPointer) { lastIdx = ((FileWALPointer)lastWALPointer).index(); if (previousEntry != null) prevIdx = ((FileWALPointer)previousEntry.getValue().checkpointMark()).index(); } tup.set1(prevIdx); tup.set2(lastIdx - 1); return tup; }
/** */ private KeyCacheObject toKey(EnlistOperation op, Object cur) { KeyCacheObject key = cctx.toCacheKeyObject(op.isDeleteOrLock() ? cur : ((IgniteBiTuple)cur).getKey()); if (key.partition() == -1) key.partition(cctx.affinity().partition(key)); return key; }
return res.isEmpty() ? null : ((IgniteBiTuple)res.get(0)).getValue();
/** {@inheritDoc} */ @Override public V2 setValue(@Nullable V2 val) { V2 old = val2; set2(val); return old; }
weightedTop.set1(true);
map.put(nodeId, new IgniteBiTuple<Collection<HadoopInputSplit>, int[]>(plan.mappers(nodeId), null)); map.put(nodeId, new IgniteBiTuple<Collection<HadoopInputSplit>, int[]>(null, reducers)); else entry.set2(reducers); Collection<HadoopInputSplit> mappers = entry.getValue().get1(); int[] reducers = entry.getValue().get2();
/** * Returns annotated value. * * @param target Object to find a value in. * @return Value of annotated field or method. * @throws IgniteCheckedException If failed to find. */ public Object annotatedValue(Object target) throws IgniteCheckedException { IgniteBiTuple<Object, Boolean> res = annotatedValue(target, new HashSet<>(), false); assert res != null; return res.get1(); }
/** {@inheritDoc} */ @Override protected boolean accept(IgniteBiTuple<WALPointer, WALRecord> tup) { return !(tup.get2() instanceof PartitionMetaStateRecord); } }