Skip to content

Commit

Permalink
Add code style checker and update to style
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Oct 31, 2014
1 parent 75b372c commit 05fffd4
Show file tree
Hide file tree
Showing 100 changed files with 1,253 additions and 835 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum CompressionType
NONE(0x00),
SNAPPY(0x01);

public static CompressionType getCompressionTypeByPersistentId(int persistentId) {
public static CompressionType getCompressionTypeByPersistentId(int persistentId)
{
for (CompressionType compressionType : CompressionType.values()) {
if (compressionType.persistentId == persistentId) {
return compressionType;
Expand Down
47 changes: 31 additions & 16 deletions leveldb-api/src/main/java/org/iq80/leveldb/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,63 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DB extends Iterable<Map.Entry<byte[], byte[]>>, Closeable {
public interface DB
extends Iterable<Map.Entry<byte[], byte[]>>, Closeable
{
public byte[] get(byte[] key)
throws DBException;

public byte[] get(byte[] key) throws DBException;
public byte[] get(byte[] key, ReadOptions options) throws DBException;
public byte[] get(byte[] key, ReadOptions options)
throws DBException;

public DBIterator iterator();

public DBIterator iterator(ReadOptions options);

public void put(byte[] key, byte[] value) throws DBException;
public void delete(byte[] key) throws DBException;
public void write(WriteBatch updates) throws DBException;
public void put(byte[] key, byte[] value)
throws DBException;

public void delete(byte[] key)
throws DBException;

public void write(WriteBatch updates)
throws DBException;

public WriteBatch createWriteBatch();

/**
* @return null if options.isSnapshot()==false otherwise returns a snapshot
* of the DB after this operation.
* of the DB after this operation.
*/
public Snapshot put(byte[] key, byte[] value, WriteOptions options) throws DBException;
public Snapshot put(byte[] key, byte[] value, WriteOptions options)
throws DBException;

/**
* @return null if options.isSnapshot()==false otherwise returns a snapshot
* of the DB after this operation.
* of the DB after this operation.
*/
public Snapshot delete(byte[] key, WriteOptions options) throws DBException;
public Snapshot delete(byte[] key, WriteOptions options)
throws DBException;

/**
* @return null if options.isSnapshot()==false otherwise returns a snapshot
* of the DB after this operation.
* of the DB after this operation.
*/
public Snapshot write(WriteBatch updates, WriteOptions options) throws DBException;
public Snapshot write(WriteBatch updates, WriteOptions options)
throws DBException;

public Snapshot getSnapshot();

public long[] getApproximateSizes(Range ... ranges);
public long[] getApproximateSizes(Range... ranges);

public String getProperty(String name);

/**
* Suspends any background compaction threads. This methods
* returns once the background compactions are suspended.
*/
public void suspendCompactions() throws InterruptedException;
public void suspendCompactions()
throws InterruptedException;

/**
* Resumes the background compaction threads.
Expand All @@ -76,7 +91,7 @@ public interface DB extends Iterable<Map.Entry<byte[], byte[]>>, Closeable {
*
* @param begin if null then compaction start from the first key
* @param end if null then compaction ends at the last key
* @throws DBException
*/
public void compactRange(byte[] begin, byte[] end) throws DBException;
public void compactRange(byte[] begin, byte[] end)
throws DBException;
}
12 changes: 3 additions & 9 deletions leveldb-api/src/main/java/org/iq80/leveldb/DBComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,20 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DBComparator extends Comparator<byte[]>{

public interface DBComparator
extends Comparator<byte[]>
{
public String name();

/**
* If <code>start < limit</code>, returns a short key in [start,limit).
* Simple comparator implementations should return start unchanged,
*
* @param start
* @param limit
* @return
*/
byte[] findShortestSeparator(byte[] start, byte[] limit);

/**
* returns a 'short key' where the 'short key' >= key.
* Simple comparator implementations should return key unchanged,
*
* @param key
*/
byte[] findShortSuccessor(byte[] key);

}
16 changes: 11 additions & 5 deletions leveldb-api/src/main/java/org/iq80/leveldb/DBException.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public class DBException extends RuntimeException {
public DBException() {
public class DBException
extends RuntimeException
{
public DBException()
{
}

public DBException(String s) {
public DBException(String s)
{
super(s);
}

public DBException(String s, Throwable throwable) {
public DBException(String s, Throwable throwable)
{
super(s, throwable);
}

public DBException(Throwable throwable) {
public DBException(Throwable throwable)
{
super(throwable);
}
}
14 changes: 8 additions & 6 deletions leveldb-api/src/main/java/org/iq80/leveldb/DBFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DBFactory {
public interface DBFactory
{
public DB open(File path, Options options)
throws IOException;

public DB open(File path, Options options) throws IOException;

public void destroy(File path, Options options) throws IOException;

public void repair(File path, Options options) throws IOException;
public void destroy(File path, Options options)
throws IOException;

public void repair(File path, Options options)
throws IOException;
}
6 changes: 3 additions & 3 deletions leveldb-api/src/main/java/org/iq80/leveldb/DBIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface DBIterator extends Iterator<Map.Entry<byte[], byte[]>>, Closeable {

public interface DBIterator
extends Iterator<Map.Entry<byte[], byte[]>>, Closeable
{
/**
* Repositions the iterator so the key of the next BlockElement
* returned greater than or equal to the specified targetKey.
Expand Down Expand Up @@ -61,5 +62,4 @@ public interface DBIterator extends Iterator<Map.Entry<byte[], byte[]>>, Closeab
* Repositions the iterator so it is at the end of of the Database.
*/
public void seekToLast();

}
5 changes: 2 additions & 3 deletions leveldb-api/src/main/java/org/iq80/leveldb/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface Logger {

public interface Logger
{
public void log(String message);

}
36 changes: 22 additions & 14 deletions leveldb-api/src/main/java/org/iq80/leveldb/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package org.iq80.leveldb;

public class Options {

public class Options
{
private boolean createIfMissing = true;
private boolean errorIfExists;
private int writeBufferSize = 4 << 20;
Expand All @@ -34,9 +34,10 @@ public class Options {
private Logger logger = null;
private long cacheSize;

static void checkArgNotNull(Object value, String name) {
if(value==null) {
throw new IllegalArgumentException("The "+name+" argument cannot be null");
static void checkArgNotNull(Object value, String name)
{
if (value == null) {
throw new IllegalArgumentException("The " + name + " argument cannot be null");
}
}

Expand Down Expand Up @@ -129,39 +130,46 @@ public Options verifyChecksums(boolean verifyChecksums)
return this;
}


public long cacheSize() {
public long cacheSize()
{
return cacheSize;
}

public Options cacheSize(long cacheSize) {
public Options cacheSize(long cacheSize)
{
this.cacheSize = cacheSize;
return this;
}

public DBComparator comparator() {
public DBComparator comparator()
{
return comparator;
}

public Options comparator(DBComparator comparator) {
public Options comparator(DBComparator comparator)
{
this.comparator = comparator;
return this;
}

public Logger logger() {
public Logger logger()
{
return logger;
}

public Options logger(Logger logger) {
public Options logger(Logger logger)
{
this.logger = logger;
return this;
}

public boolean paranoidChecks() {
public boolean paranoidChecks()
{
return paranoidChecks;
}

public Options paranoidChecks(boolean paranoidChecks) {
public Options paranoidChecks(boolean paranoidChecks)
{
this.paranoidChecks = paranoidChecks;
return this;
}
Expand Down
18 changes: 10 additions & 8 deletions leveldb-api/src/main/java/org/iq80/leveldb/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public class Range {
public class Range
{
private final byte[] start;
private final byte[] limit;

final private byte[] start;
final private byte[] limit;

public byte[] limit() {
public byte[] limit()
{
return limit;
}

public byte[] start() {
public byte[] start()
{
return start;
}

public Range(byte[] start, byte[] limit) {
public Range(byte[] start, byte[] limit)
{
Options.checkArgNotNull(start, "start");
Options.checkArgNotNull(limit, "limit");
this.limit = limit;
this.start = start;
}

}
12 changes: 8 additions & 4 deletions leveldb-api/src/main/java/org/iq80/leveldb/ReadOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ public ReadOptions snapshot(Snapshot snapshot)
return this;
}

public boolean fillCache() {
public boolean fillCache()
{
return fillCache;
}

public ReadOptions fillCache(boolean fillCache) {
public ReadOptions fillCache(boolean fillCache)
{
this.fillCache = fillCache;
return this;
}

public boolean verifyChecksums() {
public boolean verifyChecksums()
{
return verifyChecksums;
}

public ReadOptions verifyChecksums(boolean verifyChecksums) {
public ReadOptions verifyChecksums(boolean verifyChecksums)
{
this.verifyChecksums = verifyChecksums;
return this;
}
Expand Down
5 changes: 3 additions & 2 deletions leveldb-api/src/main/java/org/iq80/leveldb/Snapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.Closeable;

public interface Snapshot extends Closeable {

public interface Snapshot
extends Closeable
{
}
6 changes: 4 additions & 2 deletions leveldb-api/src/main/java/org/iq80/leveldb/WriteBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public interface WriteBatch extends Closeable {

public interface WriteBatch
extends Closeable
{
public WriteBatch put(byte[] key, byte[] value);

public WriteBatch delete(byte[] key);
}
Loading

0 comments on commit 05fffd4

Please sign in to comment.