title: Implementing java.util.Map for big data
body: <p>I'm trying to implement a database backed <code>java.util.Map</code>, most of the interface like put and get was easily implemented however I am having trouble figuring out the best way to implement:</p>
  
  <pre><code>    @Override
      public Set&lt;K&gt; keySet() {
            // TODO Auto-generated method stub
             return null;
      }
  
      @Override
      public Collection&lt;V&gt; values() {
           // TODO Auto-generated method stub
           return null;
      }
  
      @Override
           public Set&lt;Map.Entry&lt;K, V&gt;&gt; entrySet() {
          // TODO Auto-generated method stub
          return null;
      } 
  </code></pre>
  
  <p>My concern would be that keys and values could count to millions records. So I don't think its memory and cpu efficient to fetch and store all "keys" or "values" when these methods are accessed. </p>
  
  <p>What are the options to implement a memory efficient way to implementing these? </p>
  
  <p>What is the strategy to implement an iterator for the entrySet? </p>