Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Add linter to arcanist config. Fix whitespace errors
Browse files Browse the repository at this point in the history
Summary:
Arcanist text linter to detect basic formatting problems like
tabs and trailing whitespace.

Clean up whitespace errors to avoid noise in future diffs
from whitespace fixes

Test Plan: Still compiles ok

Reviewers: emayanke, dhruba

Reviewed By: emayanke

Differential Revision: https://reviews.facebook.net/D8301
  • Loading branch information
Tim Armstrong committed Mar 6, 2013
1 parent e9c7573 commit 6e20176
Show file tree
Hide file tree
Showing 73 changed files with 1,238 additions and 1,235 deletions.
4 changes: 3 additions & 1 deletion .arcconfig
@@ -1,6 +1,8 @@
{
"project_id" : "linkbench",
"conduit_uri" : "https://reviews.facebook.net/",
"copyright_holder" : ""
"copyright_holder" : "",
"lint.engine" : "ArcanistSingleLintEngine",
"lint.engine.single.linter" : "ArcanistTextLinter"
}

24 changes: 12 additions & 12 deletions src/java/com/facebook/LinkBench/Config.java
Expand Up @@ -24,17 +24,17 @@
public class Config {

public static final String DEBUGLEVEL = "debuglevel";

/* Control store implementations used */
public static final String LINKSTORE_CLASS = "linkstore";
public static final String NODESTORE_CLASS = "nodestore";

/* Schema and tables used */
public static final String DBID = "dbid";
public static final String LINK_TABLE = "linktable";
public static final String COUNT_TABLE = "counttable";
public static final String NODE_TABLE = "nodetable";

/* Control graph structure */
public static final String LOAD_RANDOM_SEED = "load_random_seed";
public static final String MIN_ID = "startid1";
Expand All @@ -46,7 +46,7 @@ public class Config {
public static final String NLINKS_CONFIG = "nlinks_config";
public static final String NLINKS_DEFAULT = "nlinks_default";
public static final String LINK_TYPE_COUNT ="link_type_count";

/* Data generation */
public static final String LINK_DATASIZE = "link_datasize";
public static final String NODE_DATASIZE = "node_datasize";
Expand All @@ -69,11 +69,11 @@ public class Config {
/* Loading performance tuning */
public static final String NUM_LOADERS = "loaders";
public static final String LOADER_CHUNK_SIZE = "loader_chunk_size";

/* Request workload */
public static final String NUM_REQUESTERS = "requesters";
public static final String REQUEST_RANDOM_SEED = "request_random_seed";

// Distribution of accesses to IDs
public static final String READ_CONFIG_PREFIX = "read_";
public static final String WRITE_CONFIG_PREFIX = "write_";
Expand All @@ -93,11 +93,11 @@ public class Config {
public static final String WRITE_UNCORR_FUNCTION = WRITE_UNCORR_CONFIG_PREFIX
+ ACCESS_FUNCTION_SUFFIX;
public static final String BLEND_SUFFIX = "blend";
public static final String READ_UNCORR_BLEND = READ_UNCORR_CONFIG_PREFIX
public static final String READ_UNCORR_BLEND = READ_UNCORR_CONFIG_PREFIX
+ BLEND_SUFFIX;
public static final String WRITE_UNCORR_BLEND = WRITE_UNCORR_CONFIG_PREFIX
+ BLEND_SUFFIX;

// Probability of different operations
public static final String PR_ADD_LINK = "addlink";
public static final String PR_DELETE_LINK = "deletelink";
Expand All @@ -120,20 +120,20 @@ public class Config {
public static final String LINK_MULTIGET_DIST_MIN = "link_multiget_dist_min";
public static final String LINK_MULTIGET_DIST_MAX = "link_multiget_dist_max";
public static final String LINK_MULTIGET_DIST_PREFIX = "link_multiget_dist_";

/* Probability distribution parameters */
public static final String PROB_MEAN = "mean";

/* Statistics collection and reporting */
public static final String MAX_STAT_SAMPLES = "maxsamples";
public static final String DISPLAY_FREQ = "displayfreq";
public static final String MAPRED_REPORT_PROGRESS = "reportprogress";
public static final String PROGRESS_FREQ = "progressfreq";

/* Reporting for progress indicators */
public static String REQ_PROG_INTERVAL = "req_progress_interval";
public static String LOAD_PROG_INTERVAL = "load_progress_interval";

/* MapReduce specific configuration */
public static final String TEMPDIR = "tempdir";
public static final String LOAD_DATA = "loaddata";
Expand Down
66 changes: 33 additions & 33 deletions src/java/com/facebook/LinkBench/ConfigUtil.java
Expand Up @@ -29,9 +29,9 @@
public class ConfigUtil {
public static final String linkbenchHomeEnvVar = "LINKBENCH_HOME";
public static final String LINKBENCH_LOGGER = "com.facebook.linkbench";

/**
* @return null if not set, or if not valid path
* @return null if not set, or if not valid path
*/
public static String findLinkBenchHome() {
String linkBenchHome = System.getenv("LINKBENCH_HOME");
Expand All @@ -43,18 +43,18 @@ public static String findLinkBenchHome() {
}
return null;
}

public static Level getDebugLevel(Properties props)
throws LinkBenchConfigError {
if (props == null) {
return Level.DEBUG;
}
String levStr = props.getProperty(Config.DEBUGLEVEL);

if (levStr == null) {
return Level.DEBUG;
}

try {
int level = Integer.parseInt(levStr);
if (level <= 0) {
Expand All @@ -69,19 +69,19 @@ public static Level getDebugLevel(Properties props)
if (lev != null) {
return lev;
} else {
throw new LinkBenchConfigError("Invalid setting for debug level: " +
throw new LinkBenchConfigError("Invalid setting for debug level: " +
levStr);
}
}
}
}

/**
* Setup log4j to log to stderr with a timestamp and thread id
* Could add in configuration from file later if it was really necessary
* @param props
* @param props
* @param logFile if not null, info logging will be diverted to this file
* @throws IOException
* @throws Exception
* @throws IOException
* @throws Exception
*/
public static void setupLogging(Properties props, String logFile)
throws LinkBenchConfigError, IOException {
Expand All @@ -91,17 +91,17 @@ public static void setupLogging(Properties props, String logFile)
Logger lbLogger = Logger.getLogger(LINKBENCH_LOGGER);
lbLogger.setLevel(logLevel);
ConsoleAppender console = new ConsoleAppender(fmt, "System.err");
/* If logfile is specified, put full stream in logfile and only
* print important messages to terminal

/* If logfile is specified, put full stream in logfile and only
* print important messages to terminal
*/
if (logFile != null) {
console.setThreshold(Level.WARN); // Only print salient messages
lbLogger.addAppender(new FileAppender(fmt, logFile));
}
lbLogger.addAppender(console);
}

/**
* Look up key in props, failing if not present
* @param props
Expand All @@ -118,12 +118,12 @@ public static String getPropertyRequired(Properties props, String key)
}
return v;
}

public static int getInt(Properties props, String key)
throws LinkBenchConfigError {
return getInt(props, key, null);
}

/**
* Retrieve a config key and convert to integer
* @param props
Expand All @@ -137,19 +137,19 @@ public static int getInt(Properties props, String key, Integer defaultVal)
return defaultVal;
}
String v = getPropertyRequired(props, key);
try {
try {
return Integer.parseInt(v);
} catch (NumberFormatException e) {
throw new LinkBenchConfigError("Expected configuration key " + key +
throw new LinkBenchConfigError("Expected configuration key " + key +
" to be integer, but was '" + v + "'");
}
}

public static long getLong(Properties props, String key)
throws LinkBenchConfigError {
return getLong(props, key, null);
return getLong(props, key, null);
}

/**
* Retrieve a config key and convert to long integer
* @param props
Expand All @@ -164,20 +164,20 @@ public static long getLong(Properties props, String key, Long defaultVal)
return defaultVal;
}
String v = getPropertyRequired(props, key);
try {
try {
return Long.parseLong(v);
} catch (NumberFormatException e) {
throw new LinkBenchConfigError("Expected configuration key " + key +
throw new LinkBenchConfigError("Expected configuration key " + key +
" to be long integer, but was '" + v + "'");
}
}
public static double getDouble(Properties props, String key)


public static double getDouble(Properties props, String key)
throws LinkBenchConfigError {
return getDouble(props, key, null);
}

/**
* Retrieve a config key and convert to double
* @param props
Expand All @@ -192,17 +192,17 @@ public static double getDouble(Properties props, String key,
return defaultVal;
}
String v = getPropertyRequired(props, key);
try {
try {
return Double.parseDouble(v);
} catch (NumberFormatException e) {
throw new LinkBenchConfigError("Expected configuration key " + key +
throw new LinkBenchConfigError("Expected configuration key " + key +
" to be double, but was '" + v + "'");
}
}

/**
* Retrieve a config key and convert to boolean.
* Valid boolean strings are "true" or "false", case insensitive
* Valid boolean strings are "true" or "false", case insensitive
* @param props
* @param key
* @return
Expand All @@ -217,7 +217,7 @@ public static boolean getBool(Properties props, String key)
} else if (v.equals("false")) {
return false;
} else {
throw new LinkBenchConfigError("Expected configuration key " + key +
throw new LinkBenchConfigError("Expected configuration key " + key +
" to be true or false, but was '" + v + "'");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/java/com/facebook/LinkBench/GraphStore.java
Expand Up @@ -18,7 +18,7 @@
import java.util.List;

/**
* An abstract class for storing both nodes and edges
* An abstract class for storing both nodes and edges
* @author tarmstrong
*/
public abstract class GraphStore extends LinkStore implements NodeStore {
Expand Down
20 changes: 10 additions & 10 deletions src/java/com/facebook/LinkBench/InvertibleShuffler.java
Expand Up @@ -21,13 +21,13 @@
* Shuffler designed to make computing permutation and inverse easy
*/
public class InvertibleShuffler {
private final long[] params;
private final long[] params;
private final int shuffleGroups;
long n;
long nRoundedUp; // n rounded up to next multiple of shuffleGroups
long nRoundedDown; // n rounded down to next multiple of shuffleGroups
int minGroupSize;

public InvertibleShuffler(long seed, int shuffleGroups, long n) {
this(new Random(seed), shuffleGroups, n);
}
Expand All @@ -40,34 +40,34 @@ public InvertibleShuffler(Random rng, int shuffleGroups, long n) {
this.n = n;
this.params = new long[shuffleGroups];
this.minGroupSize = (int)n / shuffleGroups;

for (int i = 0; i < shuffleGroups; i++) {
// Positive long
params[i] = Math.abs(rng.nextInt(minGroupSize));
}
this.nRoundedDown = (n / shuffleGroups) * shuffleGroups;
this.nRoundedDown = (n / shuffleGroups) * shuffleGroups;
this.nRoundedUp = n == nRoundedDown ? n : nRoundedDown + shuffleGroups;
}

public long permute(long i) {
return permute(i, false);
}

public long invertPermute(long i) {
return permute(i, true);
}

public long permute(long i, boolean inverse) {
if (i < 0 || i >= n) {
throw new IllegalArgumentException("Bad index to permute: " + i
+ ": out of range [0:" + (n - 1) + "]");
}
// Number of the group
int group = (int) (i % shuffleGroups);

// Whether this is a big or small group
boolean bigGroup = group < n % shuffleGroups;

// Calculate the (positive) rotation
long rotate = params[group];
if (inverse) {
Expand All @@ -79,7 +79,7 @@ public long permute(long i, boolean inverse) {
}
assert(rotate >= 0);
}

long j = (i + shuffleGroups * rotate);
long result;
if (j < n) {
Expand Down
10 changes: 5 additions & 5 deletions src/java/com/facebook/LinkBench/Link.java
Expand Up @@ -48,14 +48,14 @@ public boolean equals(Object other) {
return false;
}
}

public String toString() {
return String.format("Link(id1=%d, id2=%d, link_type=%d," +
"visibility=%d, version=%d," +
"time=%d, data=%s", id1, id2, link_type,
visibility, version, time, data.toString());
"visibility=%d, version=%d," +
"time=%d, data=%s", id1, id2, link_type,
visibility, version, time, data.toString());
}

/**
* Clone an existing link
* @param l
Expand Down

0 comments on commit 6e20176

Please sign in to comment.