@@ -233,11 +233,10 @@ def _complete(self) -> None:
233233
234234
235235@dataclass
236- class NonSerializableReadTransaction :
236+ class ReadUncommitedTransaction :
237237 _xid : XID
238238 _start_time : LogicTime
239- _is_readonly : bool
240- _is_completed : bool
239+ _space : dict [TID , TupleEffect ]
241240
242241 def xid (self ) -> XID :
243242 return self ._xid
@@ -249,54 +248,46 @@ def age(self, time: LogicTime) -> LogicTime:
249248 return time - self ._start_time
250249
251250 def include (self , effect : ConflictableTransactionScalarEffect ) -> None :
252- if self ._is_readonly and not isinstance (
253- effect , JustViewedTuple | MigratedTuple
254- ):
255- self ._is_readonly = False
256-
257- def rollback (self ) -> None :
258- self ._is_completed = True
251+ if isinstance (effect , JustViewedTuple | Claim ):
252+ return
259253
260- def commit (self ) -> Commit :
261- """
262- :raises tgdb.entities.horizon.transaction.NonSerializableWriteTransactionError:
263- """ # noqa: E501
254+ if effect .tid in self ._space :
255+ effect = self ._space [effect .tid ] & effect
264256
265- self ._is_completed = True
257+ self ._space [ effect . tid ] = effect
266258
267- if not self ._is_readonly :
268- self .rollback ()
269- raise NonSerializableWriteTransactionError (self ._xid )
259+ def rollback (self ) -> None :
260+ ...
270261
262+ def commit (self ) -> Commit :
271263 return Commit (self ._xid , frozenset ())
272264
273265 @classmethod
274266 def start (
275267 cls , xid : XID , time : LogicTime
276- ) -> "NonSerializableReadTransaction " :
277- return NonSerializableReadTransaction (
268+ ) -> "ReadUncommitedTransaction " :
269+ return ReadUncommitedTransaction (
278270 _xid = xid ,
279271 _start_time = time ,
280- _is_readonly = True ,
281- _is_completed = False ,
272+ _space = dict (),
282273 )
283274
284275 def __eq__ (self , other : object ) -> bool :
285276 return (
286- isinstance (other , SerializableTransaction )
277+ isinstance (other , ReadUncommitedTransaction )
287278 and self .xid () == other .xid ()
288279 )
289280
290281 def __hash__ (self ) -> int :
291282 return hash (type (self )) + hash (self ._xid )
292283
293284
294- type Transaction = SerializableTransaction | NonSerializableReadTransaction
285+ type Transaction = SerializableTransaction | ReadUncommitedTransaction
295286
296287
297288class IsolationLevel (Enum ):
298- serializable_read_and_write = auto ()
299- non_serializable_read = auto ()
289+ serializable = auto ()
290+ read_uncommited = auto ()
300291
301292
302293def start_transaction (
@@ -306,10 +297,10 @@ def start_transaction(
306297 serializable_transactions : Iterable [SerializableTransaction ],
307298) -> Transaction :
308299 match isolation :
309- case IsolationLevel .serializable_read_and_write :
300+ case IsolationLevel .serializable :
310301 return SerializableTransaction .start (
311302 xid , time , serializable_transactions
312303 )
313304
314- case IsolationLevel .non_serializable_read :
315- return NonSerializableReadTransaction .start (xid , time )
305+ case IsolationLevel .read_uncommited :
306+ return ReadUncommitedTransaction .start (xid , time )
0 commit comments