Examples of Counter


Examples of info.archinnov.achilles.type.Counter

        // Build proxy when necessary
        switch (propertyMeta.type()) {
            case COUNTER:
                if (rawValue == null) {
                    final Counter counter = InternalCounterBuilder.initialValue(null);
                    propertyMeta.forValues().setValueToField(target, counter);
                }
                result = rawValue;
                break;
            case LIST:
View Full Code Here

Examples of io.vertx.core.shareddata.Counter

  @Test
  public void testIllegalArguments() throws Exception {
    assertNullPointerException(() -> getVertx().sharedData().getCounter(null, ar -> {}));
    assertNullPointerException(() -> getVertx().sharedData().getCounter("foo", null));
    getVertx().sharedData().getCounter("foo", ar -> {
      Counter counter = ar.result();
      assertNullPointerException(() -> counter.get(null));
      assertNullPointerException(() -> counter.incrementAndGet(null));
      assertNullPointerException(() -> counter.getAndIncrement(null));
      assertNullPointerException(() -> counter.decrementAndGet(null));
      assertNullPointerException(() -> counter.addAndGet(1, null));
      assertNullPointerException(() -> counter.getAndAdd(1, null));
      assertNullPointerException(() -> counter.compareAndSet(1, 1, null));
      testComplete();
    });
    await();
  }
View Full Code Here

Examples of kea.util.Counter

      String str = getInputFormat().instance(i).stringValue(m_DocumentAtt);
      HashMap<String,Counter> hash = getPhrasesForDictionary(str);
      Iterator<String> it = hash.keySet().iterator();
      while (it.hasNext()) {
        String phrase = it.next();
        Counter counter = m_Dictionary.get(phrase);
        if (counter == null) {
          m_Dictionary.put(phrase, new Counter());
        } else {
          counter.increment();
        }
      }
    }

    if (m_KFused) {      
     

      // Build dictionary of n-grams that occur as keyphrases
      // with associated keyphrase frequencies
      m_KeyphraseDictionary = new HashMap<String,Counter>();
      for (int i = 0; i < getInputFormat().numInstances(); i++) {
        String str = getInputFormat().instance(i).stringValue(m_KeyphrasesAtt);
        HashMap<String,Counter> hash = getGivenKeyphrases(str, false);
        if (hash != null) {
          Iterator<String> it = hash.keySet().iterator();
          while (it.hasNext()) {
            String phrase = it.next();
            Counter counter = m_KeyphraseDictionary.get(phrase);
            if (counter == null) {
              m_KeyphraseDictionary.put(phrase, new Counter());
            } else {
              counter.increment();
            }
          }
        }
      }
    } else {
View Full Code Here

Examples of mage.counters.Counter

        GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, controllerId, counter.getName(), counter.getCount());
        countersEvent.setAppliedEffects(appliedEffects);
        if (!game.replaceEvent(countersEvent)) {
            int amount = countersEvent.getAmount();
            for (int i = 0; i < amount; i++) {
                Counter eventCounter = counter.copy();
                eventCounter.remove(eventCounter.getCount() - 1);
                GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId, counter.getName(), 1);
                event.setAppliedEffects(appliedEffects);
                if (!game.replaceEvent(event)) {
                    counters.addCounter(eventCounter);
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, controllerId, counter.getName(), 1));
View Full Code Here

Examples of maui.util.Counter

    // Build a dictionary of candidates with associated
    // document frequencies
    globalDictionary = new HashMap<String, Counter>();
    for (HashMap<String, Candidate> candidates : allCandidates.values()) {
      for (String candidateName : candidates.keySet()) {
        Counter counter = globalDictionary.get(candidateName);
        if (counter == null) {
          globalDictionary.put(candidateName, new Counter());
        } else {
          counter.increment();
        }
      }
    }

    if (debugMode) {
      System.err.println("--- Building keyphraseness dictionary");
    }
    // Build a dictionary of candidates that occur as keyphrases
    // with associated keyphrase frequencies
    keyphraseDictionary = new HashMap<String, Counter>();
    for (int i = 0; i < getInputFormat().numInstances(); i++) {
      String str = getInputFormat().instance(i)
      .stringValue(keyphrasesAtt);
      HashMap<String, Counter> hash = getGivenKeyphrases(str);
      if (hash != null) {
        for (String term : hash.keySet()) {

          Counter documentCount = hash.get(term);
          Counter counter = keyphraseDictionary.get(term);
          if (counter == null) {
            keyphraseDictionary.put(term, new Counter(documentCount
                .value()));
          } else {
            counter.increment(documentCount.value());
          }
        }
      }
    }
View Full Code Here

