-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
374 additions
and
284 deletions.
There are no files selected for viewing
286 changes: 112 additions & 174 deletions
286
...e/src/main/java/org/corfudb/runtime/object/transactions/AbstractTransactionalContext.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
runtime/src/main/java/org/corfudb/runtime/object/transactions/ReadSetInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.corfudb.runtime.object.transactions; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* This class captures information about objects accessed (read) during speculative | ||
* transaction execution. | ||
*/ | ||
@Getter | ||
class ReadSetInfo { | ||
// fine-grained conflict information regarding accessed-objects; | ||
// captures values passed using @conflict annotations in @corfuObject | ||
Map<UUID, Set<Integer>> readSetConflicts = new HashMap<>(); | ||
|
||
public void mergeInto(ReadSetInfo other) { | ||
other.getReadSetConflicts().forEach((streamId, cset) -> { | ||
getConflictSet(streamId).addAll(cset); | ||
}); | ||
} | ||
|
||
public void addToReadSet(UUID streamId, Object[] conflictObjects) { | ||
if (conflictObjects == null) { | ||
return; | ||
} | ||
|
||
Set<Integer> streamConflicts = getConflictSet(streamId); | ||
Arrays.asList(conflictObjects).stream() | ||
.forEach(V -> streamConflicts.add(Integer.valueOf(V.hashCode()))); | ||
} | ||
|
||
public Set<Integer> getConflictSet(UUID streamId) { | ||
return getReadSetConflicts().computeIfAbsent(streamId, u -> { | ||
return new HashSet<>(); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
runtime/src/main/java/org/corfudb/runtime/object/transactions/TransactionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.