Java Code Examples for org.apache.commons.lang3.tuple.MutablePair#getLeft()
The following examples show how to use
org.apache.commons.lang3.tuple.MutablePair#getLeft() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommentsNodeImpl.java From Diorite with MIT License | 6 votes |
public Map<String, MutablePair<String, CommentsNodeImpl>> copyMap(CommentsNodeImpl parent) { Map<String, MutablePair<String, CommentsNodeImpl>> result = new HashMap<>(this.dataMap.size()); for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : this.dataMap.entrySet()) { String keyToCpy = entry.getKey(); MutablePair<String, CommentsNodeImpl> valueToCpy = entry.getValue(); CommentsNodeImpl nodeToCpy = valueToCpy.getRight(); CommentsNodeImpl copiedNode; if (nodeToCpy == null) { copiedNode = null; } else { copiedNode = new CommentsNodeImpl(parent); copiedNode.dataMap.putAll(nodeToCpy.copyMap(parent)); } MutablePair<String, CommentsNodeImpl> copied = new MutablePair<>(valueToCpy.getLeft(), copiedNode); result.put(keyToCpy, copied); } return result; }
Example 2
Source File: CommentsNodeImpl.java From Diorite with MIT License | 6 votes |
@Override public void trim() { for (Iterator<Entry<String, MutablePair<String, CommentsNodeImpl>>> iterator = this.dataMap.entrySet().iterator(); iterator.hasNext(); ) { Entry<String, MutablePair<String, CommentsNodeImpl>> entry = iterator.next(); MutablePair<String, CommentsNodeImpl> value = entry.getValue(); CommentsNodeImpl right = value.getRight(); if (right != null) { right.trim(); } if (((right == null) || right.dataMap.isEmpty()) && (value.getLeft() == null)) { iterator.remove(); continue; } if (right == null) { continue; } right.trim(); } }
Example 3
Source File: CommentsNodeImpl.java From Diorite with MIT License | 6 votes |
@Override @Nullable public String getComment(String path) { MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path); if (nodePair != null) { String comment = nodePair.getLeft(); if (comment != null) { return comment; } } MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY); if (anyNodePair != null) { return anyNodePair.getKey(); } return null; }
Example 4
Source File: DefaultSharedIndexInformer.java From java with Apache License 2.0 | 5 votes |
/** * handleDeltas handles deltas and call processor distribute. * * @param deltas deltas */ private void handleDeltas(Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>> deltas) { if (CollectionUtils.isEmpty(deltas)) { return; } // from oldest to newest for (MutablePair<DeltaFIFO.DeltaType, KubernetesObject> delta : deltas) { DeltaFIFO.DeltaType deltaType = delta.getLeft(); switch (deltaType) { case Sync: case Added: case Updated: boolean isSync = deltaType == DeltaFIFO.DeltaType.Sync; Object oldObj = this.indexer.get((ApiType) delta.getRight()); if (oldObj != null) { this.indexer.update((ApiType) delta.getRight()); this.processor.distribute( new ProcessorListener.UpdateNotification(oldObj, delta.getRight()), isSync); } else { this.indexer.add((ApiType) delta.getRight()); this.processor.distribute( new ProcessorListener.AddNotification(delta.getRight()), isSync); } break; case Deleted: this.indexer.delete((ApiType) delta.getRight()); this.processor.distribute( new ProcessorListener.DeleteNotification(delta.getRight()), false); break; } } }
Example 5
Source File: EventCorrelator.java From java with Apache License 2.0 | 5 votes |
public Optional<MutablePair<V1Event, V1Patch>> correlate(V1Event event) { MutablePair<V1Event, String> aggregatedResult = this.aggregator.aggregate(event); V1Event aggregatedEvent = aggregatedResult.getLeft(); String cacheKey = aggregatedResult.getRight(); MutablePair<V1Event, V1Patch> observeResult = this.logger.observe(aggregatedEvent, cacheKey); if (!this.filter.test(event)) { return Optional.empty(); } return Optional.of(observeResult); }
Example 6
Source File: EventAggregator.java From java with Apache License 2.0 | 5 votes |
public synchronized MutablePair<V1Event, String> aggregate(V1Event event) { DateTime now = DateTime.now(); MutablePair<String, String> aggregatedKeys = keyFunc.apply(event); String aggregatedKey = aggregatedKeys.getLeft(); String localKey = aggregatedKeys.getRight(); AggregatedRecord record; try { record = this.spammingCache.get(aggregatedKey, AggregatedRecord::new); } catch (ExecutionException e) { throw new IllegalStateException(e); } record.lastTimestamp = now; record.localKeys.add(localKey); if (record.localKeys.size() < this.maxEvents) { this.spammingCache.put(aggregatedKey, record); return new MutablePair<>(event, EventUtils.getEventKey(event)); } record.localKeys.remove(record.localKeys.stream().findAny().get()); // remove any keys V1Event aggregatedEvent = new V1EventBuilder(event) .withMetadata( new V1ObjectMetaBuilder() .withName(EventUtils.generateName(event.getInvolvedObject().getName(), now)) .withNamespace(event.getInvolvedObject().getNamespace()) .build()) .withCount(1) .withFirstTimestamp(now) .withLastTimestamp(now) .withMessage(this.messageFunc.apply(event)) .build(); this.spammingCache.put(aggregatedKey, record); return new MutablePair<>(aggregatedEvent, aggregatedKey); }
Example 7
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static VoxelShape getShape(AxisAlignedBB aabb) { VoxelShape shape = bbToShapeCache.getIfPresent(aabb); if (shape == null) { shape = VoxelShapes.create(aabb); bbToShapeCache.put(aabb, shape); MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getLeft() == null) { entry.setLeft(aabb); } } return shape; }
Example 8
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static AxisAlignedBB getAABB(VoxelShape shape) { MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getLeft() == null) { entry.setLeft(shape.getBoundingBox()); } return entry.getLeft(); }
Example 9
Source File: CommentsNodeImpl.java From Diorite with MIT License | 5 votes |
@SuppressWarnings("unchecked") Map<String, MutablePair<String, ?>> buildMap() { Map<String, MutablePair<String, ?>> resultMap = new LinkedHashMap<>(this.dataMap.size()); for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : this.dataMap.entrySet()) { MutablePair<String, CommentsNodeImpl> value = entry.getValue(); CommentsNodeImpl right = value.getRight(); String left = value.getLeft(); if ((right == null) && (left == null)) { continue; } Map<String, MutablePair<String, ?>> rightMap = null; if (right != null) { rightMap = right.buildMap(); if (rightMap.isEmpty()) { rightMap = null; if (left == null) { continue; } } } resultMap.put(entry.getKey(), new MutablePair<>(left, rightMap)); } return resultMap; }
Example 10
Source File: CommentsNodeImpl.java From Diorite with MIT License | 5 votes |
@Override public void join(CommentsNode toJoin_) { if (toJoin_ instanceof EmptyCommentsNode) { return; } if (! (toJoin_ instanceof CommentsNodeImpl)) { throw new IllegalArgumentException("Can't join to unknown node type."); } CommentsNodeImpl toJoin = (CommentsNodeImpl) toJoin_; for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : toJoin.dataMap.entrySet()) { String nodeKey = entry.getKey(); MutablePair<String, CommentsNodeImpl> pair = entry.getValue(); String nodeComment = pair.getLeft(); CommentsNodeImpl subNode = pair.getRight(); if (nodeComment != null) { this.setComment(nodeKey, nodeComment); } if (subNode != null) { this.join(nodeKey, subNode); } } }
Example 11
Source File: CommentsWriter.java From Diorite with MIT License | 5 votes |
@SuppressWarnings("unchecked") private void write(Map<String, MutablePair<String, ?>> map) throws IOException { this.updateIndent(true); int keys = map.entrySet().size(); int k = 0; for (Entry<String, MutablePair<String, ?>> entry : map.entrySet()) { k += 1; MutablePair<String, ?> pair = entry.getValue(); String comment = pair.getLeft(); Map<String, MutablePair<String, ?>> rightMap = (Map<String, MutablePair<String, ?>>) pair.getRight(); int rightKeys = (rightMap == null) ? 0 : rightMap.size(); boolean newLine = keys > 3; if (comment != null) { this.writeComment(comment); } String key = entry.getKey(); this.writeKey(key); if (rightMap != null) { this.write(rightMap); } if (newLine) { this.writeNewLine(false); } } this.writeNewLine(false); this.updateIndent(false); }
Example 12
Source File: AbstractJdbcPollInputOperator.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public void beginWindow(long windowId) { currentWindowId = windowId; if (currentWindowId <= windowManager.getLargestCompletedWindow()) { try { replay(currentWindowId); return; } catch (SQLException e) { throw new RuntimeException("Replay failed", e); } } currentWindowRecoveryState = WindowData.of(currentWindowRecoveryState.key, lastEmittedRow, 0); if (isPollerPartition) { MutablePair<Object, Integer> keyOffset = fetchedKeyAndOffset.get(); if (keyOffset != null && keyOffset.getRight() < lastEmittedRow) { if (!adjustKeyAndOffset.get()) { // rebase offset lastEmittedRow -= keyOffset.getRight(); currentWindowRecoveryState.lowerBound = lastEmittedRow; currentWindowRecoveryState.key = keyOffset.getLeft(); adjustKeyAndOffset.set(true); } } } }
Example 13
Source File: Application.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public MutablePair<MutableLong, MutableLong> accumulate(MutablePair<MutableLong, MutableLong> accumulatedValue, MutablePair<Double, Double> input) { if (input.getLeft() * input.getLeft() + input.getRight() * input.getRight() < 1) { accumulatedValue.getLeft().increment(); } accumulatedValue.getRight().increment(); return accumulatedValue; }
Example 14
Source File: Average.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override public Double getOutput(MutablePair<Double, Long> accumulatedValue) { return accumulatedValue.getLeft(); }
Example 15
Source File: PartFileWriter.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override protected String getFileName(AbstractBlockReader.ReaderRecord<Slice> tuple) { MutablePair<Integer,String> blockId = blockInfo.get(tuple.getBlockId()); return blockId.getRight() + PARTSUFFIX + blockId.getLeft(); }
Example 16
Source File: PartFileWriter.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override public void finalizeFile(String fileName) throws IOException { MutablePair<Integer,String> blockId = blockInfo.get(Long.parseLong(fileName)); super.finalizeFile(blockId.getRight() + PARTSUFFIX + blockId.getLeft()); }