|
| 1 | +# Java Snippets |
| 2 | + |
| 3 | +The Java snippets are contained in the `snippets` directory under various Java package directories. They can built using the `pom.xml` in this directory using `mvn package`. The result will be the `sz-sdk-snippets.jar` file ni the `target` directory. |
| 4 | + |
| 5 | +There are several ways to run the code snippets. |
| 6 | + |
| 7 | +## Run Directly |
| 8 | + |
| 9 | +You may run any individual Snippet class directly providing you have a Senzing repository to run it with and the `SENZING_ENGINE_CONFIGURATION_JSON` environment variable set for connecting to that repository. Many of the snippets will find a default data file to run with if run from this directory, but also allow the caller to use a different data file if given by the first command-line arguemnt. |
| 10 | + |
| 11 | +1. Run a snippet that takes no command-line arguments. |
| 12 | + ``` |
| 13 | + java -cp target/sz-sdk-snippets.jar loading.LoadRecords |
| 14 | + ``` |
| 15 | +
|
| 16 | +2. Run a snippet and override the input file using command-line arguments |
| 17 | + ``` |
| 18 | + java -cp target/sz-sdk-snippets.jar loading.LoadRecordsViaLoop ../../resources/data/load-500-with-errors.jsonl |
| 19 | + ``` |
| 20 | +
|
| 21 | +# Run Individually via Runner |
| 22 | +
|
| 23 | +The `com.senzing.runner.SnippetRunner` class will run one or more snippets for you and create a temporary Senzing repository to run |
| 24 | +then against. This is the `Main-Class` of the `sz-sdk-snippets.jar` file so it can be executed using `java -jar target/sz-sdk-snippets.jar`. |
| 25 | +
|
| 26 | +**NOTE:** When code snippets are run this way you cannot specify command-line arguments for individual snippets, nor can you respond to command-line input requests (they will be automatically be responded by the runner -- including forced termination of a snippet that is intended to run indefinitely). |
| 27 | +
|
| 28 | +1. Execute all code snippets: |
| 29 | + ``` |
| 30 | + java -jar target/sz-sdk-snippets.jar all |
| 31 | + ``` |
| 32 | +
|
| 33 | +2. Execute all code snippets in a Java package: |
| 34 | + ``` |
| 35 | + java -jar target/sz-sdk-snippets.jar loading |
| 36 | + ``` |
| 37 | +
|
| 38 | +3. Execute all code snippets from multiple packages: |
| 39 | + ``` |
| 40 | + java -jar target/sz-sdk-snippets.jar loading redo |
| 41 | + ``` |
| 42 | +4. Execute specific code snippets: |
| 43 | + ``` |
| 44 | + java -jar target/sz-sdk-snippets.jar loading.LoadViaLoop loading.LoadViaQueue |
| 45 | + ``` |
| 46 | +5. Mix and match packages with individual snippets: |
| 47 | + ``` |
| 48 | + java -jar target/sz-sdk-snippets.jar redo loading.LoadViaLoop |
| 49 | + ``` |
| 50 | +6. Generate a help message by specifying no arguments: |
| 51 | + ``` |
| 52 | + java -jar target/sz-sdk-snippets.jar |
| 53 | +
|
| 54 | + java -jar sz-sdk-snippets.jar [ all | <group> | <snippet> ]* |
| 55 | + |
| 56 | + - Specifying no arguments will print this message |
| 57 | + - Specifying "all" will run all snippets |
| 58 | + - Specifying one or more groups will run all snippets in those groups |
| 59 | + - Specifying one or more snippets will run those snippet |
| 60 | +
|
| 61 | + Examples: |
| 62 | +
|
| 63 | + java -jar sz-sdk-snippets.jar all |
| 64 | +
|
| 65 | + java -jar sz-sdk-snippets.jar loading.LoadRecords loading.LoadViaFutures |
| 66 | +
|
| 67 | + java -jar sz-sdk-snippets.jar initialization deleting loading.LoadRecords |
| 68 | +
|
| 69 | + Snippet Group Names: |
| 70 | + - configuration |
| 71 | + - deleting |
| 72 | + - information |
| 73 | + - initialization |
| 74 | + - loading |
| 75 | + - redo |
| 76 | + - searching |
| 77 | + - stewardship |
| 78 | +
|
| 79 | + Snippet Names: |
| 80 | + - configuration.AddDataSources |
| 81 | + - configuration.InitDefaultConfig |
| 82 | + - deleting.DeleteViaFutures |
| 83 | + - deleting.DeleteViaLoop |
| 84 | + - deleting.DeleteWithInfoViaFutures |
| 85 | + - information.CheckDatastorePerformance |
| 86 | + - information.GetDatastoreInfo |
| 87 | + - information.GetLicense |
| 88 | + - information.GetVersion |
| 89 | + - initialization.EnginePriming |
| 90 | + - initialization.EnvironmentAndHubs |
| 91 | + - initialization.PurgeRepository |
| 92 | + - loading.LoadRecords |
| 93 | + - loading.LoadTruthSetWithInfoViaLoop |
| 94 | + - loading.LoadViaFutures |
| 95 | + - loading.LoadViaLoop |
| 96 | + - loading.LoadViaQueue |
| 97 | + - loading.LoadWithInfoViaFutures |
| 98 | + - loading.LoadWithStatsViaLoop |
| 99 | + - redo.LoadWithRedoViaLoop |
| 100 | + - redo.RedoContinuous |
| 101 | + - redo.RedoContinuousViaFutures |
| 102 | + - redo.RedoWithInfoContinuous |
| 103 | + - searching.SearchRecords |
| 104 | + - searching.SearchViaFutures |
| 105 | + - stewardship.ForceResolve |
| 106 | + - stewardship.ForceUnresolve |
| 107 | + ``` |
0 commit comments