0

I have a problem in getting cardinality service in hazelcast. In following code, I add some visitor to cardinality estimator. messageID is unique. In test environment that filled by 5K unique item by this code.

public void AppendVisitor(String messageID, String visitor)  {
    CardinalityEstimator cs = this.hazelcast.getCardinalityEstimator(messageID);
    cs.add(visitor);
    this.viewsList.putIfAbsent(messageID, Long.valueOf(System.currentTimeMillis() / 1000L));
  }

In expiration of viewsList in another class I write listener code. The entry event key was messageID in previous code. But when call this function, visit is 0. Seems it get another object that is empty.

@Override
    public void entryEvicted(EntryEvent<String, Long> entryEvent) {

        long visit = hazelcast.getCardinalityEstimator(messageID).estimate();
    }
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
M.Ali R
  • 1
  • 1
  • Can you post some code with more detail ? Ideally [MVCE](https://stackoverflow.com/help/mcve) – Neil Stevenson Mar 17 '19 at 15:40
  • I don't get zeroes. Can you post a more complete example please ? How is `viewsList` defined ? Is it a map or a list ? Why `putIfAbsert` if the `messageID` is unique ? – Neil Stevenson Mar 18 '19 at 09:52
  • @NeilStevenson viewLIst is IMap and keep message ID. puIfAbsent is used to when message ID is not present in IMap. – M.Ali R Mar 19 '19 at 10:52
  • You need to post *MORE* code if you want this resolved. For example, your `entryEvicted()` method doesn't use the `entryEvent`. – Neil Stevenson Mar 19 '19 at 11:42

0 Answers0