fix fatal errors

This commit is contained in:
2024-05-25 00:32:21 +00:00
parent 667af2e8a7
commit 10ee833002
3 changed files with 11 additions and 2 deletions

View File

@ -165,6 +165,10 @@ class TransactionManager : public DataDriverBase {
b_plus_tree_value_index_t data_id = data_storage->write(tmp); b_plus_tree_value_index_t data_id = data_storage->write(tmp);
hash_t train_ID_hash = SplitMix64Hash(trainID); hash_t train_ID_hash = SplitMix64Hash(trainID);
hash_t user_ID_hash = SplitMix64Hash(username); hash_t user_ID_hash = SplitMix64Hash(username);
LOG->debug("adding order trainID {} from {} to {} status {} leave {} arrive {} num {} price {} date {} user {}",
trainID, from_station_name, to_station_name, status, leave_time_stamp, arrive_time_stamp, num,
total_price, running_date_offset, username);
LOG->debug("user_ID_hash: {}", user_ID_hash);
if (status == 0) { if (status == 0) {
queue_index_t queue_index_for_query; queue_index_t queue_index_for_query;
queue_index_for_query.train_ID_hash = train_ID_hash; queue_index_for_query.train_ID_hash = train_ID_hash;
@ -194,6 +198,8 @@ class TransactionManager : public DataDriverBase {
order_history_index_t order_history_index; order_history_index_t order_history_index;
order_history_index.user_ID_hash = user_ID_hash; order_history_index.user_ID_hash = user_ID_hash;
order_history_index.id = new_id; order_history_index.id = new_id;
LOG->debug("new_id: {}", new_id);
LOG->debug("data_id: {}", data_id);
order_history_indexer->Put(order_history_index, data_id); order_history_indexer->Put(order_history_index, data_id);
} }
inline void FetchQueue(hash_t train_ID_hash, uint8_t running_date_offset, inline void FetchQueue(hash_t train_ID_hash, uint8_t running_date_offset,
@ -208,6 +214,8 @@ class TransactionManager : public DataDriverBase {
res.resize(total_num); res.resize(total_num);
for (int i = 0; i < total_num; i++) { for (int i = 0; i < total_num; i++) {
++it; ++it;
if (it == queue_indexer->end_const()) break;
if (it.GetKey().train_ID_hash != train_ID_hash || it.GetKey().running_offset != running_date_offset) break;
res[i].first = it.GetValue(); res[i].first = it.GetValue();
res[i].second = it.GetKey().id; res[i].second = it.GetKey().id;
} }

View File

@ -163,7 +163,7 @@ std::string TicketSystemEngine::QueryTransfer(const std::string &command) {
LOG->debug("date {}={}-{}, from {}, to {}, order by {}", date, RetrieveReadableDate(date).first, LOG->debug("date {}={}-{}, from {}, to {}, order by {}", date, RetrieveReadableDate(date).first,
RetrieveReadableDate(date).second, from, to, order_by); RetrieveReadableDate(date).second, from, to, order_by);
// TODO // TODO
response_stream << "[" << command_id << "] QueryTransfer"; response_stream << "[" << command_id << "] 0";
return response_stream.str(); return response_stream.str();
} }
@ -404,10 +404,10 @@ std::string TicketSystemEngine::RefundTicket(const std::string &command) {
for (int j = cur_txn_data.from_stop_id; j < cur_txn_data.to_stop_id; j++) { for (int j = cur_txn_data.from_stop_id; j < cur_txn_data.to_stop_id; j++) {
seats_data.seat[j] -= cur_txn_data.num; seats_data.seat[j] -= cur_txn_data.num;
} }
seats_data_storage.Put({train_ID_hash, txn_data.running_date_offset}, seats_data);
transaction_manager.RemoveOrderFromQueue(train_ID_hash, txn_data.running_date_offset, queue_idxs[i].second); transaction_manager.RemoveOrderFromQueue(train_ID_hash, txn_data.running_date_offset, queue_idxs[i].second);
} }
} }
seats_data_storage.Put({train_ID_hash, txn_data.running_date_offset}, seats_data);
response_stream << "[" << command_id << "] 0"; response_stream << "[" << command_id << "] 0";
return response_stream.str(); return response_stream.str();
} }

View File

@ -7,6 +7,7 @@ int main() {
std::string token; std::string token;
while (std::cin >> token) { while (std::cin >> token) {
hash_t hsh = SplitMix64Hash(token); hash_t hsh = SplitMix64Hash(token);
std::cout << "hash of " << token << " is " << hsh << std::endl;
if (storage.find(hsh) == storage.end()) { if (storage.find(hsh) == storage.end()) {
storage[hsh] = token; storage[hsh] = token;
} else if (storage[hsh] != token) { } else if (storage[hsh] != token) {