Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragkh committed Oct 17, 2016
1 parent d3c2011 commit 33477e5
Show file tree
Hide file tree
Showing 100 changed files with 1,118 additions and 1,072 deletions.
2 changes: 1 addition & 1 deletion assembly/src/main/assembly/assembly.xml
@@ -1,6 +1,6 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>assembly</id>
<formats>
Expand Down
24 changes: 12 additions & 12 deletions core/src/main/java/edu/berkeley/cs/succinct/SuccinctCore.java
Expand Up @@ -11,6 +11,7 @@ public abstract class SuccinctCore implements Serializable {

// Logger
public final static Logger LOG = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);

static {
final Handler consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(new Formatter() {
Expand All @@ -24,6 +25,8 @@ public String format(LogRecord record) {
LOG.setLevel(Level.OFF);
}

// Alphabet map
protected transient int[] alphabet;
// Metadata
private transient int originalSize;
private transient int alphabetSize;
Expand All @@ -32,9 +35,6 @@ public String format(LogRecord record) {
private transient int samplingRateNPA;
private transient int sampleBitWidth;

// Alphabet map
protected transient int[] alphabet;

public SuccinctCore() {
}

Expand Down Expand Up @@ -138,22 +138,22 @@ public int getSampleBitWidth() {
}

/**
* Find a character in the alphabet.
* Set the sample bit width.
*
* @param c The character to find.
* @return The position of the character in the alphabet (if it exists), -ve value otherwise.
* @param sampleBitWidth The sample bit width to set.
*/
public int findCharacter(int c) {
return Arrays.binarySearch(alphabet, 1, alphabet.length, c);
public void setSampleBitWidth(int sampleBitWidth) {
this.sampleBitWidth = sampleBitWidth;
}

/**
* Set the sample bit width.
* Find a character in the alphabet.
*
* @param sampleBitWidth The sample bit width to set.
* @param c The character to find.
* @return The position of the character in the alphabet (if it exists), -ve value otherwise.
*/
public void setSampleBitWidth(int sampleBitWidth) {
this.sampleBitWidth = sampleBitWidth;
public int findCharacter(int c) {
return Arrays.binarySearch(alphabet, 1, alphabet.length, c);
}

protected int baseSize() {
Expand Down
Expand Up @@ -44,8 +44,8 @@ public interface SuccinctIndexedFile extends SuccinctFile {
* Get random access into record.
*
* @param recordId The record id.
* @param offset Offset into record.
* @param length Number of bytes to fetch.
* @param offset Offset into record.
* @param length Number of bytes to fetch.
* @return The extracted data.
*/
byte[] extractRecordBytes(int recordId, int offset, int length);
Expand All @@ -62,8 +62,8 @@ public interface SuccinctIndexedFile extends SuccinctFile {
* Get random access into record.
*
* @param recordId The record id.
* @param offset Offset into record.
* @param length Number of bytes to fetch.
* @param offset Offset into record.
* @param length Number of bytes to fetch.
* @return The extracted data.
*/
String extractRecord(int recordId, int offset, int length);
Expand Down
Expand Up @@ -47,10 +47,6 @@ public SuccinctBuffer() {
super();
}

@Override public int getCoreSize() {
return core.limit();
}

/**
* Constructor to initialize SuccinctCore from input byte array.
*
Expand Down Expand Up @@ -139,6 +135,10 @@ public SuccinctBuffer(ByteBuffer buf) {
mapFromCore();
}

@Override public int getCoreSize() {
return core.limit();
}

/**
* Lookup NPA at specified index.
*
Expand Down
Expand Up @@ -201,8 +201,7 @@ public SuccinctFileBuffer() {
s = lookupNPA(s);
int byte1 = lookupC(s);

return (short) ((byte0 << 8) |
(byte1 & 0xFF));
return (short) ((byte0 << 8) | (byte1 & 0xFF));
}

/**
Expand Down
Expand Up @@ -112,7 +112,8 @@ public static void main(String[] args) throws IOException {
results.put(result.getOffset(), result.getLength());
}
} catch (RegExParsingException e) {
System.err.println("Could not parse regular expression: [" + cmdArray[1] + "]: " + e.getMessage());
System.err.println(
"Could not parse regular expression: [" + cmdArray[1] + "]: " + e.getMessage());
continue;
}
System.out.println("Result size = " + results.size());
Expand Down
Expand Up @@ -78,13 +78,11 @@ public boolean contains(RegExMatch r) {
return r.begin() >= begin() && r.end() <= end();
}

@Override
public String toString() {
@Override public String toString() {
return "(" + offset + ", " + length + ")";
}

@Override
public int compareTo(RegExMatch o) {
@Override public int compareTo(RegExMatch o) {
if (offset == o.getOffset()) {
return length - o.getLength();
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ public class SuccinctRegEx {
* @throws RegExParsingException
*/
public SuccinctRegEx(SuccinctFile succinctFile, String regExString, boolean greedy)
throws RegExParsingException {
throws RegExParsingException {
this.succinctFile = succinctFile;
this.regExString = regExString;
this.regEx = parse();
Expand Down
Expand Up @@ -21,7 +21,7 @@ public SuccinctRegExMatch(long first, long second, int length) {
/**
* Constructor to initialize Regex Match.
*
* @param range Input range.
* @param range Input range.
* @param length Length of the match.
*/
public SuccinctRegExMatch(Range range, int length) {
Expand Down
Expand Up @@ -17,16 +17,12 @@ public abstract class RegExExecutor {
protected TreeSet<RegExMatch> finalResults;
protected boolean greedy;

enum SortType {
FRONT_SORTED,
END_SORTED
}

/**
* Constructor to initialize RegExExecutor.
*
* @param succinctFile The input SuccinctFile.
* @param regEx The input regular expression.
* @param regEx The input regular expression.
*/
RegExExecutor(SuccinctFile succinctFile, RegEx regEx, boolean greedy) {
this.succinctFile = succinctFile;
Expand Down Expand Up @@ -100,7 +96,8 @@ protected TreeSet<RegExMatch> regexWildcard(TreeSet<RegExMatch> left, TreeSet<Re

// Greedy match
RegExMatch lastMatch = null;
while (rightEntry != null && succinctFile.sameRecord(leftEntry.getOffset(), rightEntry.getOffset())) {
while (rightEntry != null && succinctFile
.sameRecord(leftEntry.getOffset(), rightEntry.getOffset())) {
lastMatch = rightEntry;
rightEntry = right.higher(rightEntry);
}
Expand All @@ -117,4 +114,9 @@ protected TreeSet<RegExMatch> regexWildcard(TreeSet<RegExMatch> left, TreeSet<Re

return wildcardRes;
}

enum SortType {
FRONT_SORTED,
END_SORTED
}
}
Expand Up @@ -140,7 +140,8 @@ private HashSet<SuccinctRegExMatch> regexConcat(RegEx r, SuccinctRegExMatch righ
String mgram = p.getPrimitiveStr();
Range range = succinctFile.continueBwdSearch(mgram.toCharArray(), rightMatch);
if (!range.empty()) {
concatResults.add(new SuccinctRegExMatch(range, rightMatch.getLength() + mgram.length()));
concatResults
.add(new SuccinctRegExMatch(range, rightMatch.getLength() + mgram.length()));
}
break;
}
Expand Down Expand Up @@ -225,13 +226,14 @@ private HashSet<SuccinctRegExMatch> computeSeedToRepeat(RegEx r) {
if (!greedy)
return results;

TreeSet<SuccinctRegExMatch> initialRepeats = new TreeSet<>(new Comparator<SuccinctRegExMatch>() {
@Override public int compare(SuccinctRegExMatch o1, SuccinctRegExMatch o2) {
return (int) (o1.begin() - o2.begin());
}
});
TreeSet<SuccinctRegExMatch> initialRepeats =
new TreeSet<>(new Comparator<SuccinctRegExMatch>() {
@Override public int compare(SuccinctRegExMatch o1, SuccinctRegExMatch o2) {
return (int) (o1.begin() - o2.begin());
}
});

for (SuccinctRegExMatch result: results) {
for (SuccinctRegExMatch result : results) {
initialRepeats.addAll(regexConcat(r, result));
}

Expand All @@ -251,7 +253,7 @@ private HashSet<SuccinctRegExMatch> computeSeedToRepeat(RegEx r) {
} else {
// Remove subrange.
HashSet<SuccinctRegExMatch> newSubRanges = new HashSet<>();
for (Iterator<SuccinctRegExMatch> i = results.iterator(); i.hasNext();) {
for (Iterator<SuccinctRegExMatch> i = results.iterator(); i.hasNext(); ) {
SuccinctRegExMatch match = i.next();
if (match.contains(start, end)) {
i.remove();
Expand All @@ -274,7 +276,7 @@ private HashSet<SuccinctRegExMatch> computeSeedToRepeat(RegEx r) {

// Remove subrange.
HashSet<SuccinctRegExMatch> newSubRanges = new HashSet<>();
for (Iterator<SuccinctRegExMatch> i = results.iterator(); i.hasNext();) {
for (Iterator<SuccinctRegExMatch> i = results.iterator(); i.hasNext(); ) {
SuccinctRegExMatch match = i.next();
if (match.contains(start, end)) {
i.remove();
Expand Down Expand Up @@ -316,7 +318,7 @@ private HashSet<SuccinctRegExMatch> regexRepeatOneOrMore(RegEx r) {
/**
* Repeat regular expression one or more times given right match.
*
* @param r The regular expression.
* @param r The regular expression.
* @param rightMatch The right match.
* @return The results for repeat.
*/
Expand All @@ -341,11 +343,12 @@ private HashSet<SuccinctRegExMatch> regexRepeatOneOrMore(RegEx r, SuccinctRegExM
/**
* Repeat regular expression zero or more times given right match.
*
* @param r The regular expression.
* @param r The regular expression.
* @param rightMatch The right match.
* @return The results for repeat.
*/
private HashSet<SuccinctRegExMatch> regexRepeatZeroOrMore(RegEx r, SuccinctRegExMatch rightMatch) {
private HashSet<SuccinctRegExMatch> regexRepeatZeroOrMore(RegEx r,
SuccinctRegExMatch rightMatch) {
HashSet<SuccinctRegExMatch> repeatResults = new HashSet<>();
if (rightMatch.empty()) {
return repeatResults;
Expand Down Expand Up @@ -389,10 +392,10 @@ private HashSet<SuccinctRegExMatch> regexRepeatMinToMax(RegEx r, int min, int ma
/**
* Repeat the regular expression from min to max times given right match.
*
* @param r The regular expression.
* @param r The regular expression.
* @param rightMatch The right match.
* @param min The minimum number of repetitions.
* @param max The maximum number of repetitions.
* @param min The minimum number of repetitions.
* @param max The maximum number of repetitions.
* @return The results for repeat.
*/
private HashSet<SuccinctRegExMatch> regexRepeatMinToMax(RegEx r, SuccinctRegExMatch rightMatch,
Expand Down

0 comments on commit 33477e5

Please sign in to comment.