Skip to content

Commit

Permalink
Merge pull request #566 from ashigeru/wip/refactor-0.8.0-3
Browse files Browse the repository at this point in the history
Fix code style.
  • Loading branch information
akirakw committed Jan 22, 2016
2 parents 776b64b + 284504e commit ac03cd9
Show file tree
Hide file tree
Showing 327 changed files with 1,750 additions and 1,438 deletions.
Expand Up @@ -55,9 +55,9 @@
import org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl;
import org.apache.hadoop.util.Progressable;

import com.asakusafw.runtime.compatibility.hadoop.CoreCompatibility.FrameworkVersion;
import com.asakusafw.runtime.compatibility.hadoop.JobCompatibilityHadoop;
import com.asakusafw.runtime.compatibility.hadoop.KeyValueConsumer;
import com.asakusafw.runtime.compatibility.hadoop.CoreCompatibility.FrameworkVersion;

/**
* Compatibility for job APIs (Hadoop {@code 2.x}).
Expand Down
Expand Up @@ -373,12 +373,7 @@ public int compareTo(NodePath o) {
return cmp;
}
}
if (a.size() > b.size()) {
return +1;
} else if (a.size() < b.size()) {
return -1;
}
return 0;
return Integer.compare(a.size(), b.size());
}
}
}
Expand Up @@ -110,11 +110,11 @@ public static BlockMap create(
Arrays.sort(blocks, new Comparator<BlockInfo>() {
@Override
public int compare(BlockInfo o1, BlockInfo o2) {
int startDiff = compareLong(o1.start, o2.start);
int startDiff = Long.compare(o1.start, o2.start);
if (startDiff != 0) {
return startDiff;
}
return -compareLong(o1.hosts.length, o2.hosts.length);
return Integer.compare(o2.hosts.length, o1.hosts.length);
}
});
long lastOffset = 0;
Expand Down Expand Up @@ -234,18 +234,9 @@ private List<Map.Entry<String, Long>> computeLocalityRank(long start, long end)
Collections.sort(entries, new Comparator<Map.Entry<String, Long>>() {
@Override
public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> o2) {
return -compareLong(o1.getValue(), o2.getValue());
return Long.compare(o2.getValue(), o1.getValue());
}
});
return entries;
}

static int compareLong(long offset1, long offset2) {
if (offset1 < offset2) {
return -1;
} else if (offset1 > offset2) {
return +1;
}
return 0;
}
}
Expand Up @@ -98,14 +98,7 @@ public List<TransactionInfo> list() throws IOException {
Collections.sort(list, new Comparator<FileStatus>() {
@Override
public int compare(FileStatus o1, FileStatus o2) {
long t1 = o1.getModificationTime();
long t2 = o2.getModificationTime();
if (t1 < t2) {
return -1;
} else if (t1 > t2) {
return +1;
}
return 0;
return Long.compare(o1.getModificationTime(), o2.getModificationTime());
}
});
LOG.info(MessageFormat.format(
Expand Down
Expand Up @@ -140,15 +140,7 @@ private boolean validFragments(BlockMap map, List<DirectInputFragment> results)
Collections.sort(results, new Comparator<DirectInputFragment>() {
@Override
public int compare(DirectInputFragment o1, DirectInputFragment o2) {
long i1 = o1.getOffset();
long i2 = o2.getOffset();
if (i1 < i2) {
return -1;
}
if (i1 > i2) {
return +1;
}
return 0;
return Long.compare(o1.getOffset(), o2.getOffset());
}
});
long expectedOffset = 0;
Expand Down
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -102,7 +103,7 @@ public final class HadoopDataSourceUtil {
/**
* Charset for commit mark file comments.
*/
public static final Charset COMMENT_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
public static final Charset COMMENT_CHARSET = StandardCharsets.UTF_8;

