ARST打卡第208周[208/521]
Algorithm
lc2418_按身高排序
思路:
因为这个名字和身高是分离的数组,不能通过直接写一个对比身高的函数来直接调整名字,因为快排中需要后续持续比较,所以可以容易地想到方法一就是把名字和身高联系起来,以方便一起变动
方法1. 通过把名字身高搞成一个结构体数组,然后再用身高对结构体数组排序
方法2. 还有一种思路,就是通过记录身高对应的原始的下标,最后sort排序之后,遍历现在的身高,把原来的下标位置的名字和当前身高下标的名字依次swap(如果相等则不用swap)
发现题解和我的思路一毛一样,只不过我的swap,变成了题解的直接遍历获取,多用了一些空间,问题不大
1 | // g++ A.cpp -o A.out -std=c++11 |
Review
解决的痛点 / 优势:
防止Rocksdb单节点故障
A RocksDB-Cloud instance is durable. Continuous and automatic replication of db data and metadata to Cloud Storage (e.g. AWS S3). In the event that the RocksDB-Cloud machine dies, another process on any other EC2 machine can reopen the same RocksDB-Cloud database.方便克隆拷贝rocksdb实例
A RocksDB-Cloud instance is cloneable. RocksDB-Cloud supports a primitive called zero-copy-clone that allows another instance of RocksDB-Cloud on another machine to clone an existing db. Both master and slave RocksDB-Cloud instance can run in parallel and they share some set of common database files.冷热数据分离,自动把冷数据放在云存储
A RocksDB-Cloud instance automatically places hot data in SSD and cold data in Cloud Storage. The entire database storage footprint need not be resident on costly SSD. The Cloud storage contains the entire database and the local storage contains only the files that are in the working set.降本的特性
The reason you might want to use rocksdb-cloud is not because replication is quicker in rocksdb-cloud. You would use rocksdb-cloud because of its storage efficiency and reduced cost.
Storage efficiency comes from better packing of data in rocksdb. Reduced-cost comes from the fact that you do not need to keep only one copy of your data in SSD/RAM whereas you need to keep two/three copies of your data in SSD/RAM while using cassandra.
Tips
LSM-tree 的 Remote Compaction调度
Share-个人能量 & 开阔视野
管理能量,专注事情,学习成长,不要急