Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.iq80.leveldb.impl;
  
  
 
 public class SeekingIteratorAdapter implements DBIterator
 {
     private final SnapshotSeekingIterator seekingIterator;
     private final AtomicBoolean closed = new AtomicBoolean(false);
 
     public SeekingIteratorAdapter(SnapshotSeekingIterator seekingIterator)
     {
         this. = seekingIterator;
     }
 
     @Override
     public void seekToFirst()
     {
         .seekToFirst();
     }
 
     @Override
     public void seek(byte[] targetKey)
     {
         .seek(Slices.wrappedBuffer(targetKey));
     }
 
     @Override
     public boolean hasNext()
     {
         return .hasNext();
     }
 
     @Override
     public DbEntry next()
     {
         return adapt(.next());
     }
 
     @Override
     public DbEntry peekNext()
     {
         return adapt(.peek());
     }
 
     @Override
     public void close()
     {
         // This is an end user API.. he might screw up and close multiple times.
         // but we don't want the close multiple times as reference counts go bad.
         if(.compareAndSet(falsetrue)) {
             .close();
         }
     }
 
     @Override
     public void remove()
     {
         throw new UnsupportedOperationException();
     }
 
     private DbEntry adapt(Entry<SliceSliceentry)
     {
         return new DbEntry(entry.getKey(), entry.getValue());
     }
 
     //
     // todo Implement reverse iterator
     //
 
 
     @Override
     public void seekToLast()
     {
         throw new UnsupportedOperationException();
     }
 
     @Override
     public boolean hasPrev()
     {
         throw new UnsupportedOperationException();
     }
 
     @Override
     public DbEntry prev()
     {
         throw new UnsupportedOperationException();
     }
 
     @Override
     public DbEntry peekPrev()
     {
         throw new UnsupportedOperationException();
     }
    public static class DbEntry implements Entry<byte[], byte[]>
    {
        private final Slice key;
        private final Slice value;
        public DbEntry(Slice keySlice value)
        {
            Preconditions.checkNotNull(key"key is null");
            Preconditions.checkNotNull(value"value is null");
            this. = key;
            this. = value;
        }
        @Override
        public byte[] getKey()
        {
            return .getBytes();
        }
        public Slice getKeySlice()
        {
            return ;
        }
        @Override
        public byte[] getValue()
        {
            return .getBytes();
        }
        public Slice getValueSlice()
        {
            return ;
        }
        @Override
        public byte[] setValue(byte[] value)
        {
            throw new UnsupportedOperationException();
        }
        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Entry) {
                Entry<?, ?> that = (Entry<?, ?>) object;
                return .equals(that.getKey()) &&
                        .equals(that.getValue());
            }
            return false;
        }
        @Override
        public int hashCode()
        {
            return .hashCode() ^ .hashCode();
        }

        
Returns a string representation of the form {key}={value}.
        @Override
        public String toString()
        {
            return  + "=" + ;
        }
    }
New to GrepCode? Check out our FAQ X