alexzfx / engine Goto Github PK
View Code? Open in Web Editor NEW第一届PolarDB数据库性能大赛代码。Java语言实现
第一届PolarDB数据库性能大赛代码。Java语言实现
write函数中的这部分代码似乎会产生并发问题
// ...
int hash = valueFileHash(numkey);
int off = valueOffsets[hash].getAndIncrement();
try {
ByteBuffer keyBuffer = keyMappedByteBuffers[hash].slice();
keyBuffer.position(keyOffsets[hash].getAndAdd(KEY_AND_OFF_LEN));
keyBuffer.putLong(numkey).putInt(off);
// ...
假设两个线程同时调用write方法并且产生的hash相同时,有如下执行顺序:
keyBuffer.position()
-> buffer位置变成了xkeyBuffer.position()
-> buffer位置变成了x + 16keyBuffer.putLong()
-> buffer中为 [key1]keyBuffer.putLong()
-> buffer中为 [key1, key2]keyBuffer.putInt()
-> buffer中为 [key1, key2, off1]keyBuffer.putInt()
-> buffer中为 [key1, key2, off1, off2]此时似乎应该会产生不一致的问题。
没有任何恶意,希望能学习一下😊
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.