Skip to content
Browse files

made transaction IDs serialize in base 10 again. This facilitates eas…

…ier parsing of data files outside XFlat.

Signed-off-by: gburgett <gordon.burgett@gmail.com>
  • Loading branch information...
1 parent b3621fc commit 79959438b6147668a2c5d2480404908d11b7546c @gburgett committed Feb 15, 2013
View
11 java/XFlat/src/org/xflatdb/xflat/engine/CachedDocumentEngine.java
@@ -60,6 +60,9 @@
*/
public class CachedDocumentEngine extends EngineBase implements Engine {
+ /** The radix of transaction IDs when serialized to an attribute, ex. 16 for hexadecimal */
+ private static final int TRANSACTION_ID_RADIX = 10;
+
//TODO: can we replace this by taking a table lock on spin-up?
private final AtomicBoolean operationsReady = new AtomicBoolean(false);
@@ -668,15 +671,15 @@ protected boolean spinUp() {
String a = data.getAttributeValue("tx", XFlatDatabase.xFlatNs);
if(a != null && !"".equals(a)){
try{
- txId = Long.parseLong(a, 16);
+ txId = Long.parseLong(a, TRANSACTION_ID_RADIX);
}catch(NumberFormatException ex){
//just leave it as 0.
}
}
a = data.getAttributeValue("commit", XFlatDatabase.xFlatNs);
if(a != null && !"".equals(a)){
try{
- commitId = Long.parseLong(a, 16);
+ commitId = Long.parseLong(a, TRANSACTION_ID_RADIX);
}catch(NumberFormatException ex){
//just leave it as 0.
}
@@ -994,8 +997,8 @@ private void dumpCacheNow(boolean required){
nonDeleteData++;
}
- dataEl.setAttribute("tx", Long.toHexString(rData.transactionId), XFlatDatabase.xFlatNs);
- dataEl.setAttribute("commit", Long.toHexString(rData.commitId), XFlatDatabase.xFlatNs);
+ dataEl.setAttribute("tx", Long.toString(rData.transactionId, TRANSACTION_ID_RADIX), XFlatDatabase.xFlatNs);
+ dataEl.setAttribute("commit", Long.toString(rData.commitId, TRANSACTION_ID_RADIX), XFlatDatabase.xFlatNs);
rowEl.addContent(dataEl);
}
View
8 java/XFlat/src/org/xflatdb/xflat/transaction/ThreadContextTransactionManager.java
@@ -818,8 +818,8 @@ public void removeTransactionListener(TransactionListener listener) {
@Override
public Element convert(TransactionJournalEntry source) throws ConversionException {
Element ret = new Element("entry");
- ret.setAttribute("txId", Long.toHexString(source.txId));
- ret.setAttribute("commit", Long.toHexString(source.commitId));
+ ret.setAttribute("txId", Long.toString(source.txId));
+ ret.setAttribute("commit", Long.toString(source.commitId));
for(String s : source.tableNames){
ret.addContent(new Element("table").setText(s));
@@ -839,11 +839,11 @@ public TransactionJournalEntry convert(Element source) throws ConversionExceptio
if(txId == null){
throw new ConversionException("txId attribute required");
}
- ret.txId = Long.parseLong(txId, 16);
+ ret.txId = Long.parseLong(txId);
String commitId = source.getAttributeValue("commit");
if(commitId != null){
- ret.commitId = Long.parseLong(commitId, 16);
+ ret.commitId = Long.parseLong(commitId);
}
for(Element e : source.getChildren("table")){
View
2 java/XFlat/test/org/xflatdb/xflat/db/EngineTestsBase.java
@@ -108,7 +108,7 @@ protected TestContext getContext(){
TestContext ctx = new TestContext();
- ctx.workspace = new File(workspace, Long.toHexString(ctx.id));
+ ctx.workspace = new File(workspace, Long.toString(ctx.id));
if(!ctx.workspace.exists()){
ctx.workspace.mkdirs();
}

0 comments on commit 7995943

Please sign in to comment.
Something went wrong with that request. Please try again.