/**
* Loads a profile list from the configuration.
Expand Down
Expand Up @@ -61,7 +61,7 @@ public void add(LookUpKey key, T value) throws IOException {
}
List<T> list = entity.get(key.getDirectView());
if (list == null) {
list = new ArrayList<>();
list = new ArrayList<>(1);
entity.put(key.getFrozenView(), list);
}
list.add(value);
Expand Down
Expand Up @@ -25,6 +25,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;

import org.apache.hadoop.io.Text;
Expand All @@ -49,7 +50,7 @@
*/
public class TsvEmitter implements RecordEmitter {

private static final Charset TEXT_ENCODE = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset TEXT_ENCODE = StandardCharsets.UTF_8;

private static final int BUFFER_SIZE = 2048;

Expand Down
Expand Up @@ -21,6 +21,7 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
* An implementation of {@link ModelIoFactory} for using TSV files.
Expand All @@ -29,7 +30,7 @@
*/
public class TsvIoFactory<T> extends ModelIoFactory<T> {

private static final Charset CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset CHARSET = StandardCharsets.UTF_8;

/**
* Creates a new instance.
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -61,7 +62,7 @@ public final class TsvParser implements RecordParser {

private static final int SPECIAL_FLOAT_NEGATIVE_INF = 2;

private static final Charset TEXT_ENCODE = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset TEXT_ENCODE = StandardCharsets.UTF_8;

private static final int INITIAL_BUFFER_SIZE = 2048;

Expand Down
Expand Up @@ -16,6 +16,7 @@
package com.asakusafw.runtime.io.csv;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.List;
Expand All @@ -34,7 +35,7 @@ public class CsvConfiguration {
* The default charset encoding.
* @see #getCharset()
*/
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

/**
* The default header cells (empty list).
Expand Down
Expand Up @@ -17,6 +17,7 @@

import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;

/**
* Line based text configurations.
Expand All @@ -28,7 +29,7 @@ public class LineConfiguration {
* The default charset.
* @see #getCharset()
*/
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

/**
* The default buffer size hint in bytes.
Expand Down
Expand Up @@ -17,6 +17,7 @@

import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import com.asakusafw.runtime.io.ModelInput;
import com.asakusafw.runtime.value.StringOption;
Expand All @@ -27,7 +28,7 @@
*/
public abstract class LineInput implements ModelInput<StringOption> {

static final Charset INTERNAL_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
static final Charset INTERNAL_CHARSET = StandardCharsets.UTF_8;

/**
* Creates a new instance.
Expand Down
Expand Up @@ -17,6 +17,7 @@

import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import com.asakusafw.runtime.io.ModelOutput;
import com.asakusafw.runtime.value.StringOption;
Expand All @@ -27,7 +28,7 @@
*/
public abstract class LineOutput implements ModelOutput<StringOption> {

static final Charset INTERNAL_CHARSET = Charset.forName("UTF-8"); //$NON-NLS-1$
static final Charset INTERNAL_CHARSET = StandardCharsets.UTF_8;

static final char LINE_BREAK = '\n';

Expand Down
Expand Up @@ -18,6 +18,7 @@
import java.io.IOException;

import org.apache.hadoop.io.Writable;

import com.asakusafw.runtime.core.Result;
import com.asakusafw.runtime.flow.MapperWithRuntimeResource;
import com.asakusafw.runtime.stage.output.StageOutputDriver;
Expand Down
Expand Up @@ -737,15 +737,7 @@ private static final class LocationAndTime implements Comparable<LocationAndTime
}
@Override
public int compareTo(LocationAndTime o) {
double a = time;
double b = o.time;
if (a < b) {
return +1;
} else if (a > b) {
return -1;
} else {
return 0;
}
return Double.compare(time, o.time);
}
@Override
public int hashCode() {
Expand Down Expand Up @@ -870,15 +862,7 @@ private enum GeneComparator implements Comparator<Gene> {
;
@Override
public int compare(Gene o1, Gene o2) {
double a = o1.score;
double b = o2.score;
if (a < b) {
return -1;
} else if (a > b) {
return +1;
} else {
return 0;
}
return Double.compare(o1.score, o2.score);
}
}
}
Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -57,7 +58,7 @@ public final class StageInputDriver {

static final Log LOG = LogFactory.getLog(StageInputDriver.class);

private static final Charset ASCII = Charset.forName("ASCII"); //$NON-NLS-1$
private static final Charset ASCII = StandardCharsets.US_ASCII;

private static final long SERIAL_VERSION = 1;

Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -75,7 +76,7 @@ public final class BridgeOutputFormat extends OutputFormat<Object, Object> {

static final Log LOG = LogFactory.getLog(BridgeOutputFormat.class);

private static final Charset ASCII = Charset.forName("ASCII"); //$NON-NLS-1$
private static final Charset ASCII = StandardCharsets.US_ASCII;

private static final long SERIAL_VERSION = 1;

Expand Down
Expand Up @@ -19,6 +19,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Arrays;

Expand Down Expand Up @@ -55,7 +56,7 @@ public final class TemporaryFile {
*/
public static final int EMPTY_ENTRY_PADDING = 0;

private static final Charset ENCODING = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset ENCODING = StandardCharsets.UTF_8;

/**
* The maximum page size.
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.io.OutputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Arrays;

Expand All @@ -38,7 +39,7 @@ public final class ConfigurationDetecter {

static final String MARKER_FILE_NAME = "core-site.xml"; //$NON-NLS-1$

private static final Charset ENCODING = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset ENCODING = StandardCharsets.UTF_8;

private ConfigurationDetecter() {
return;
Expand Down
Expand Up @@ -21,6 +21,7 @@
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;

import org.apache.commons.logging.Log;
Expand All @@ -35,7 +36,7 @@ public class LocalFileLockProvider<T> implements LockProvider<T> {

static final Log LOG = LogFactory.getLog(LocalFileLockProvider.class);

private static final Charset ENCODING = Charset.forName("UTF-8"); //$NON-NLS-1$
private static final Charset ENCODING = StandardCharsets.UTF_8;

private final File baseDirectory;

Expand Down
Expand Up @@ -22,23 +22,11 @@
final class ByteArrayUtil {

static int compare(int a, int b) {
if (a == b) {
return 0;
}
if (a < b) {
return -1;
}
return +1;
return Integer.compare(a, b);
}

static int compare(long a, long b) {
if (a == b) {
return 0;
}
if (a < b) {
return -1;
}
return +1;
return Long.compare(a, b);
}

static short readShort(byte[] bytes, int offset) {
Expand Down

0 comments on commit ac03cd9

Please sign in to comment.