烂笔头网记

Transaction Programming

Calum GrantDDJ上发表了一篇Transaction Programming, 介绍了用他做的一个C++事务编程库Atomic,关于它的实现:

  • The implementation of the Atomic Library is based around a central stack—a transaction stack—that logs each operation. Whenever an atomic container is modified, it pushes a record of the operation onto the stack.
  • When a transaction is entered, the constructor of atomic::transaction stores the initial size of the transaction stack. When a transaction exits, the destructor of atomic::transaction can roll back all operations (in reverse order) to the initial size of the transaction stack. The transaction::commit() method sets a flag in the transaction telling it not to roll back.
  • There are just two types of atomic operations—insert and delete. Other operations can be composed of insertions or deletions.
  • All atomic containers derive from atomic::container.
  • When an item is inserted into a container, it logs an insertion, a pointer to the container, and a pointer to the inserted object on the transaction stack.
  • When an item is deleted from a container, it logs a deletion, a pointer to the container, and a pointer to the deleted object on the transaction stack. The object is not destroyed at this point in case it needs to be inserted back into the container.
  • When an insertion is rolled back, the unlink() function is called on the container to remove the item from the data structure, and destroy() is called to delete the object.
  • When a deletion is rolled back, the relink() function is called on the container to insert the item back into the data structure. The deleted item must contain a hint where the item should be inserted.

缺点是该库并不支持多线程。另外,按作者的说法,事务insert和delete操作将增加5%-15%的CPU消耗。

BTW, Abrahams guarantees [Abrahams, D. "Exception-Safety in Generic Components," Generic Programming: Proceedings of a Dagstuhl Seminar, M. Jazayeri, R. Loos, and D. Musser, eds. (Springer Verlag, 1999).]:

  • Basic Guarantee. If an exception is thrown, no resources are leaked and objects remain in a destructible and usable—but not necessarily predictable—state.
  • Strong Guarantee. If an exception is thrown, the program state remains unchanged.
  • Nothrow Guarantee. The function will not emit an exception under any circumstances.

 

Databases: Yesterday, Today, and Tomorrow

MySQL的Jim Starkey接受了DDJ的采访。对于Database的现状和未来,他说:

We started with blobs because they were unlimited in size, but soon all fields will be unlimited, so blobs can fade away. The relational model was good because it was simple, but now needs semantic extensions to keep it alive going forward. SQL was once good because it worked well on a network, but SQL on the wire is now the limiting factor in system performance. To save it, we need to get off the wire and into a sandbox within the database server. To do that, we need to learn to think differently about how applications are designed and deployed.

There's the old story about a great-grandfather's axe that had its head replaced twice and its handle three times. That's where I think relational databases are going. We'll change the data model, the data types, the application topology, and the network interface, but they'll still be relational databases.

另外,关于一些技术细节的摘录:

  • Falcon stores data by actual value rather than declared type. This removes any performance penalty for over-specifying a field. The value "5" takes the same space whether declared as a tiny integer, small integer, large integer, or really-big-I-mean-it-this-time integer.
  • Access control or visibility needs to be at the row, not table, level.

 

Defining Success - Success is in the eye of the beholder

后面的一句是文中的。虽然我不是非常赞同。文中有一个调查结果比较有趣,是不同角色的人对五个项目权衡因素的优先级排序:

All/Commercial/Govt./IT Mgmt.StakeholdersNonMgmt. ITProject Mgmt.
1QualityQualityQualityQuality
2ScopeScopeStaffScope
3StaffTimeScopeTime
4TimeMoneyTimeStaff
5MoneyStaffMoneyMoney

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值