// 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;
/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package org.lmdbjava;




/**
 * Welcome to LmdbJava!
 *
 * <p>
 * This short tutorial will walk you through using LmdbJava step-by-step.
 *
 * <p>
 * If you are using a 64-bit Windows, Linux or OS X machine, you can simply run
 * this tutorial by adding the LmdbJava JAR to your classpath. It includes the
 * required system libraries. If you are using another 64-bit platform, you'll
 * need to install the LMDB system library yourself. 32-bit platforms are not
 * supported.
 */
public final class TutorialTest {

  private static final String DB_NAME = "my DB";
  @Rule
  public final TemporaryFolder tmp = new TemporaryFolder();

  /**
   * In this first tutorial we will use LmdbJava with some basic defaults.
   *
   * @throws IOException if a path was unavailable for memory mapping
   */
  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial1() throws IOException {
    // We need a storage directory first.
    // The path cannot be on a remote file system.
    final File path = tmp.newFolder();

    // We always need an Env. An Env owns a physical on-disk storage file. One
    // Env can store many different databases (ie sorted maps).
// 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;

/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package org.lmdbjava;




/**
 * Welcome to LmdbJava!
 *
 * <p>
 * This short tutorial will walk you through using LmdbJava step-by-step.
 *
 * <p>
 * If you are using a 64-bit Windows, Linux or OS X machine, you can simply run
 * this tutorial by adding the LmdbJava JAR to your classpath. It includes the
 * required system libraries. If you are using another 64-bit platform, you'll
 * need to install the LMDB system library yourself. 32-bit platforms are not
 * supported.
 */
public final class TutorialTest {

  private static final String DB_NAME = "my DB";
  @Rule
  public final TemporaryFolder tmp = new TemporaryFolder();

  /**
   * In this first tutorial we will use LmdbJava with some basic defaults.
   *
   * @throws IOException if a path was unavailable for memory mapping
   */
  @Test
  @SuppressWarnings("ConvertToTryWithResources")
  public void tutorial1() throws IOException {
    // We need a storage directory first.
    // The path cannot be on a remote file system.
    final File path = tmp.newFolder();

    // We always need an Env. An Env owns a physical on-disk storage file. One
    // Env can store many different databases (ie sorted maps).
    final Env<ByteBuffer> env = create()