本文整理匯總了Java中org.apache.commons.lang3.tuple.MutablePair.setRight方法的典型用法代碼示例。如果您正苦於以下問題:Java MutablePair.setRight方法的具體用法?Java MutablePair.setRight怎麽用?Java MutablePair.setRight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.tuple.MutablePair
的用法示例。
在下文中一共展示了MutablePair.setRight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNode
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
@Override
public CommentsNodeImpl getNode(String path)
{
MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
CommentsNodeImpl node = (nodePair == null) ? null : nodePair.getRight();
if (node == null)
{
MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
node = (anyNodePair == null) ? null : anyNodePair.getRight();
if (node == null)
{
CommentsNodeImpl commentsNode = new CommentsNodeImpl(this);
if (nodePair != null)
{
nodePair.setRight(commentsNode);
}
else
{
this.dataMap.put(path, new MutablePair<>(null, commentsNode));
}
return commentsNode;
}
return node;
}
return node;
}
示例2: prefixSplitter
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
private Pair<String, String> prefixSplitter(String input) {
MutablePair<String, String> result = new MutablePair<>("", input);
if (input.startsWith("Device")) {
result.setLeft("Device");
result.setRight(input.replaceFirst("Device", ""));
} else if (input.startsWith("OperatingSystem")) {
result.setLeft("Operating System");
result.setRight(input.replaceFirst("OperatingSystem", ""));
} else if (input.startsWith("LayoutEngine")) {
result.setLeft("Layout Engine");
result.setRight(input.replaceFirst("LayoutEngine", ""));
} else if (input.startsWith("Agent")) {
result.setLeft("Agent");
result.setRight(input.replaceFirst("Agent", ""));
}
return result;
}
示例3: emitTuples
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* Implement InputOperator Interface.
*/
@Override
public void emitTuples()
{
if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) {
return;
}
int count = consumer.getQueueSize();
if (maxTuplesPerWindow > 0) {
count = Math.min(count, maxTuplesPerWindow - emitCount);
}
for (int i = 0; i < count; i++) {
Pair<String, Record> data = consumer.pollRecord();
String shardId = data.getFirst();
String recordId = data.getSecond().getSequenceNumber();
emitTuple(data);
MutablePair<String, Integer> shardOffsetAndCount = currentWindowRecoveryState.get(shardId);
if (shardOffsetAndCount == null) {
currentWindowRecoveryState.put(shardId, new MutablePair<String, Integer>(recordId, 1));
} else {
shardOffsetAndCount.setRight(shardOffsetAndCount.right + 1);
}
shardPosition.put(shardId, recordId);
}
emitCount += count;
}
示例4: onRemove
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* Invoked when a mapping of a map of one of the settings is removed.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting of which the entry was removed
* @param key the key of the mapping to be removed
*/
private synchronized void onRemove(SettingsContainer sc, Object key) {
MutablePair<V, Integer> pair = this.mergedMap.get(key);
if (pair != null && pair.getRight() == sc.listIndex) {
Pair<V, Integer> newVal = getIndexAndValueForKey(key);
if (newVal != null) {
pair.setLeft(newVal.getLeft());
pair.setRight(newVal.getRight());
}
else this.mergedMap.remove(key);
}
removeMapIfEmpty(sc.listIndex);
}
示例5: receive
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
@Override
public void receive(String channel, String packet)
{
String[] args = packet.split(":");
String[] prefix = args[0].split("/");
if (!prefix[0].equals(SamaGamesAPI.get().getServerName()))
return ;
int id = Integer.parseInt(prefix[1]);
MutablePair<ResultType, Object> result = TeamSpeakAPI.results.get(id);
TeamSpeakAPI.results.remove(id);
boolean ok = args.length > 1 && !args[1].equals("ERROR");
if (!ok)
SamaGamesAPI.get().getPlugin().getLogger().severe("[TeamSpeakAPI] Error : " + (args.length > 2 ? args[2] : "Unknown") + "(packet = " + packet + ")");
else
switch (result.getLeft())
{
case UUID_LIST:
List<UUID> uuid = (List<UUID>) result.getRight();
for (int i = 1; i < args.length; i++)
uuid.add(UUID.fromString(args[i]));
break;
case INTEGER:
result.setRight(Integer.parseInt(args[1]));
break;
case BOOLEAN:
result.setRight(args[1].equalsIgnoreCase("OK") || args[1].equalsIgnoreCase("true"));
break ;
default:
break ;
}
synchronized (result)
{
result.notifyAll();
}
}
示例6: average
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#average(org.apache.commons.lang3.tuple.MutablePair, java.io.Serializable)
*/
public MutablePair<Double, Integer> average(MutablePair<Double, Integer> sumAndCount, Double value) throws Exception {
if(sumAndCount == null && value == null)
return new MutablePair<>(Double.valueOf(0), Integer.valueOf(0));
if(sumAndCount == null && value != null)
return new MutablePair<>(Double.valueOf(value.doubleValue()), Integer.valueOf(1));
if(sumAndCount != null && value == null)
return sumAndCount;
sumAndCount.setLeft(sumAndCount.getLeft().doubleValue() + value.doubleValue());
sumAndCount.setRight(sumAndCount.getRight().intValue() + 1);
return sumAndCount;
}
示例7: average
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#average(org.apache.commons.lang3.tuple.Pair, java.io.Serializable)
*/
public MutablePair<Integer, Integer> average(MutablePair<Integer, Integer> sumAndCount, Integer value) throws Exception {
if(sumAndCount == null && value == null)
return new MutablePair<>(Integer.valueOf(0), Integer.valueOf(0));
if(sumAndCount == null && value != null)
return new MutablePair<>(Integer.valueOf(value.intValue()), Integer.valueOf(1));
if(sumAndCount != null && value == null)
return sumAndCount;
sumAndCount.setLeft(sumAndCount.getLeft().intValue() + value.intValue());
sumAndCount.setRight(sumAndCount.getRight().intValue() + 1);
return sumAndCount;
}
示例8: updateBlock
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
public void updateBlock(long time, BlockChangeRecord record) {
MutablePair<Long, BlockChangeRecord> pair = blockChanges(record.getPosition());
if (pair.getLeft() < time) {
pair.setLeft(time);
pair.setRight(record);
}
}
示例9: resourceCsvToBatchedPair
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
Pair<List<String>, List<Object[]>> resourceCsvToBatchedPair(final Resource resource)
throws IOException {
XLOGGER.entry(resource.getDescription());
// parse CSV
try (InputStreamReader isReader = new InputStreamReader(resource.getInputStream())) {
CSVParser parser = CSVFormat.DEFAULT.withHeader().withNullString("").parse(isReader);
// read header row
MutablePair<List<String>, List<Object[]>> readData = new MutablePair<>();
readData.setLeft( new ArrayList<>( parser.getHeaderMap().keySet() ) );
XLOGGER.info("Read header: " + readData.getLeft() );
// read data rows
List<Object[]> rows = new ArrayList<>();
for ( CSVRecord record : parser.getRecords() ) {
if ( ! record.isConsistent() ) {
throw new IllegalArgumentException("CSV record inconsistent: " + record);
}
List theRow = IteratorUtils.toList(record.iterator());
rows.add( theRow.toArray() );
}
readData.setRight(rows);
XLOGGER.exit("Records read: " + readData.getRight().size());
return readData;
}
}
示例10: emitTuples
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
@Override
public void emitTuples()
{
if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) {
return;
}
int count = consumer.messageSize() + ((pendingMessage != null) ? 1 : 0);
if (maxTuplesPerWindow > 0) {
count = Math.min(count, maxTuplesPerWindow - emitCount);
}
KafkaConsumer.KafkaMessage message = null;
for (int i = 0; i < count; i++) {
if (pendingMessage != null) {
message = pendingMessage;
pendingMessage = null;
} else {
message = consumer.pollMessage();
}
// If the total size transmitted in the window will be exceeded don't transmit anymore messages in this window
// Make an exception for the case when no message has been transmitted in the window and transmit at least one
// message even if the condition is violated so that the processing doesn't get stuck
if ((emitCount > 0) && ((maxTotalMsgSizePerWindow - emitTotalMsgSize) < message.msg.size())) {
pendingMessage = message;
break;
}
emitTuple(message);
emitCount++;
emitTotalMsgSize += message.msg.size();
offsetStats.put(message.kafkaPart, message.offSet);
MutablePair<Long, Integer> offsetAndCount = currentWindowRecoveryState.get(message.kafkaPart);
if (offsetAndCount == null) {
currentWindowRecoveryState.put(message.kafkaPart, new MutablePair<Long, Integer>(message.offSet, 1));
} else {
offsetAndCount.setRight(offsetAndCount.right + 1);
}
}
}
示例11: accumulate
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
@Override
public MutablePair<Double, Long> accumulate(MutablePair<Double, Long> accu, Double input)
{
accu.setLeft(accu.getLeft() * ((double)accu.getRight() / (accu.getRight() + 1)) + input / (accu.getRight() + 1));
accu.setRight(accu.getRight() + 1);
return accu;
}
示例12: merge
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
@Override
public MutablePair<Double, Long> merge(MutablePair<Double, Long> accu1, MutablePair<Double, Long> accu2)
{
accu1.setLeft(accu1.getLeft() * ((double)accu1.getRight() / accu1.getRight() + accu2.getRight()) +
accu2.getLeft() * ((double)accu2.getRight() / accu1.getRight() + accu2.getRight()));
accu1.setRight(accu1.getRight() + accu2.getRight());
return accu1;
}
示例13: onEntryRemove
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* Invoked when an entry of a map of one of the settings is removed.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting of which the entry was removed
* @param entry the removed entry
*/
private synchronized void onEntryRemove(SettingsContainer sc, Map.Entry<K, V> entry) {
MutablePair<V, Integer> pair = this.mergedMap.get(entry.getKey());
if (pair != null && pair.getRight() == sc.listIndex) {
Pair<V, Integer> newVal = getIndexAndValueForKey(entry.getKey());
if (newVal != null) {
pair.setLeft(newVal.getLeft());
pair.setRight(newVal.getRight());
}
}
removeMapIfEmpty(sc.listIndex);
}
示例14: onPut
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* Invoked when a mapping was put into a map of one of the settings.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting into which the mapping was put
* @param key the key of the mapping
* @param value the value of the mapping
*/
private synchronized void onPut(SettingsContainer sc, K key, V value) {
MutablePair<V, Integer> pair = this.mergedMap.get(key);
if (pair == null)
this.mergedMap.put(key, MutablePair.of(value, sc.listIndex));
else if (pair.getRight() >= sc.listIndex) {
pair.setLeft(value);
pair.setRight(sc.listIndex);
}
}
示例15: DeferredEvent
import org.apache.commons.lang3.tuple.MutablePair; //導入方法依賴的package包/類
/**
* Allows constructing objects that will receive an eventAction() call from
* Timed after delay ticks.
*
* @param delay
* the number of ticks that should pass before this deferred event
* object's eventAction() will be called.
*/
public DeferredEvent(final long delay) {
if (delay <= 0) {
eventArrival = Timed.getFireCount();
eventAction();
received = true;
return;
}
eventArrival = Timed.calcTimeJump(delay);
MutablePair<Integer, DeferredEvent[]> simultaneousReceiverPairs = toSweep.get(eventArrival);
if (simultaneousReceiverPairs == null) {
simultaneousReceiverPairs = new MutablePair<Integer, DeferredEvent[]>(0, new DeferredEvent[5]);
toSweep.put(eventArrival, simultaneousReceiverPairs);
}
int len = simultaneousReceiverPairs.getLeft();
DeferredEvent[] simultaneousReceivers = simultaneousReceiverPairs.getRight();
if (len == simultaneousReceivers.length) {
DeferredEvent[] temp = new DeferredEvent[simultaneousReceivers.length * 2];
System.arraycopy(simultaneousReceivers, 0, temp, 0, len);
simultaneousReceivers = temp;
simultaneousReceiverPairs.setRight(temp);
}
simultaneousReceivers[len++] = this;
simultaneousReceiverPairs.setLeft(len);
if (!dispatcherSingleton.isSubscribed() || dispatcherSingleton.getNextEvent() > eventArrival) {
dispatcherSingleton.updateDispatcher();
}
}