dump-segment tool

The DumpSegment tool can be used to dump the metadata or contents of an Apache Druid segment for debugging purposes. Note that the dump is not necessarily a full-fidelity translation of the segment. In particular, not all metadata is included, and complex metric values may not be complete.

To run the tool, point it at a segment directory and provide a file for writing output:

  1. java -classpath "/my/druid/lib/*" -Ddruid.extensions.loadList="[]" org.apache.druid.cli.Main \
  2. tools dump-segment \
  3. --directory /home/druid/path/to/segment/ \
  4. --out /home/druid/output.txt

Output format

Data dumps

By default, or with --dump rows, this tool dumps rows of the segment as newline-separate JSON objects, with one object per line, using the default serialization for each column. Normally all columns are included, but if you like, you can limit the dump to specific columns with --column name.

For example, one line might look like this when pretty-printed:

  1. {
  2. "__time": 1442018818771,
  3. "added": 36,
  4. "channel": "#en.wikipedia",
  5. "cityName": null,
  6. "comment": "added project",
  7. "count": 1,
  8. "countryIsoCode": null,
  9. "countryName": null,
  10. "deleted": 0,
  11. "delta": 36,
  12. "isAnonymous": "false",
  13. "isMinor": "false",
  14. "isNew": "false",
  15. "isRobot": "false",
  16. "isUnpatrolled": "false",
  17. "iuser": "00001553",
  18. "metroCode": null,
  19. "namespace": "Talk",
  20. "page": "Talk:Oswald Tilghman",
  21. "regionIsoCode": null,
  22. "regionName": null,
  23. "user": "GELongstreet"
  24. }

Metadata dumps

With --dump metadata, this tool dumps metadata instead of rows. Metadata dumps generated by this tool are in the same format as returned by the SegmentMetadata query.

Bitmap dumps

With --dump bitmaps, this tool will dump bitmap indexes instead of rows. Bitmap dumps generated by this tool include dictionary-encoded string columns only. The output contains a field “bitmapSerdeFactory” describing the type of bitmaps used in the segment, and a field “bitmaps” containing the bitmaps for each value of each column. These are base64 encoded by default, but you can also dump them as lists of row numbers with --decompress-bitmaps.

Normally all columns are included, but if you like, you can limit the dump to specific columns with --column name.

Sample output:

  1. {
  2. "bitmapSerdeFactory": {
  3. "type": "roaring"
  4. },
  5. "bitmaps": {
  6. "isRobot": {
  7. "false": "//aExfu+Nv3X...",
  8. "true": "gAl7OoRByQ..."
  9. }
  10. }
  11. }

Nested column dumps

With --dump nested, this tool can be used to examine Druid nested columns. Using nested always requires exactly one --column name argument, and takes an optional argument to specify a specific nested field in JSONPath syntax, --nested-path $.path.to.field. If --nested-path is not specified, the output will contain the list of nested fields and their types, the global value dictionaries, and the list of null rows.

Sample output:

  1. {
  2. "nest": {
  3. "fields": [
  4. {
  5. "path": "$.x",
  6. "types": [
  7. "LONG"
  8. ]
  9. },
  10. {
  11. "path": "$.y",
  12. "types": [
  13. "DOUBLE"
  14. ]
  15. },
  16. {
  17. "path": "$.z",
  18. "types": [
  19. "STRING"
  20. ]
  21. }
  22. ],
  23. "dictionaries": {
  24. "strings": [
  25. {
  26. "globalId": 0,
  27. "value": null
  28. },
  29. {
  30. "globalId": 1,
  31. "value": "a"
  32. },
  33. {
  34. "globalId": 2,
  35. "value": "b"
  36. }
  37. ],
  38. "longs": [
  39. {
  40. "globalId": 3,
  41. "value": 100
  42. },
  43. {
  44. "globalId": 4,
  45. "value": 200
  46. },
  47. {
  48. "globalId": 5,
  49. "value": 400
  50. }
  51. ],
  52. "doubles": [
  53. {
  54. "globalId": 6,
  55. "value": 1.1
  56. },
  57. {
  58. "globalId": 7,
  59. "value": 2.2
  60. },
  61. {
  62. "globalId": 8,
  63. "value": 3.3
  64. }
  65. ],
  66. "nullRows": []
  67. }
  68. }
  69. }

If --nested-path is specified, the output will instead contain the types of the nested field, the local value dictionary, including the ‘global’ dictionary id and value, the uncompressed bitmap index for each value (list of row numbers which contain the value), and a dump of the column itself, which contains the row number, raw JSON form of the nested column itself, the local dictionary id of the field for that row, and the value for the field for the row.

Sample output:

  1. {
  2. "bitmapSerdeFactory": {
  3. "type": "roaring"
  4. },
  5. "nest": {
  6. "$.x": {
  7. "types": [
  8. "LONG"
  9. ],
  10. "dictionary": [
  11. {
  12. "localId": 0,
  13. "globalId": 0,
  14. "value": null,
  15. "rows": [
  16. 4
  17. ]
  18. },
  19. {
  20. "localId": 1,
  21. "globalId": 3,
  22. "value": "100",
  23. "rows": [
  24. 3
  25. ]
  26. },
  27. {
  28. "localId": 2,
  29. "globalId": 4,
  30. "value": "200",
  31. "rows": [
  32. 0,
  33. 2
  34. ]
  35. },
  36. {
  37. "localId": 3,
  38. "globalId": 5,
  39. "value": "400",
  40. "rows": [
  41. 1
  42. ]
  43. }
  44. ],
  45. "column": [
  46. {
  47. "row": 0,
  48. "raw": {
  49. "x": 200,
  50. "y": 2.2
  51. },
  52. "fieldId": 2,
  53. "fieldValue": "200"
  54. },
  55. {
  56. "row": 1,
  57. "raw": {
  58. "x": 400,
  59. "y": 1.1,
  60. "z": "a"
  61. },
  62. "fieldId": 3,
  63. "fieldValue": "400"
  64. },
  65. {
  66. "row": 2,
  67. "raw": {
  68. "x": 200,
  69. "z": "b"
  70. },
  71. "fieldId": 2,
  72. "fieldValue": "200"
  73. },
  74. {
  75. "row": 3,
  76. "raw": {
  77. "x": 100,
  78. "y": 1.1,
  79. "z": "a"
  80. },
  81. "fieldId": 1,
  82. "fieldValue": "100"
  83. },
  84. {
  85. "row": 4,
  86. "raw": {
  87. "y": 3.3,
  88. "z": "b"
  89. },
  90. "fieldId": 0,
  91. "fieldValue": null
  92. }
  93. ]
  94. }
  95. }
  96. }

Command line arguments

argumentdescriptionrequired?
—directory fileDirectory containing segment data. This could be generated by unzipping an “index.zip” from deep storage.yes
—output fileFile to write to, or omit to write to stdout.yes
—dump TYPEDump either ‘rows’ (default), ‘metadata’, ‘bitmaps’, or ‘nested’ for examining nested columns.no
—column columnNameColumn to include. Specify multiple times for multiple columns, or omit to include all columns.no
—filter jsonJSON-encoded query filter. Omit to include all rows. Only used if dumping rows.no
—time-iso8601Format __time column in ISO8601 format rather than long. Only used if dumping rows.no
—decompress-bitmapsDump bitmaps as arrays rather than base64-encoded compressed bitmaps. Only used if dumping bitmaps.no
—nested-pathSpecify a specific nested column field using JSONPath syntax. Only used if dumping a nested column.no