7
7
8
8
package org .elasticsearch .xpack .profiler ;
9
9
10
- import org .elasticsearch .xcontent .ObjectPath ;
11
10
import org .elasticsearch .xcontent .ToXContentObject ;
12
11
import org .elasticsearch .xcontent .XContentBuilder ;
13
12
18
17
import java .util .Objects ;
19
18
20
19
final class StackFrame implements ToXContentObject {
21
- private static final String [] PATH_FILE_NAME = new String [] { "Stackframe" , "file" , "name" };
22
- private static final String [] PATH_FUNCTION_NAME = new String [] { "Stackframe" , "function" , "name" };
23
- private static final String [] PATH_FUNCTION_OFFSET = new String [] { "Stackframe" , "function" , "offset" };
24
- private static final String [] PATH_LINE_NUMBER = new String [] { "Stackframe" , "line" , "number" };
25
20
List <String > fileName ;
26
21
List <String > functionName ;
27
22
List <Integer > functionOffset ;
@@ -46,26 +41,12 @@ private static <T> List<T> listOf(Object o) {
46
41
}
47
42
48
43
public static StackFrame fromSource (Map <String , Object > source ) {
49
- // stack frames may either be stored with synthetic source or regular one
50
- // which results either in a nested or flat document structure.
51
-
52
- if (source .containsKey ("Stackframe" )) {
53
- // synthetic source
54
- return new StackFrame (
55
- ObjectPath .eval (PATH_FILE_NAME , source ),
56
- ObjectPath .eval (PATH_FUNCTION_NAME , source ),
57
- ObjectPath .eval (PATH_FUNCTION_OFFSET , source ),
58
- ObjectPath .eval (PATH_LINE_NUMBER , source )
59
- );
60
- } else {
61
- // regular source
62
- return new StackFrame (
63
- source .get ("Stackframe.file.name" ),
64
- source .get ("Stackframe.function.name" ),
65
- source .get ("Stackframe.function.offset" ),
66
- source .get ("Stackframe.line.number" )
67
- );
68
- }
44
+ return new StackFrame (
45
+ source .get ("Stackframe.file.name" ),
46
+ source .get ("Stackframe.function.name" ),
47
+ source .get ("Stackframe.function.offset" ),
48
+ source .get ("Stackframe.line.number" )
49
+ );
69
50
}
70
51
71
52
@ Override
0 commit comments