// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/DirectBufferProxy.java
// public static final BufferProxy<DirectBuffer> PROXY_DB
//     = new DirectBufferProxy();
// 
// Path: src/main/java/org/lmdbjava/Env.java
// public static Builder<ByteBuffer> create() {
//   return new Builder<>(PROXY_OPTIMAL);
// }
// 
// Path: src/main/java/org/lmdbjava/CursorIterable.java
// public static final class KeyVal<T> {
// 
//   private T k;
//   private T v;
// 
//   /**
//    * The key.
//    *
//    * @return key
//    */
//   public T key() {
//     return k;
//   }
// 
//   /**
//    * The value.
//    *
//    * @return value
//    */
//   public T val() {
//     return v;
//   }
// 
//   void setK(final T key) {
//     this.k = key;
//   }
// 
//   void setV(final T val) {
//     this.v = val;
//   }
// 
// }


import static java.nio.ByteBuffer.allocateDirect;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.DbiFlags.MDB_CREATE;
import static org.lmdbjava.DbiFlags.MDB_DUPSORT;
import static org.lmdbjava.DirectBufferProxy.PROXY_DB;
import static org.lmdbjava.Env.create;
import static org.lmdbjava.GetOp.MDB_SET;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_PREV;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService;
import org.agrona.DirectBuffer;
import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.lmdbjava.CursorIterable.KeyVal;
  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial6() throws IOException {
    // Note we need to specify the Verifier's DBI_COUNT for the Env.
    final Env<ByteBuffer> env = create(PROXY_OPTIMAL)
        .setMapSize(10_485_760)
        .setMaxDbs(Verifier.DBI_COUNT)
        .open(tmp.newFolder());

    // Create a Verifier (it's a Callable<Long> for those needing full control).
    final Verifier v = new Verifier(env);

    // We now run the verifier for 3 seconds; it raises an exception on failure.
    // The method returns the number of entries it successfully verified.
    v.runFor(3, SECONDS);

    env.close();
  }

  /**
   * In this final tutorial we'll look at using Agrona's DirectBuffer.
   *
   * @throws IOException if a path was unavailable for memory mapping
   */
  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial7() throws IOException {
    // The critical difference is we pass the PROXY_DB field to Env.create().
    // There's also a PROXY_SAFE if you want to stop ByteBuffer's Unsafe use.
    // Aside from that and a different type argument, it's the same as usual...
// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/DirectBufferProxy.java
// public static final BufferProxy<DirectBuffer> PROXY_DB
//     = new DirectBufferProxy();
// 
// Path: src/main/java/org/lmdbjava/Env.java
// public static Builder<ByteBuffer> create() {
//   return new Builder<>(PROXY_OPTIMAL);
// }
// 
// Path: src/main/java/org/lmdbjava/CursorIterable.java
// public static final class KeyVal<T> {
// 
//   private T k;
//   private T v;
// 
//   /**
//    * The key.
//    *
//    * @return key
//    */
//   public T key() {
//     return k;
//   }
// 
//   /**
//    * The value.
//    *
//    * @return value
//    */
//   public T val() {
//     return v;
//   }
// 
//   void setK(final T key) {
//     this.k = key;
//   }
// 
//   void setV(final T val) {
//     this.v = val;
//   }
// 
// }


// Path: src/test/java/org/lmdbjava/TutorialTest.java
import static java.nio.ByteBuffer.allocateDirect;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.DbiFlags.MDB_CREATE;
import static org.lmdbjava.DbiFlags.MDB_DUPSORT;
import static org.lmdbjava.DirectBufferProxy.PROXY_DB;
import static org.lmdbjava.Env.create;
import static org.lmdbjava.GetOp.MDB_SET;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_LAST;
import static org.lmdbjava.SeekOp.MDB_PREV;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService;
import org.agrona.DirectBuffer;
import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.lmdbjava.CursorIterable.KeyVal;

  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial6() throws IOException {
    // Note we need to specify the Verifier's DBI_COUNT for the Env.
    final Env<ByteBuffer> env = create(PROXY_OPTIMAL)
        .setMapSize(10_485_760)
        .setMaxDbs(Verifier.DBI_COUNT)
        .open(tmp.newFolder());

    // Create a Verifier (it's a Callable<Long> for those needing full control).
    final Verifier v = new Verifier(env);

    // We now run the verifier for 3 seconds; it raises an exception on failure.
    // The method returns the number of entries it successfully verified.
    v.runFor(3, SECONDS);

    env.close();
  }

  /**
   * In this final tutorial we'll look at using Agrona's DirectBuffer.
   *
   * @throws IOException if a path was unavailable for memory mapping
   */
  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial7() throws IOException {
    // The critical difference is we pass the PROXY_DB field to Env.create().
    // There's also a PROXY_SAFE if you want to stop ByteBuffer's Unsafe use.
    // Aside from that and a different type argument, it's the same as usual...
    final Env<DirectBuffer> env = create(PROXY_DB)