Browse files

check for deletes in filter

  • Loading branch information...
1 parent b09c36d commit 393a5278ca4ef4361fb8d1c3d1eb6afa3f774a3e Maysam Yabandeh committed May 15, 2012
View
20 src/main/java/com/yahoo/omid/client/TransactionalTable.java
@@ -299,7 +299,6 @@ boolean isMoreRecentThan(KeyValueTc other) {
//Added by Maysam Yabandeh
/*
- * TODO: check for deletes
* This filter assumes that only one row is feteched
* Assume?: the writes of all elders are either feteched and rejected in a previous get or are presents in this result variable
* There are three kinds of committed values:
@@ -314,7 +313,7 @@ private Result filter(TransactionState state, Result unfilteredResult, long star
return new Result(filteredList);
}
- //add the results to the filteredLost, recurse if it is necessary
+ //add the results to the filteredList, recurse if it is necessary
private void filter(TransactionState state, Result unfilteredResult, long startTimestamp, int nMinVersionsAsked, ArrayList<KeyValue> filteredList) throws IOException {
Statistics.partialReport(Statistics.Tag.GET_PER_CLIENT_GET, 1);
List<KeyValue> kvs = unfilteredResult == null ? null : unfilteredResult.list();
@@ -336,7 +335,7 @@ private void filter(TransactionState state, Result unfilteredResult, long startT
KeyValue lastkv = null;
//start from the highest Ts and compare their Tc till you reach a one with lost Tc (Ts < Tmax). Then read the rest of the list to make sure that values of failed elders are also read. Then among the normal value and the failedElder with highest Tc, choose one.
for (KeyValue kv : kvs) {
- {//check if the column is switched, if yes provess the results of the last column, otherwise keep reading
+ {//check if the column is switched, if yes process the results of the last column, otherwise keep reading
ColumnFamilyAndQuantifier column = new ColumnFamilyAndQuantifier(kv.getFamily(), kv.getQualifier());
boolean sameColumn = lastColumn == null ? true : lastColumn.equals(column);
if (pickedOneForLastColumn && sameColumn)
@@ -359,7 +358,7 @@ private void filter(TransactionState state, Result unfilteredResult, long startT
//porcess the keyvalue
long Ts = kv.getTimestamp();
if (Ts == startTimestamp) {//if it is my own write, return it
- filteredList.add(kv);
+ addIfItIsNotADelete(kv, filteredList);
pickedOneForLastColumn = true;
}
nextFetchMaxTimestamp = Math.min(nextFetchMaxTimestamp, Ts);
@@ -376,7 +375,7 @@ private void filter(TransactionState state, Result unfilteredResult, long startT
long Tc = state.tsoclient.commitTimestamp(Ts, startTimestamp);
if (Tc == -2) continue;//invalid read
if (IsolationLevel.checkForWriteWriteConflicts) {//then everything is in order, and the first version is enough
- filteredList.add(kv);
+ addIfItIsNotADelete(kv, filteredList);
pickedOneForLastColumn = true;
continue;
}
@@ -394,17 +393,17 @@ private void filter(TransactionState state, Result unfilteredResult, long startT
//Having processed the versions related to a column, decide which version should be added to the filteredList
void pickTheRightVersion(ArrayList<KeyValue> filteredList, TransactionState state, long startTimestamp, int nVersionsRead, int nMinVersionsAsked, KeyValue lastkv, long nextFetchMaxTimestamp, KeyValueTc mostRecentValueWithTc, KeyValue mostRecentKeyValueWithLostTc, KeyValueTc mostRecentFailedElder) throws IOException {
if (mostRecentValueWithTc.isMoreRecentThan(mostRecentFailedElder)) {
- filteredList.add(mostRecentValueWithTc.kv);
+ addIfItIsNotADelete(mostRecentValueWithTc.kv, filteredList);
return;
}
if (mostRecentFailedElder.isMoreRecentThan(mostRecentKeyValueWithLostTc)) {
//if Ts < Tc(elder) => Tc < Tc(elder)
//this is bacause otherwise tso would have detected the other txn as elder too
- filteredList.add(mostRecentFailedElder.kv);
+ addIfItIsNotADelete(mostRecentFailedElder.kv, filteredList);
return;
}
if (mostRecentKeyValueWithLostTc != null) {
- filteredList.add(mostRecentKeyValueWithLostTc);
+ addIfItIsNotADelete(mostRecentKeyValueWithLostTc, filteredList);
return;
}
boolean noMoreLeft = (nVersionsRead < nMinVersionsAsked);
@@ -419,6 +418,11 @@ void pickTheRightVersion(ArrayList<KeyValue> filteredList, TransactionState stat
filter(state, unfilteredResult, startTimestamp, nMinVersionsAsked, filteredList);
}
+ void addIfItIsNotADelete(KeyValue kv, ArrayList<KeyValue> filteredList) {
+ if (kv.getValue().length != 0)
+ filteredList.add(kv);
+ }
+
/*
private Result filter(TransactionState state, Result result, long startTimestamp, int localVersions) throws IOException {
if (result == null) {
View
2 src/main/java/com/yahoo/omid/tso/TSOHandler.java
@@ -343,7 +343,7 @@ public void handle(CommitRequest msg, ChannelHandlerContext ctx) {
}
//now do the rest out of sync block to allow more concurrency
toWAL.writeLong(reply.commitTimestamp);
- //TODO: should we be able to recover the writeset of a failed elders?
+ //TODO: should we be able to recover the writeset of failed elders?
if (newmax > oldmax) {//I caused a raise in Tmax
toWAL.writeByte((byte)-2);
toWAL.writeLong(newmax);

0 comments on commit 393a527

Please sign in to comment.