Skip to content

Commit

Permalink
add operation support
Browse files Browse the repository at this point in the history
  • Loading branch information
1a1a11a committed Dec 9, 2024
1 parent b8539a1 commit 8be32b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
19 changes: 17 additions & 2 deletions libCacheSim/traceReader/generalReader/csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#include "../../../libCacheSim/include/libCacheSim/macro.h"
#include "../../dataStructure/hash/hash.h"
Expand Down Expand Up @@ -228,6 +229,22 @@ static inline void csv_cb1(void *s, size_t len, void *data) {
if (req->obj_size == 0 && end == s) {
WARN("csvReader obj_size is not a number: \"%s\"\n", (char *)s);
}
} else if (csv_params->curr_field_idx == csv_params->op_field_idx) {
if (strncasecmp((char *)s, "read", len) == 0) {
req->op = OP_READ;
} else if (strncasecmp((char *)s, "write", len) == 0) {
req->op = OP_WRITE;
} else if (strncasecmp((char *)s, "get", len) == 0) {
req->op = OP_GET;
} else if (strncasecmp((char *)s, "set", len) == 0) {
req->op = OP_SET;
} else if (strncasecmp((char *)s, "delete", len) == 0) {
req->op = OP_DELETE;
} else {
WARN("unknown operation: \"%s\"\n", (char *)s);
}
} else if (csv_params->curr_field_idx == csv_params->ttl_field_idx) {
req->ttl = (uint32_t)strtoul((char *)s, &end, 0);
} else if (csv_params->curr_field_idx == csv_params->cnt_field_idx) {
reader->n_req_left = (uint64_t)strtoull((char *)s, &end, 0) - 1;
}
Expand All @@ -245,8 +262,6 @@ static inline void csv_cb2(int c, void *data) {
reader_t *reader = (reader_t *)data;
csv_params_t *csv_params = reader->reader_params;
csv_params->curr_field_idx = 1;

// printf("cb2 %d '%c'\n", csv_params->curr_field_idx, c);
}

/**
Expand Down
8 changes: 1 addition & 7 deletions libCacheSim/traceReader/generalReader/lcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ typedef struct lcs_trace_stat {
int32_t n_tenant;

// block cache specific
int32_t block_size; // used in block trace, block size in bytes
int64_t n_uniq_block; // number of unique blocks
int32_t block_size; // used in block trace, block size in bytes

// key-value cache and object cache specific
int32_t n_ttl;
Expand Down Expand Up @@ -111,8 +110,6 @@ typedef char static_assert_lcs_v1_size[(sizeof(struct lcs_req_v1) == 24) ? 1 : -
/******************************************************************************/
/** v2 has more fields, operation and tenant **/
/******************************************************************************/
//
// specifically we add operation and ns
typedef struct __attribute__((packed)) lcs_req_v2 {
uint32_t clock_time;
// this is the hash of key in key-value cache
Expand All @@ -126,9 +123,6 @@ typedef struct __attribute__((packed)) lcs_req_v2 {
// assert the struct size at compile time
typedef char static_assert_lcs_v2_size[(sizeof(struct lcs_req_v2) == 28) ? 1 : -1];




int lcsReader_setup(reader_t *reader);

int lcs_read_one_req(reader_t *reader, request_t *req);
Expand Down

0 comments on commit 8be32b5

Please sign in to comment.