Skip to content

Commit

Permalink
Merge pull request #18 from andrewgaul/closeable
Browse files Browse the repository at this point in the history
Use standard Closeable instead of custom Closable
  • Loading branch information
chirino committed May 25, 2012
2 parents 0467761 + cdbd442 commit 1715f96
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 36 deletions.
27 changes: 0 additions & 27 deletions leveldb-api/src/main/java/org/iq80/leveldb/Closable.java

This file was deleted.

3 changes: 2 additions & 1 deletion leveldb-api/src/main/java/org/iq80/leveldb/DB.java
Expand Up @@ -17,12 +17,13 @@
*/
package org.iq80.leveldb;

import java.io.Closeable;
import java.util.Map;

/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DB extends Iterable<Map.Entry<byte[], byte[]>>, Closable {
public interface DB extends Iterable<Map.Entry<byte[], byte[]>>, Closeable {

public byte[] get(byte[] key) throws DBException;
public byte[] get(byte[] key, ReadOptions options) throws DBException;
Expand Down
3 changes: 2 additions & 1 deletion leveldb-api/src/main/java/org/iq80/leveldb/DBIterator.java
Expand Up @@ -17,13 +17,14 @@
*/
package org.iq80.leveldb;

import java.io.Closeable;
import java.util.Iterator;
import java.util.Map;

/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DBIterator extends Iterator<Map.Entry<byte[], byte[]>>, Closable {
public interface DBIterator extends Iterator<Map.Entry<byte[], byte[]>>, Closeable {

/**
* Repositions the iterator so the key of the next BlockElement
Expand Down
4 changes: 3 additions & 1 deletion leveldb-api/src/main/java/org/iq80/leveldb/Snapshot.java
Expand Up @@ -17,6 +17,8 @@
*/
package org.iq80.leveldb;

public interface Snapshot extends Closable {
import java.io.Closeable;

public interface Snapshot extends Closeable {

}
4 changes: 3 additions & 1 deletion leveldb-api/src/main/java/org/iq80/leveldb/WriteBatch.java
Expand Up @@ -17,10 +17,12 @@
*/
package org.iq80.leveldb;

import java.io.Closeable;

/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface WriteBatch extends Closable {
public interface WriteBatch extends Closeable {

public WriteBatch put(byte[] key, byte[] value);
public WriteBatch delete(byte[] key);
Expand Down
9 changes: 4 additions & 5 deletions leveldb/src/test/java/org/iq80/leveldb/DbBenchmark.java
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.io.CharStreams;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.iq80.leveldb.impl.DbImpl;
import org.iq80.leveldb.util.*;
Expand Down Expand Up @@ -440,7 +441,7 @@ private void readSequential()
bytes_ += entry.getKey().length + entry.getValue().length;
finishedSingleOp();
}
iterator.close();
Closeables.closeQuietly(iterator);
}
}

Expand Down Expand Up @@ -603,10 +604,8 @@ private void heapProfile()

private void destroyDb()
{
if (db_ != null) {
db_.close();
db_ = null;
}
Closeables.closeQuietly(db_);
db_ = null;
FileUtils.deleteRecursively(databaseDir);
}

Expand Down

0 comments on commit 1715f96

Please sign in to comment.