Examples of net.rubyeye.xmemcached.Counter

  public void tearDown() throws Exception {
    memcachedClient.shutdown();
  }

  public void testCounter() throws Exception {
    Counter counter = memcachedClient.getCounter("a");
    Assert.assertEquals(0, counter.get());
    Assert.assertEquals(0, counter.get());

    Assert.assertEquals(1, counter.incrementAndGet());
    Assert.assertEquals(2, counter.incrementAndGet());
    Assert.assertEquals(3, counter.incrementAndGet());

    Assert.assertEquals(2, counter.decrementAndGet());
    Assert.assertEquals(1, counter.decrementAndGet());
    Assert.assertEquals(0, counter.decrementAndGet());
    Assert.assertEquals(0, counter.decrementAndGet());

    Assert.assertEquals(4, counter.addAndGet(4));
    Assert.assertEquals(7, counter.addAndGet(3));
    Assert.assertEquals(0, counter.addAndGet(-7));

    counter.set(1000);
    Assert.assertEquals(1000, counter.get());
    Assert.assertEquals(1001, counter.incrementAndGet());

    counter = memcachedClient.getCounter("b", 100);
    Assert.assertEquals(101, counter.incrementAndGet());
    Assert.assertEquals(102, counter.incrementAndGet());
    Assert.assertEquals(101, counter.decrementAndGet());

    // test issue 74
    counter = memcachedClient.getCounter("issue74", 0);
    for (int i = 0; i < 100; i++) {
      Assert.assertEquals(i + 1, counter.incrementAndGet());
    }
    for (int i = 0; i < 100; i++) {
      counter.decrementAndGet();
    }
    Assert.assertEquals(0, counter.get());
  }
View Full Code Here

Examples of net.sf.clairv.p2p.util.Counter

  }

  public void send(String key, Message message) {
    Id id = idFactory.buildId(key);
    log.debug("Sending message with id: " + id.toStringFull());
    final Counter counter = new Counter(1);
    this.endpoint.route(id, message, null, new DeliveryNotification() {

      public void sendFailed(MessageReceipt arg0, Exception arg1) {
        log.warn("Failed to send the message");
        counter.decrement();
      }

      public void sent(MessageReceipt receipt) {
        counter.decrement();
      }

    });
    while (counter.getValue() == 1) {

    }
  }
View Full Code Here

Examples of net.sf.clairv.search.util.Counter

  public ResponseMessage handleRequest(OverlayRequest request) {

    final Wrapper resp = new Wrapper();

    final Counter counter = new Counter(1);

    final KeywordQueryMessage kqm = (KeywordQueryMessage) request
        .getMessage();

    final DocList docList = reader.getMatchList(kqm.getKeywords()[kqm
        .getCurrentKeywordIndex()]);

    idf = reader.getIdf();

    final ScoreDocList sdList = new ScoreDocList(docList);

    if (kqm.getCurrentBloomFilter() != null) {
      SimpleBloomFilter receivedBloomFilter = kqm
          .getCurrentBloomFilter();
      // calculate F(a) intersects B
      sdList.intersects(receivedBloomFilter);
    }

    final SimpleBloomFilter currentBloomFilter = (new BloomFilterCreator())
        .createBloomFilter(sdList);
    try {
      OverlayNetwork network = PastryNetwork.getInstance();
      if (kqm.getCurrentKeywordIndex() < kqm.getKeywords().length - 1) {
        // if current node is NOT the last node of the message-chaining
        // process
        KeywordQueryMessage newKqm = new KeywordQueryMessage(kqm
            .getKeywords(), kqm.getCurrentKeywordIndex() + 1, currentBloomFilter);

        network.send(
            kqm.getKeywords()[kqm.getCurrentKeywordIndex() + 1],
            newKqm, new MessageCallback() {

              public void onResponse(ResponseMessage response) {

                if (response instanceof KeywordQueryRespMessage) {
                  ScoreDocList receivedSdList = ((KeywordQueryRespMessage) response)
                      .getSdList();

                  Scorer.calculateScore(docList,
                      receivedSdList, idf);
                  resp.value = new KeywordQueryRespMessage(
                      receivedSdList);

                  counter.decrement();
                }
              }
            });
      } else {
        // on the last node
        sdList.intersects(currentBloomFilter);
        Scorer.mutiplyIdf(sdList, idf);
        resp.value = new KeywordQueryRespMessage(sdList);
        counter.decrement();
      }

    } catch (OverlayNetworkException e) {
      log.error("Error in handling KeywordQueryMessage: ", e);
    }

    while (counter.getValue() != 0) {
     
    }

    return (ResponseMessage)resp.value;
  }
View Full Code Here

Examples of net.sourceforge.align.calculator.length.counter.Counter

   * Constructs algorithm object. It is similar to Gale and Church algorithm
   * but based on Forward Backward method instead of Viterbi method.
   */
  @Before
  public void setUp() {
    Counter counter = new CharCounter();
    Calculator calculator = new NormalDistributionCalculator(counter);
    MatrixFactory matrixFactory = new FullMatrixFactory();
   
    algorithm = new ForwardBackwardAlgorithm(calculator,
        CategoryDefaults.BEST_CATEGORY_MAP, matrixFactory);
View Full Code Here

Examples of opennlp.maxent.Counter

    try {
      for(String s = br.readLine(); s!=null; s=br.readLine()) {
        StringTokenizer st = new StringTokenizer(s);
        while(st.hasMoreTokens()) {
          String tok = (String)split(st.nextToken()).a;
          Counter c = (Counter)map.get(tok);
          if(c!=null)
            c.increment();
          else
            map.put(tok, new Counter());
        }
      }
    } catch (IOException e) { e.printStackTrace(); }
   
    HashSet set = new HashSet();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.