remove end-of-line whitespace
Change-Id: I5c0415f47d4c3a9827574fbdab949b45718d9ea4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/601
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGeneratorMojo.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGeneratorMojo.java
index c72eb0a..7b914bc 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGeneratorMojo.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGeneratorMojo.java
@@ -37,7 +37,7 @@
public class LexerGeneratorMojo extends AbstractMojo {
/**
* parameter injected from pom.xml
- *
+ *
* @parameter
* @required
*/
@@ -45,7 +45,7 @@
/**
* parameter injected from pom.xml
- *
+ *
* @parameter
* @required
*/
@@ -93,4 +93,4 @@
return fileData.toString();
}
-}
\ No newline at end of file
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
index a113864..60e6e89 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package [PACKAGE];
+package [PACKAGE];
import java.io.IOException;
import [PACKAGE].[LEXER_NAME]Exception;
@@ -28,18 +28,18 @@
// Human representation of tokens. Useful for debug.
// Is possible to convert a TOKEN_CONSTANT in its image through
- // [LEXER_NAME].tokenKindToString(TOKEN_CONSTANT);
+ // [LEXER_NAME].tokenKindToString(TOKEN_CONSTANT);
private static final String[] tokenImage = {
"<EOF>", "<AUX_NOT_FOUND>" [TOKENS_IMAGES]
};
-
+
private static final char EOF_CHAR = 4;
protected java.io.Reader inputStream;
protected int column;
protected int line;
protected boolean prevCharIsCR;
protected boolean prevCharIsLF;
- protected boolean containsEscapes;
+ protected boolean containsEscapes;
protected char[] buffer;
protected int bufsize;
protected int bufpos;
@@ -56,12 +56,12 @@
// ================================================================================
// Main method. Return a TOKEN_CONSTANT
-// ================================================================================
-
+// ================================================================================
+
public int next() throws [LEXER_NAME]Exception, IOException {
char currentChar = buffer[bufpos];
while (currentChar == ' ' || currentChar=='\t' || currentChar == '\n' || currentChar=='\r')
- currentChar = readNextChar();
+ currentChar = readNextChar();
tokenBegin = bufpos;
containsEscapes = false;
if (currentChar==EOF_CHAR) return TOKEN_EOF;
@@ -124,21 +124,21 @@
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos);
}
-
+
public int getColumn() {
return column;
}
-
+
public int getLine() {
return line;
}
-
+
public boolean containsEscapes() {
return containsEscapes;
}
public static String tokenKindToString(int token) {
- return tokenImage[token];
+ return tokenImage[token];
}
public void done(){
@@ -147,8 +147,8 @@
// ================================================================================
// Parse error management
-// ================================================================================
-
+// ================================================================================
+
protected int parseError(int ... tokens) throws [LEXER_NAME]Exception {
StringBuilder message = new StringBuilder();
message.append("Parse error at (").append(line).append(", ").append(column).append(")");
@@ -160,10 +160,10 @@
}
throw new [LEXER_NAME]Exception(message.toString());
}
-
+
protected void updateLineColumn(char c){
column++;
-
+
if (prevCharIsLF)
{
prevCharIsLF = false;
@@ -181,17 +181,17 @@
line += (column = 1);
}
}
-
+
if (c=='\r') {
prevCharIsCR = true;
} else if(c == '\n') {
prevCharIsLF = true;
}
}
-
+
// ================================================================================
// Read data, buffer management. It uses a circular (and expandable) buffer
-// ================================================================================
+// ================================================================================
protected char readNextChar() throws IOException {
if (++bufpos >= endOf_USED_Buffer)
@@ -202,13 +202,13 @@
}
protected boolean fillBuff() throws IOException {
- if (endOf_UNUSED_Buffer == endOf_USED_Buffer) // If no more unused buffer space
+ if (endOf_UNUSED_Buffer == endOf_USED_Buffer) // If no more unused buffer space
{
if (endOf_UNUSED_Buffer == bufsize) // -- If the previous unused space was
{ // -- at the end of the buffer
if (tokenBegin > maxUnusedBufferSize) // -- -- If the first N bytes before
{ // the current token are enough
- bufpos = endOf_USED_Buffer = 0; // -- -- -- setup buffer to use that fragment
+ bufpos = endOf_USED_Buffer = 0; // -- -- -- setup buffer to use that fragment
endOf_UNUSED_Buffer = tokenBegin;
}
else if (tokenBegin < 0) // -- -- If no token yet
@@ -220,9 +220,9 @@
endOf_UNUSED_Buffer = bufsize; // -- set endOf_UNUSED_Buffer to the end of the buffer
else if ((tokenBegin - endOf_UNUSED_Buffer) < maxUnusedBufferSize)
{ // If between endOf_UNUSED_Buffer and the token
- ExpandBuff(true); // there is NOT enough space expand the buffer
+ ExpandBuff(true); // there is NOT enough space expand the buffer
} // reorganizing it
- else
+ else
endOf_UNUSED_Buffer = tokenBegin; // Otherwise there is enough space at the start
} // so we set the buffer to use that fragment
int i;
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
index 8b37bae..9030eb2 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
@@ -19,11 +19,11 @@
package [PACKAGE];
public class [LEXER_NAME]Exception extends Exception {
-
+
public [LEXER_NAME]Exception(String message) {
super(message);
}
-
+
private static final long serialVersionUID = 1L;
}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/Fixtures.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/Fixtures.java
index be792e4..a6d0267 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/Fixtures.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/Fixtures.java
@@ -34,18 +34,18 @@
static String rule2_action = "myaction2";
static String rule2_name = "myrule2";
static String rule2_match = "matchCheck2("+rule_name+")";
-
+
static public Rule createRule(final String name){
return new Rule(){
String rule_name = name;
String rule_action = "myaction";
String rule_match = "matchCheck("+rule_name+")";
-
+
@Override
public Rule clone(){
return Fixtures.createRule(name+"_clone");
}
-
+
@Override
public String javaAction() {
return rule_action;
@@ -55,21 +55,21 @@
public String javaMatch(String action) {
return rule_match+"{"+action+"}";
}
-
+
@Override
public String toString(){
return rule_name;
}
-
- };
+
+ };
}
-
+
static Rule rule = new Rule(){
-
+
public Rule clone(){
return null;
}
-
+
@Override
public String javaAction() {
return rule_action;
@@ -79,20 +79,20 @@
public String javaMatch(String action) {
return rule_match+"{"+action+"}";
}
-
+
@Override
public String toString(){
return rule_name;
}
-
- };
+
+ };
static Rule rule2 = new Rule(){
public Rule clone(){
return null;
}
-
+
@Override
public String javaAction() {
return rule2_action;
@@ -102,17 +102,17 @@
public String javaMatch(String act) {
return rule2_match+"{"+act+"}";
}
-
+
@Override
public String toString(){
return rule2_name;
}
-
+
};
-
+
static RuleChar ruleA = new RuleChar('a');
static RuleChar ruleB = new RuleChar('b');
static RuleChar ruleC = new RuleChar('c');
static String ruleABC_action = "currentChar = readNextChar();";
-
+
}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAddRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAddRuleTest.java
index 28812e8..dee1255 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAddRuleTest.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAddRuleTest.java
@@ -44,7 +44,7 @@
+"}"
+token_parseerror , node.toJava());
}
-
+
@Test
public void NodeSwitchCase() {
LexerNode node = new LexerNode();
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendNodeTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendNodeTest.java
index 9957776..206e69b 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendNodeTest.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendNodeTest.java
@@ -49,7 +49,7 @@
node.append(node2);
assertEquals("Arule_clone! ", node.toString());
}
-
+
@Test
public void AppendedNodesAreCloned() throws Exception {
LexerNode node = new LexerNode();
@@ -61,7 +61,7 @@
node.append(node2);
// TODO
// assertEquals("A! B_clone! ", node.toString());
-
+
LexerNode node3 = new LexerNode();
node3.append(createRule("C"));
node3.append(createRule("D"));
@@ -95,5 +95,5 @@
// TODO
// assertEquals(" ( A_clone! A_clone! || A_clone! ) ", node.toString());
}
-
+
}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendRuleTest.java
index fb2bdba..e532cf8 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendRuleTest.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAppendRuleTest.java
@@ -25,7 +25,7 @@
import org.apache.asterix.lexergenerator.LexerNode;
import static org.apache.asterix.lexergenerator.Fixtures.*;
-public class LexerNodeAppendRuleTest {
+public class LexerNodeAppendRuleTest {
@Test
public void SingleNode() {
LexerNode node = new LexerNode();
@@ -62,4 +62,4 @@
+token_parseerror
+"}"+token_parseerror, node.toJava());
}
-}
\ No newline at end of file
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
index 624af344..677d12e 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/org/apache/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
@@ -34,8 +34,8 @@
import org.apache.asterix.lexergenerator.rules.RulePartial;
public class LexerNodeAuxFunctionsTest {
- String expectedDifferentReturn = "return TOKEN_AUX_NOT_FOUND;\n";
-
+ String expectedDifferentReturn = "return TOKEN_AUX_NOT_FOUND;\n";
+
@Test
public void NodeRuleRuleNodeNode() {
LexerNode node = new LexerNode();
@@ -53,7 +53,7 @@
+"}"
+expectedDifferentReturn , node.toJavaAuxFunction());
}
-
+
@Test
public void NodeSwitchCase() {
LexerNode node = new LexerNode();
@@ -88,7 +88,7 @@
expectedNeededAuxFunctions.add("token1");
expectedNeededAuxFunctions.add("token2");
assertEquals(expectedNeededAuxFunctions, node.neededAuxFunctions());
- }
+ }
@Test(expected=Exception.class)
public void NodeExpandFirstActionError() throws Exception {
@@ -107,7 +107,7 @@
assertEquals("Cannot find a token used as part of another definition, missing token: token1", e.getMessage());
throw e;
}
- }
+ }
public void NodeExpandFirstAction() throws Exception {
LexerNode node = new LexerNode();
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/Generator.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/Generator.java
index 17a315e..ca53f66 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/Generator.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/Generator.java
@@ -27,19 +27,19 @@
import org.apache.asterix.recordmanagergenerator.RecordType.Field;
public class Generator {
-
+
public enum TemplateType {
RECORD_MANAGER,
ARENA_MANAGER,
SUPPORT
}
-
+
public static void generateSource(
- TemplateType tmplType,
+ TemplateType tmplType,
String packageName,
- RecordType rec,
- InputStream is,
- StringBuilder sb,
+ RecordType rec,
+ InputStream is,
+ StringBuilder sb,
boolean debug) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(is));
@@ -56,7 +56,7 @@
break;
default:
throw new IllegalArgumentException();
- }
+ }
} catch (IOException ioe) {
ioe.printStackTrace();
}
@@ -65,9 +65,9 @@
private static void generateMemoryManagerSource(
String packageName,
- RecordType resource,
- BufferedReader in,
- StringBuilder sb,
+ RecordType resource,
+ BufferedReader in,
+ StringBuilder sb,
boolean debug) throws IOException {
String line = null;
String indent = " ";
@@ -96,12 +96,12 @@
}
}
} else if (line.contains("@INIT_SLOT@")) {
- for (int i = 0; i < resource.size(); ++i) {
+ for (int i = 0; i < resource.size(); ++i) {
final Field field = resource.fields.get(i);
field.appendInitializers(sb, indent, 3);
}
} else if (line.contains("@CHECK_SLOT@")) {
- for (int i = 0; i < resource.size(); ++i) {
+ for (int i = 0; i < resource.size(); ++i) {
final Field field = resource.fields.get(i);
field.appendChecks(sb, indent, 3);
}
@@ -116,9 +116,9 @@
private static void generateArenaManagerSource(
String packageName,
- RecordType resource,
- BufferedReader in,
- StringBuilder sb,
+ RecordType resource,
+ BufferedReader in,
+ StringBuilder sb,
boolean debug) throws IOException {
String line = null;
String indent = " ";
@@ -154,7 +154,7 @@
private static void generateSupportFileSource(
String packageName,
- BufferedReader in,
+ BufferedReader in,
StringBuilder sb,
boolean debug) throws IOException {
String line = null;
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java
index 38c0dd3..bf981aa 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordManagerGeneratorMojo.java
@@ -40,23 +40,23 @@
* @requiresDependencyResolution compile
*/
public class RecordManagerGeneratorMojo extends AbstractMojo {
-
+
/**
* parameter injected from pom.xml
- *
+ *
* @parameter
*/
private boolean debug;
/**
* parameter injected from pom.xml
- *
+ *
* @parameter
* @required
*/
private String packageName;
/**
* parameter injected from pom.xml
- *
+ *
* @parameter
* @required
*/
@@ -67,15 +67,15 @@
* @readonly
*/
MavenProject project;
-
-
- String recordManagerTemplate = "RecordManager.java";
+
+
+ String recordManagerTemplate = "RecordManager.java";
String arenaManagerTemplate = "ArenaManager.java";
String[] supportTemplates = { "RecordManagerStats.java", "AllocInfo.java", "TypeUtil.java" };
-
+
private Map<String, RecordType> typeMap;
- public RecordManagerGeneratorMojo() {
+ public RecordManagerGeneratorMojo() {
}
private void readRecordTypes() throws MojoExecutionException {
@@ -90,7 +90,7 @@
getLog().info("reading " + inputFiles[i].toString());
Reader read = new FileReader(inputFiles[i]);
RecordType type = RecordType.read(read);
- // always add allocId to enable tracking of allocations
+ // always add allocId to enable tracking of allocations
type.addField("alloc id", RecordType.Type.SHORT, null);
type.addToMap(typeMap);
} catch (FileNotFoundException fnfe) {
@@ -102,7 +102,7 @@
}
public void execute() throws MojoExecutionException, MojoFailureException {
- String outputPath = project.getBuild().getDirectory() + File.separator
+ String outputPath = project.getBuild().getDirectory() + File.separator
+ "generated-sources" + File.separator
+ "java" + File.separator
+ packageName.replace('.', File.separatorChar);
@@ -112,12 +112,12 @@
}
readRecordTypes();
-
+
for (String recordType : typeMap.keySet()) {
generateSource(Generator.TemplateType.RECORD_MANAGER, recordManagerTemplate, recordType, outputPath);
generateSource(Generator.TemplateType.ARENA_MANAGER, arenaManagerTemplate, recordType, outputPath);
}
-
+
for (int i = 0; i < supportTemplates.length; ++i) {
generateSource(Generator.TemplateType.SUPPORT, supportTemplates[i], "", outputPath);
}
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordType.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordType.java
index c3a6e1f..6702a8f 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordType.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/java/org/apache/asterix/recordmanagergenerator/RecordType.java
@@ -31,13 +31,13 @@
import org.json.JSONTokener;
public class RecordType {
-
+
enum Type {
BYTE (1, "byte", "get", "put", "(byte)0xde", "TypeUtil.Byte.append", "TypeUtil.Byte.appendFixed"),
SHORT (2, "short", "getShort", "putShort", "(short)0xdead", "TypeUtil.Short.append", "TypeUtil.Short.appendFixed"),
INT (4, "int", "getInt", "putInt", "0xdeadbeef", "TypeUtil.Int.append", "TypeUtil.Int.appendFixed"),
GLOBAL(8, "long", "getLong", "putLong", "0xdeadbeefdeadbeefl", "TypeUtil.Global.append", "TypeUtil.Global.appendFixed");
-
+
Type(int size, String javaType, String bbGetter, String bbSetter, String deadMemInitializer, String appender, String tabAppender) {
this.size = size;
this.javaType = javaType;
@@ -47,7 +47,7 @@
this.appender = appender;
this.tabAppender = tabAppender;
}
-
+
int size;
String javaType;
String bbGetter;
@@ -56,9 +56,9 @@
String appender;
String tabAppender;
}
-
+
static class Field {
-
+
String name;
Type type;
String initial;
@@ -72,14 +72,14 @@
this.offset = offset;
this.accessible = accessible;
}
-
+
public static Field fromJSON(JSONObject obj) throws JSONException {
String name = obj.getString("name");
Type type = parseType(obj.getString("type"));
String initial = obj.optString("initial", null);
return new Field(name, type, initial, -1, true);
}
-
+
private static Type parseType(String string) {
string = string.toUpperCase();
if (string.equals("GLOBAL")) {
@@ -103,7 +103,7 @@
sb.append(word.substring(0, 1).toUpperCase());
sb.append(word.substring(1));
}
- return sb.toString();
+ return sb.toString();
}
StringBuilder appendMemoryManagerGetMethod(StringBuilder sb, String indent, int level) {
@@ -129,7 +129,7 @@
sb.append("}\n");
return sb;
}
-
+
StringBuilder appendMemoryManagerSetMethod(StringBuilder sb, String indent, int level) {
sb = indent(sb, indent, level);
sb.append("public void ")
@@ -173,7 +173,7 @@
sb.append("}\n");
return sb;
}
-
+
StringBuilder appendArenaManagerSetMethod(StringBuilder sb, String indent, int level) {
sb = indent(sb, indent, level);
sb.append("public void ")
@@ -197,7 +197,7 @@
sb.append("}\n");
return sb;
}
-
+
StringBuilder appendInitializers(StringBuilder sb, String indent, int level) {
sb = indent(sb, indent, level);
sb.append("bb.")
@@ -213,7 +213,7 @@
sb.append(");\n");
return sb;
}
-
+
StringBuilder appendChecks(StringBuilder sb, String indent, int level) {
if (initial == null) {
return sb;
@@ -236,7 +236,7 @@
sb.append("}\n");
return sb;
}
-
+
String offsetName() {
String words[] = name.split(" ");
assert(words.length > 0);
@@ -247,7 +247,7 @@
sb.append("_OFF");
return sb.toString();
}
-
+
int offset() {
return offset;
}
@@ -257,26 +257,26 @@
ArrayList<Field> fields;
int totalSize;
boolean modifiable = true;
-
+
static StringBuilder indent(StringBuilder sb, String indent, int level) {
for (int i = 0; i < level; ++i) {
sb.append(indent);
}
return sb;
}
-
+
public RecordType(String name) {
this.name = name;
fields = new ArrayList<Field>();
addField("next free slot", Type.INT, "-1", false);
}
-
+
public static RecordType read(Reader reader) throws JSONException {
JSONTokener tok = new JSONTokener(reader);
JSONObject obj = new JSONObject(tok);
return fromJSON(obj);
}
-
+
public static RecordType fromJSON(JSONObject obj) throws JSONException {
RecordType result = new RecordType(obj.getString("name"));
JSONArray fields = obj.getJSONArray("fields");
@@ -284,9 +284,9 @@
JSONObject field = fields.getJSONObject(i);
result.fields.add(Field.fromJSON(field));
}
- return result;
+ return result;
}
-
+
public void addToMap(Map<String, RecordType> map) {
modifiable = false;
calcOffsetsAndSize();
@@ -295,15 +295,15 @@
public void addField(String name, Type type, String initial) {
addField(name, type, initial, true);
- }
-
+ }
+
private void addField(String name, Type type, String initial, boolean accessible) {
if (! modifiable) {
throw new IllegalStateException("cannot modify type anmore");
}
fields.add(new Field(name, type, initial, -1, accessible));
}
-
+
private void calcOffsetsAndSize() {
Collections.sort(fields, new Comparator<Field>() {
public int compare(Field left, Field right) {
@@ -313,7 +313,7 @@
// sort fields by size and align the items
totalSize = 0;
int alignment = 0;
- for (int i = 0; i < fields.size(); ++i) {
+ for (int i = 0; i < fields.size(); ++i) {
final Field field = fields.get(i);
assert field.offset == -1;
field.offset = totalSize;
@@ -322,22 +322,22 @@
if (size > alignment) alignment = size;
}
if (totalSize % alignment != 0) {
- totalSize = ((totalSize / alignment) + 1) * alignment;
+ totalSize = ((totalSize / alignment) + 1) * alignment;
}
}
-
+
int size() {
return fields.size();
}
-
+
static String padRight(String s, int n) {
- return String.format("%1$-" + n + "s", s);
+ return String.format("%1$-" + n + "s", s);
}
static String padLeft(String s, int n) {
- return String.format("%1$" + n + "s", s);
+ return String.format("%1$" + n + "s", s);
}
-
+
StringBuilder appendConstants(StringBuilder sb, String indent, int level) {
sb = indent(sb, indent, level);
sb.append("public static int ITEM_SIZE = ")
@@ -354,7 +354,7 @@
}
return sb;
}
-
+
StringBuilder appendBufferPrinter(StringBuilder sb, String indent, int level) {
int maxNameWidth = 0;
for (int i = 0; i < fields.size(); ++i) {
@@ -391,20 +391,20 @@
}
return sb;
}
-
+
StringBuilder appendRecordPrinter(StringBuilder sb, String indent, int level) {
sb = indent(sb, indent, level);
sb.append("public StringBuilder appendRecord(StringBuilder sb, long slotNum) {\n");
-
+
sb = indent(sb, indent, level + 1);
sb.append("sb.append(\"{ \");\n\n");
-
+
for (int i = 0; i < fields.size(); ++i) {
Field field = fields.get(i);
if (field.accessible) {
if (i > 0) {
sb = indent(sb, indent, level + 1);
- sb.append("sb.append(\", \");\n\n");
+ sb.append("sb.append(\", \");\n\n");
}
sb = indent(sb, indent, level + 1);
sb.append("sb.append(\"\\\"").append(field.name).append("\\\" : \\\"\");\n");
@@ -421,7 +421,7 @@
sb = indent(sb, indent, level);
sb.append("}");
-
+
return sb;
}
}
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/AllocInfo.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/AllocInfo.java
index 0bea5da..f415562 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/AllocInfo.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/AllocInfo.java
@@ -24,11 +24,11 @@
public class AllocInfo {
String alloc;
String free;
-
+
void alloc() {
alloc = getStackTrace();
}
-
+
void free() {
free = getStackTrace();
}
@@ -42,11 +42,11 @@
// remove first 3 lines
int nlPos = 0;
for (int i = 0; i < 3; ++i) {
- nlPos = res.indexOf('\n', nlPos) + 1;
+ nlPos = res.indexOf('\n', nlPos) + 1;
}
return res.substring(nlPos);
}
-
+
public String toString() {
return "allocation stack:\n" + alloc + "\nfree stack\n" + free;
}
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
index adb73af..be295d6 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/ArenaManager.java
@@ -20,18 +20,18 @@
package @PACKAGE@;
public class @E@ArenaManager {
-
+
public static final boolean TRACK_ALLOC_ID = @DEBUG@;
private final int noArenas;
private final @E@RecordManager[] arenas;
private ThreadLocal<LocalManager> local;
-
+
static class LocalManager {
int arenaId;
@E@RecordManager mgr;
}
-
+
public @E@ArenaManager(final int noArenas, final long txnShrinkTimer) {
this.noArenas = noArenas;
arenas = new @E@RecordManager[noArenas];
@@ -39,7 +39,7 @@
arenas[i] = new @E@RecordManager(txnShrinkTimer);
}
local = new ThreadLocal<LocalManager>() {
- private int nextArena = 0;
+ private int nextArena = 0;
@Override
protected synchronized LocalManager initialValue() {
@@ -58,7 +58,7 @@
final @E@RecordManager recMgr = localManager.mgr;
final int allocId = TRACK_ALLOC_ID ? (++recMgr.allocCounter % 0x7fff) : 0;
final int localId = recMgr.allocate();
-
+
long result = TypeUtil.Global.build(localManager.arenaId, allocId, localId);
if (TRACK_ALLOC_ID) setAllocId(result, (short) allocId);
@@ -68,23 +68,23 @@
assert TypeUtil.Global.localId(result) == localId;
return result;
}
-
+
public void deallocate(long slotNum) {
if (TRACK_ALLOC_ID) checkAllocId(slotNum);
final int arenaId = TypeUtil.Global.arenaId(slotNum);
get(arenaId).deallocate(TypeUtil.Global.localId(slotNum));
}
-
+
public @E@RecordManager get(int i) {
return arenas[i];
}
-
+
public @E@RecordManager local() {
return local.get().mgr;
}
-
+
@METHODS@
-
+
private void checkAllocId(long slotNum) {
final int refAllocId = TypeUtil.Global.allocId(slotNum);
final short curAllocId = getAllocId(slotNum);
@@ -100,14 +100,14 @@
throw new IllegalStateException(msg);
}
}
-
+
public AllocInfo getAllocInfo(long slotNum) {
final int arenaId = TypeUtil.Global.arenaId(slotNum);
return get(arenaId).getAllocInfo(TypeUtil.Global.localId(slotNum));
}
-
+
@PRINT_RECORD@
-
+
public StringBuilder append(StringBuilder sb) {
for (int i = 0; i < noArenas; ++i) {
sb.append("++++ arena ").append(i).append(" ++++\n");
@@ -115,7 +115,7 @@
}
return sb;
}
-
+
public String toString() {
return append(new StringBuilder()).toString();
}
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
index b3c06f1..6e5041f 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManager.java
@@ -26,7 +26,7 @@
public static final boolean CHECK_SLOTS = @DEBUG@;
public static final boolean TRACK_ALLOC_LOC = @DEBUG@;
-
+
static final int NO_SLOTS = 1000;
@CONSTS@
@@ -39,22 +39,22 @@
private boolean isShrinkTimerOn;
int allocCounter;
-
+
public @E@RecordManager(long txnShrinkTimer) {
this.txnShrinkTimer = txnShrinkTimer;
buffers = new ArrayList<Buffer>();
buffers.add(new Buffer());
current = 0;
-
+
allocCounter = 0;
}
-
+
enum SlotSource {
NON_FULL,
UNINITIALIZED,
NEW
}
-
+
synchronized int allocate() {
if (buffers.get(current).isFull()) {
final int size = buffers.size();
@@ -74,7 +74,7 @@
current = i;
}
}
-
+
switch (source) {
case NEW:
buffers.add(new Buffer());
@@ -114,7 +114,7 @@
* buffers status : O O x x x x x
* However, in the above case, if we subtract the deinitialized children's slots,
* needShrink() will return false even if we shrink the buffers at this case.
- *
+ *
* @return
*/
private boolean needShrink() {
@@ -175,7 +175,7 @@
break;
}
}
-
+
//reset allocChild to the first buffer
current = 0;
@@ -183,7 +183,7 @@
}
@METHODS@
-
+
public AllocInfo getAllocInfo(int slotNum) {
final Buffer buf = buffers.get(slotNum / NO_SLOTS);
if (buf.allocList == null) {
@@ -192,7 +192,7 @@
return buf.allocList.get(slotNum % NO_SLOTS);
}
}
-
+
StringBuilder append(StringBuilder sb) {
sb.append("+++ current: ")
.append(current)
@@ -205,7 +205,7 @@
}
return sb;
}
-
+
public String toString() {
return append(new StringBuilder()).toString();
}
@@ -220,14 +220,14 @@
}
return s;
}
-
+
static class Buffer {
private ByteBuffer bb = null; // null represents 'deinitialized' state.
private int freeSlotNum;
private int occupiedSlots;
-
+
ArrayList<AllocInfo> allocList;
-
+
Buffer() {
initialize();
}
@@ -241,7 +241,7 @@
setNextFreeSlot(i, i + 1);
}
setNextFreeSlot(NO_SLOTS - 1, -1); //-1 represents EOL(end of link)
-
+
if (TRACK_ALLOC_LOC) {
allocList = new ArrayList<AllocInfo>(NO_SLOTS);
for (int i = 0; i < NO_SLOTS; ++i) {
@@ -249,12 +249,12 @@
}
}
}
-
+
public void deinitialize() {
if (TRACK_ALLOC_LOC) allocList = null;
bb = null;
}
-
+
public boolean isInitialized() {
return bb != null;
}
@@ -266,7 +266,7 @@
public boolean isEmpty() {
return occupiedSlots == 0;
}
-
+
public int allocate() {
int slotNum = freeSlotNum;
freeSlotNum = getNextFreeSlot(slotNum);
@@ -275,7 +275,7 @@
if (TRACK_ALLOC_LOC) allocList.get(slotNum).alloc();
return slotNum;
}
-
+
public void deallocate(int slotNum) {
@INIT_SLOT@
setNextFreeSlot(slotNum, freeSlotNum);
@@ -286,8 +286,8 @@
public int getNextFreeSlot(int slotNum) {
return bb.getInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFF);
- }
-
+ }
+
public void setNextFreeSlot(int slotNum, int nextFreeSlot) {
bb.putInt(slotNum * ITEM_SIZE + NEXT_FREE_SLOT_OFF, nextFreeSlot);
}
@@ -301,17 +301,17 @@
@PRINT_BUFFER@
return sb;
}
-
+
public String toString() {
return append(new StringBuilder()).toString();
}
-
+
public void addTo(RecordManagerStats s) {
if (isInitialized()) {
s.items += occupiedSlots;
}
}
-
+
private void checkSlot(int slotNum) {
if (! CHECK_SLOTS) {
return;
@@ -320,5 +320,5 @@
// @CHECK_SLOT@
}
}
-
+
}
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManagerStats.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManagerStats.java
index b5a3bbf..800b388 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManagerStats.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/RecordManagerStats.java
@@ -24,7 +24,7 @@
int slots = 0;
int items = 0;
int size = 0;
-
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ arenas : ").append(arenas);
diff --git a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/TypeUtil.java b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/TypeUtil.java
index 8108094..81d6958 100644
--- a/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/TypeUtil.java
+++ b/asterix-maven-plugins/record-manager-generator-maven-plugin/src/main/resources/TypeUtil.java
@@ -19,7 +19,7 @@
package @PACKAGE@;
public class TypeUtil {
-
+
public static class Byte {
public static StringBuilder append(StringBuilder sb, byte b) {
return sb.append(String.format("%1$x", b));
@@ -71,7 +71,7 @@
public static int localId(long l) {
return (int) (l & 0xffffffffL);
}
-
+
public static StringBuilder append(StringBuilder sb, long l) {
sb.append(String.format("%1$x", TypeUtil.Global.arenaId(l)));
sb.append(':');
@@ -80,7 +80,7 @@
sb.append(String.format("%1$x", TypeUtil.Global.localId(l)));
return sb;
}
-
+
public static StringBuilder appendFixed(StringBuilder sb, long l) {
sb.append(String.format("%1$4x", TypeUtil.Global.arenaId(l)));
sb.append(':');
@@ -89,10 +89,10 @@
sb.append(String.format("%1$8x", TypeUtil.Global.localId(l)));
return sb;
}
-
+
public static String toString(long l) {
return append(new StringBuilder(), l).toString();
}
-
+
}
}