neo4j_bolt 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/bin/neo4j_bolt +4 -1
- data/lib/neo4j_bolt/version.rb +1 -1
- data/lib/neo4j_bolt.rb +31 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38ed2e6727f1bc4baccc838b195d72a2392bbb82788598d704a1e81bd0f20de0
|
|
4
|
+
data.tar.gz: d781a67c3eee09dd9e32a9af60fe1fb65a61bb8afddb96307dd897cbcd99ddf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1d4c318c5adb68878da6368dc8d694a63c79cc953ab0e87ffe5aceaf77ce9d47d06b35a80cef8ea835ac90e6753974a59c2bb2bd9088f144fdf8761976b9b8a
|
|
7
|
+
data.tar.gz: d28fd8341cbbfe89391c7685331ed8fc666864edb7222f8ccb3530ddd3e93b2bad68d9fa6ebdf75049cad99c8d68926b356e3b55fadcb795e017dfc0be9d0f22
|
data/README.md
CHANGED
|
@@ -159,6 +159,13 @@ end
|
|
|
159
159
|
|
|
160
160
|
Passing `progress_io:` is optional for the Ruby API. The CLI always reports dump/load progress on stderr, so dump data written to stdout remains safe to redirect or pipe. In `auto` mode a terminal gets a colored, in-place progress bar while redirected stderr receives periodic plain-text progress lines. Set `NEO4J_BOLT_PROGRESS=pretty` to force the terminal display through a container or other wrapper that hides the TTY, or `NEO4J_BOLT_PROGRESS=plain` to force log-friendly output. `NO_COLOR` disables colors without disabling the in-place display.
|
|
161
161
|
|
|
162
|
+
Both `dump` and `load` accept `--color COLOR` to choose the spinner and filled progress-bar accent. The default is `cyan`. The Ruby API exposes the same setting as `progress_color:`. Available colors are `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `bright-red`, `bright-green`, `bright-yellow`, `bright-blue`, `bright-magenta`, `bright-cyan`, and `bright-white`.
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
neo4j_bolt dump --color magenta -o database.dump
|
|
166
|
+
neo4j_bolt load --color bright-blue database.dump
|
|
167
|
+
```
|
|
168
|
+
|
|
162
169
|
The `0, 1, 2, ...` IDs are synthetic dump-local IDs. Database-internal IDs and element IDs are never written to the persistent format. Dumping keeps the count, node, and relationship reads in one transaction, so the driver-provided entity identity used to connect the two streamed result sets stays within Neo4j's transaction-scoped identity guarantee. To keep dump numbering deterministic, ordering uses `elementId()` on modern Neo4j and an internal `id()` fallback only on Neo4j 4.4, where `elementId()` does not exist. Old Neo4jBolt dumps remain loadable.
|
|
163
170
|
|
|
164
171
|
For relational loads, the adapter assigns a random temporary label and dump-ID property to imported nodes. After the nodes are committed it builds a temporary `neo4j_bolt_` index on that property, uses indexed lookups while creating relationships, drops the index, and removes the temporary metadata in batches. No database-internal identity is carried from one load transaction to another. Loading a relational dump therefore requires permission to create and drop an index.
|
|
@@ -175,8 +182,8 @@ The `neo4j_bolt` executable retains these commands:
|
|
|
175
182
|
| --- | --- |
|
|
176
183
|
| `neo4j_bolt console` | Open an IRB console with Neo4jBolt loaded |
|
|
177
184
|
| `neo4j_bolt clear --srsly` | Delete all nodes and relationships |
|
|
178
|
-
| `neo4j_bolt dump` | Write the textual database dump |
|
|
179
|
-
| `neo4j_bolt load [--force] [--batch-size N] PATH` | Load a textual dump |
|
|
185
|
+
| `neo4j_bolt dump [--color COLOR]` | Write the textual database dump |
|
|
186
|
+
| `neo4j_bolt load [--force] [--batch-size N] [--color COLOR] PATH` | Load a textual dump |
|
|
180
187
|
| `neo4j_bolt index ls` | List constraints and indexes |
|
|
181
188
|
| `neo4j_bolt index rm --force` | Remove all constraints and indexes |
|
|
182
189
|
| `neo4j_bolt visualize` | Generate a GraphViz document |
|
data/bin/neo4j_bolt
CHANGED
|
@@ -47,9 +47,10 @@ class App
|
|
|
47
47
|
long_desc 'Dump all nodes and relationships.'
|
|
48
48
|
command :dump do |c|
|
|
49
49
|
c.flag [:o, 'out-file'.to_sym], :default_value => '/dev/stdout'
|
|
50
|
+
c.flag [:color], :default_value => 'cyan', :desc => 'progress accent color'
|
|
50
51
|
c.action do |global_options, options|
|
|
51
52
|
File.open(options['out-file'.to_sym], 'w') do |f|
|
|
52
|
-
dump_database(f, progress_io: $stderr)
|
|
53
|
+
dump_database(f, progress_io: $stderr, progress_color: options[:color])
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
end
|
|
@@ -63,6 +64,7 @@ class App
|
|
|
63
64
|
c.switch [:f, :force], :default_value => false, :desc => 'force appending nodes even if the database is not empty'
|
|
64
65
|
c.flag [:b, 'batch-size'.to_sym], :default_value => Neo4jBolt::LOAD_INITIAL_BATCH_SIZE,
|
|
65
66
|
:desc => 'initial batch size; automatically reduced on transaction-memory errors'
|
|
67
|
+
c.flag [:color], :default_value => 'cyan', :desc => 'progress accent color'
|
|
66
68
|
c.action do |global_options, options, args|
|
|
67
69
|
help_now!('input path is required') if args.empty?
|
|
68
70
|
path = args.shift
|
|
@@ -71,6 +73,7 @@ class App
|
|
|
71
73
|
f,
|
|
72
74
|
force_append: options[:force],
|
|
73
75
|
progress_io: $stderr,
|
|
76
|
+
progress_color: options[:color],
|
|
74
77
|
initial_batch_size: options['batch-size'.to_sym]
|
|
75
78
|
)
|
|
76
79
|
end
|
data/lib/neo4j_bolt/version.rb
CHANGED
data/lib/neo4j_bolt.rb
CHANGED
|
@@ -29,13 +29,35 @@ module Neo4jBolt
|
|
|
29
29
|
reset: "\e[0m",
|
|
30
30
|
bold: "\e[1m",
|
|
31
31
|
dim: "\e[2m",
|
|
32
|
-
|
|
32
|
+
red: "\e[31m",
|
|
33
33
|
green: "\e[32m",
|
|
34
|
-
yellow: "\e[33m"
|
|
34
|
+
yellow: "\e[33m",
|
|
35
|
+
blue: "\e[34m",
|
|
36
|
+
magenta: "\e[35m",
|
|
37
|
+
cyan: "\e[36m",
|
|
38
|
+
white: "\e[37m",
|
|
39
|
+
bright_red: "\e[91m",
|
|
40
|
+
bright_green: "\e[92m",
|
|
41
|
+
bright_yellow: "\e[93m",
|
|
42
|
+
bright_blue: "\e[94m",
|
|
43
|
+
bright_magenta: "\e[95m",
|
|
44
|
+
bright_cyan: "\e[96m",
|
|
45
|
+
bright_white: "\e[97m"
|
|
46
|
+
}.freeze
|
|
47
|
+
ACCENT_STYLES = {
|
|
48
|
+
"red" => :red, "green" => :green, "yellow" => :yellow, "blue" => :blue,
|
|
49
|
+
"magenta" => :magenta, "cyan" => :cyan, "white" => :white,
|
|
50
|
+
"bright-red" => :bright_red, "bright-green" => :bright_green,
|
|
51
|
+
"bright-yellow" => :bright_yellow, "bright-blue" => :bright_blue,
|
|
52
|
+
"bright-magenta" => :bright_magenta, "bright-cyan" => :bright_cyan,
|
|
53
|
+
"bright-white" => :bright_white
|
|
35
54
|
}.freeze
|
|
36
55
|
|
|
37
|
-
def initialize(io)
|
|
56
|
+
def initialize(io, color: "cyan")
|
|
38
57
|
@io = io
|
|
58
|
+
@accent_style = ACCENT_STYLES.fetch(color.to_s) do
|
|
59
|
+
raise ArgumentError, "progress color must be one of: #{ACCENT_STYLES.keys.join(', ')}"
|
|
60
|
+
end
|
|
39
61
|
mode = ENV.fetch("NEO4J_BOLT_PROGRESS", "auto")
|
|
40
62
|
unless %w[auto pretty plain].include?(mode)
|
|
41
63
|
raise ArgumentError, "NEO4J_BOLT_PROGRESS must be auto, pretty, or plain"
|
|
@@ -110,7 +132,7 @@ module Neo4jBolt
|
|
|
110
132
|
spinner = SPINNER[@spinner_index % SPINNER.length]
|
|
111
133
|
@spinner_index += 1
|
|
112
134
|
|
|
113
|
-
parts = [color(
|
|
135
|
+
parts = [color(@accent_style, spinner), color(:bold, label)]
|
|
114
136
|
if percent
|
|
115
137
|
percent = [[percent.to_i, 0].max, 100].min
|
|
116
138
|
parts << progress_bar(percent)
|
|
@@ -123,7 +145,7 @@ module Neo4jBolt
|
|
|
123
145
|
def progress_bar(percent)
|
|
124
146
|
filled = (percent * BAR_WIDTH / 100.0).round
|
|
125
147
|
empty = BAR_WIDTH - filled
|
|
126
|
-
"#{color(
|
|
148
|
+
"#{color(@accent_style, '━' * filled)}#{color(:dim, '─' * empty)}"
|
|
127
149
|
end
|
|
128
150
|
|
|
129
151
|
def terminal_parts(message, strip_percent: false)
|
|
@@ -514,8 +536,8 @@ module Neo4jBolt
|
|
|
514
536
|
nil
|
|
515
537
|
end
|
|
516
538
|
|
|
517
|
-
def dump_database(io, progress_io: nil)
|
|
518
|
-
progress = ProgressReporter.new(progress_io)
|
|
539
|
+
def dump_database(io, progress_io: nil, progress_color: "cyan")
|
|
540
|
+
progress = ProgressReporter.new(progress_io, color: progress_color)
|
|
519
541
|
dumped_nodes = 0
|
|
520
542
|
dumped_relationships = 0
|
|
521
543
|
|
|
@@ -574,7 +596,7 @@ module Neo4jBolt
|
|
|
574
596
|
progress&.close
|
|
575
597
|
end
|
|
576
598
|
|
|
577
|
-
def load_database_dump(io, force_append: false, progress_io: nil,
|
|
599
|
+
def load_database_dump(io, force_append: false, progress_io: nil, progress_color: "cyan",
|
|
578
600
|
initial_batch_size: LOAD_INITIAL_BATCH_SIZE)
|
|
579
601
|
raise Error, "load_database_dump cannot run inside a transaction" if transaction_context
|
|
580
602
|
|
|
@@ -586,7 +608,7 @@ module Neo4jBolt
|
|
|
586
608
|
raise Error, "There are nodes in this database, exiting now." unless count.zero?
|
|
587
609
|
end
|
|
588
610
|
|
|
589
|
-
progress = ProgressReporter.new(progress_io)
|
|
611
|
+
progress = ProgressReporter.new(progress_io, color: progress_color)
|
|
590
612
|
node_batches = Hash.new { |hash, key| hash[key] = [] }
|
|
591
613
|
relationship_batches = Hash.new { |hash, key| hash[key] = [] }
|
|
592
614
|
total_nodes, total_relationships = parse_dump(io, node_batches, relationship_batches, progress)
|