-2

i write inner product method to compute inner product between bloom filter and list of bloom filter then retrieve the name of bloom filter attach with the max value of this inner product in the following class as:

 public String innerProduct(List<BloomFilter> bfListt , BloomFilter ff){
           long ddd=0;
           String ma=null;

            Hashtable <Long,String> hashhhTT=new Hashtable<Long ,String >();

         for(int i=0;i<bfListt.size();i++){
              ddd=0;
             BloomFilter fi=bfListt.get(i);
            String nameOfFile= fi.getName();
             for(int j=0;j<fi.size();j++){
              ddd+= fi.getBitSet().getWord(j)*ff.getBitSet().getWord(j);
             }
             hashhhTT.put(ddd, nameOfFile);
             }
               Set<Long> summtion=hashhhTT.keySet();
               Long maxmaximum= Collections.max(summtion);

                    ma=hashhhTT.get(maxmaximum); 

          return ma; 
         }

but the following exception appear:

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
    at java.util.Collections$EmptyIterator.next(Collections.java:4189)
    at java.util.Collections.max(Collections.java:669)
    at searchencrypted.ReadData.innerProduct(ReadData.java:633)
    at searchencrypted.GUI.jButton4ActionPerformed(GUI.java:397)
    at searchencrypted.GUI.access$300(GUI.java:31)
    at searchencrypted.GUI$4.actionPerformed(GUI.java:142)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at 

java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 2
    Please fix the indentation, it looks like completely random chaos right now. Where does the "BloomFilter" come from, is this from Guava? – Andrey Tyukin Feb 11 '18 at 13:55
  • Please do not fundamentally change your question, it invalidates existing answer, and makes answering a moving target. If you run into a new problem, ask a new question (but search first)! – Mark Rotteveel Feb 14 '18 at 19:44

1 Answers1

1

Looks like summtion is empty.

From the javadoc for method max() of class java.util.Collections.

[throws] NoSuchElementException - if the collection is empty.

Abra
  • 19,142
  • 7
  • 29
  • 41
  • @abre why summution is empty here? if all values in summution contain zero values as it affect when compute the max between them. – sarah hamza Feb 11 '18 at 20:28
  • What is the size of the list `bfListt`? If it is empty, then your hashtable `hashhhTT` will also be empty and consequently `summtion` will be empty. Have you tried debugging your code? – Abra Feb 11 '18 at 20:49