當前位置: 首頁>>代碼示例>>Java>>正文


Java MutablePair.setRight方法代碼示例

本文整理匯總了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;
}
 
開發者ID:GotoFinal,項目名稱:diorite-configs-java8,代碼行數:27,代碼來源:CommentsNodeImpl.java

示例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;
}
 
開發者ID:nielsbasjes,項目名稱:yauaa,代碼行數:18,代碼來源:ParseService.java

示例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;
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:29,代碼來源:AbstractKinesisInputOperator.java

示例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);
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:23,代碼來源:MergedMappedSettings.java

示例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();
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:36,代碼來源:TeamSpeakAPI.java

示例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;	
}
 
開發者ID:ottogroup,項目名稱:flink-operator-library,代碼行數:15,代碼來源:DoubleContentAggregateFunction.java

示例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;
}
 
開發者ID:ottogroup,項目名稱:flink-operator-library,代碼行數:15,代碼來源:IntegerContentAggregateFunction.java

示例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);
    }
}
 
開發者ID:ReplayMod,項目名稱:ReplayStudio,代碼行數:8,代碼來源:SquashFilter.java

示例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;
  }
}
 
開發者ID:OpenLMIS,項目名稱:openlmis-stockmanagement,代碼行數:30,代碼來源:Resource2Db.java

示例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);
    }
  }
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:38,代碼來源:AbstractKafkaInputOperator.java

示例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;
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:8,代碼來源:Average.java

示例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;
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:9,代碼來源:Average.java

示例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);
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:22,代碼來源:MergedMappedSettings.java

示例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);
	}
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:19,代碼來源:MergedMappedSettings.java

示例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();
	}
}
 
開發者ID:kecskemeti,項目名稱:dissect-cf,代碼行數:36,代碼來源:DeferredEvent.java


注:本文中的org.apache.commons.lang3.tuple.MutablePair.setRight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。