Skip to content

Commit 53004df

Browse files
authored
Support testing of non-deterministic programs (#189)
1 parent 30b5ff3 commit 53004df

File tree

123 files changed

+1238
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1238
-34
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
@SuppressWarnings("unchecked")
3+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
4+
Map<String, String> offsetMap;
5+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
6+
offsetMap = new HashMap<>();
7+
} else {
8+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
9+
}
10+
return offsetMap;
11+
}
12+
13+
This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:
14+
15+
1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.
16+
2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.
17+
3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.
18+
4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.
19+
20+
The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map<String, String>`. Since the actual type of the map is not known at compile time, the compiler issues a warning. The `@SuppressWarnings` annotation is used to suppress this warning.
21+
22+
EVALUATION:
23+
The similarity (Levenshtein) between this answer and the ground truth is:
24+
0.34065934065934067
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
@SuppressWarnings("unchecked")
3+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
4+
Map<String, String> offsetMap;
5+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
6+
offsetMap = new HashMap<>();
7+
} else {
8+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
9+
}
10+
return offsetMap;
11+
}
12+
13+
This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:
14+
15+
1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.
16+
2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.
17+
3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.
18+
4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.
19+
20+
The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential unchecked warning that might occur due to the raw `Map` type used in the `else` block.
21+
22+
EVALUATION:
23+
The similarity (Levenshtein) between this answer and the ground truth is:
24+
0.3044334975369458
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
@SuppressWarnings("unchecked")
3+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
4+
Map<String, String> offsetMap;
5+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
6+
offsetMap = new HashMap<>();
7+
} else {
8+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
9+
}
10+
return offsetMap;
11+
}
12+
13+
This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:
14+
15+
1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.
16+
2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.
17+
3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.
18+
4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.
19+
20+
The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map<String, String>`. The compiler knows that the actual type of the `Map` is safe, but it still generates a warning. The `@SuppressWarnings` annotation is used to suppress this warning.
21+
22+
EVALUATION:
23+
The similarity (Levenshtein) between this answer and the ground truth is:
24+
0.32053291536050155
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
@SuppressWarnings("unchecked")
3+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
4+
Map<String, String> offsetMap;
5+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
6+
offsetMap = new HashMap<>();
7+
} else {
8+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
9+
}
10+
return offsetMap;
11+
}
12+
13+
This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:
14+
15+
1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.
16+
2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes a new `HashMap<String, String>` and assigns it to `offsetMap`.
17+
3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>` and assigns it to `offsetMap`.
18+
4. Finally, it returns the `offsetMap`.
19+
20+
The `@SuppressWarnings("unchecked")` annotation is used to suppress a compile-time warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the compiler doesn't know that it's safe to cast it to `Map<String, String>`. However, since the method is designed to handle only `Map<String, String>` objects, this warning can be safely ignored.
21+
22+
EVALUATION:
23+
The similarity (Levenshtein) between this answer and the ground truth is:
24+
0.3528336380255942
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
@SuppressWarnings("unchecked")
3+
public static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {
4+
Map<String, String> offsetMap;
5+
if (lastSourceOffset == null || lastSourceOffset.isEmpty()) {
6+
offsetMap = new HashMap<>();
7+
} else {
8+
offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class);
9+
}
10+
return offsetMap;
11+
}
12+
13+
This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:
14+
15+
1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.
16+
2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.
17+
3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>`. The `readValue` method is used for this purpose, with `Map.class` as the second argument, which specifies the expected type of the deserialized object.
18+
4. Finally, the method returns the `offsetMap`, which now contains the deserialized data.
19+
20+
The `@SuppressWarnings("unchecked")` annotation is used to suppress a potential warning about the raw use of the `Map` type. This is because the `JSON_MAPPER.readValue` method returns a `Map` object, but the method signature declares it as `Map<String, String>`. The compiler knows that the actual type of the `Map` object will be a `Map<String, String>`, but the annotation is used to suppress the warning.
21+
22+
EVALUATION:
23+
The similarity (Levenshtein) between this answer and the ground truth is:
24+
0.31687898089171973
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"input": {"source_code": "@SuppressWarnings(\"unchecked\")\npublic static Map<String, String> deserializeOffsetMap(String lastSourceOffset) throws IOException {\n Map<String, String> offsetMap;\n if (lastSourceOffset == null || lastSourceOffset.isEmpty()) { \n offsetMap = new HashMap<>(); \n } else {\n offsetMap = JSON_MAPPER.readValue(lastSourceOffset, Map.class); \n }\n return offsetMap;\n}\n", "repo_info": {"repo": "streamsets/datacollector", "path": "stagesupport/src/main/java/com/.../OffsetUtil.java", "function_name": "OffsetUtil.deserializeOffsetMap"}}, "output": "This Java method, `deserializeOffsetMap`, is used to deserialize a JSON string into a `Map<String, String>`. Here's a breakdown of the code:\n\n1. The method takes a single parameter, `lastSourceOffset`, which is expected to be a JSON string.\n2. It first checks if `lastSourceOffset` is either `null` or an empty string. If true, it initializes an empty `HashMap` and assigns it to `offsetMap`.\n3. If `lastSourceOffset` is not `null` or empty, it uses the `JSON_MAPPER` object (presumably an instance of `ObjectMapper` from the Jackson library) to deserialize the JSON string into a `Map<String, String>`. The `readValue` method is used for this purpose, with `Map.class` as the type argument.\n4. Finally, the method returns the deserialized `Map<String, String>`.\n\nThe `@SuppressWarnings(\"unchecked\")` annotation is used to suppress a potential unchecked warning that might occur due to the raw type `Map.class` being used as the type argument for `JSON_MAPPER.readValue`.", "metric": 0.2929085303186023}

0 commit comments

Comments
 (0)