Skip to content

Commit

Permalink
Shuffle data when generate (#401)
Browse files Browse the repository at this point in the history
* remix data

* revert config
  • Loading branch information
SpriCoder authored Jan 29, 2024
1 parent e1fabc7 commit b599a8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ public long getBatchNumber() {
}

/** Add one row into batch, row contains data from all sensors */
protected List<Object> generateOneRow(int colIndex, long stepOffset) throws WorkloadException {
protected List<Object> generateOneRow(int deviceIndex, int colIndex, long stepOffset)
throws WorkloadException {
List<Object> values = new ArrayList<>();
int index = (int) (Math.abs(stepOffset * (deviceIndex + 1)) % config.getWORKLOAD_BUFFER_SIZE());
if (colIndex == -1) {
for (int i = 0; i < config.getSENSOR_NUMBER(); i++) {
values.add(
workloadValues[i][(int) (Math.abs(stepOffset) % config.getWORKLOAD_BUFFER_SIZE())]);
values.add(workloadValues[i][index]);
}
} else {
values.add(
workloadValues[colIndex][
(int) (Math.abs(stepOffset) % config.getWORKLOAD_BUFFER_SIZE())]);
values.add(workloadValues[colIndex][index]);
}
return values;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public IBatch getOneBatch() throws WorkloadException {
(curLoop / config.getDEVICE_NUMBER()) * config.getBATCH_SIZE_PER_WRITE() + batchOffset;
records.add(
new Record(
getCurrentTimestamp(stepOffset), generateOneRow(batch.getColIndex(), stepOffset)));
getCurrentTimestamp(stepOffset),
generateOneRow(deviceSchema.getDeviceId(), batch.getColIndex(), stepOffset)));
}
batch.addSchemaAndContent(deviceSchema, records);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public IBatch getOneBatch() throws WorkloadException {
for (long offset = 0; offset < recordNumPerDevice; offset++, rowOffset++) {
records.add(
new Record(
getCurrentTimestamp(rowOffset), generateOneRow(batch.getColIndex(), rowOffset)));
getCurrentTimestamp(rowOffset),
generateOneRow(deviceSchema.getDeviceId(), batch.getColIndex(), rowOffset)));
}
// move
if (config.isIS_SENSOR_TS_ALIGNMENT()) {
Expand Down

0 comments on commit b599a8e

Please sign in to comment.