-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenIndex.ecl
1348 lines (1256 loc) · 64.2 KB
/
GenIndex.ecl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
IMPORT $ AS DataMgmt;
IMPORT Std;
EXPORT GenIndex := MODULE(DataMgmt.Common)
//--------------------------------------------------------------------------
// Internal Declarations and Functions
//--------------------------------------------------------------------------
SHARED ROXIE_PACKAGEMAP_NAME := 'genindex_packagemap.pkg';
SHARED DEFAULT_ROXIE_TARGET := 'roxie';
SHARED DEFAULT_ROXIE_PROCESS := '*';
EXPORT DALI_LOCK_DELAY := 300; // milliseconds
SHARED _CleanName(STRING s) := REGEXREPLACE('::+', Std.Str.ToLowerCase(TRIM(Std.Str.FilterOut(s, '~'), LEFT, RIGHT)), '_');
SHARED _VirtualSuperkeyPathForDataStore(STRING indexStorePath) := 'virtual_' + _CleanName(indexStorePath);
SHARED _PackageMapNameForQuery(STRING roxieQueryName) := 'query_' + _CleanName(roxieQueryName) + '.pkg';
SHARED _PackageNameForSuperkeyPath(STRING superkeyPath) := 'data_' + _CleanName(superkeyPath) + '.pkg';
SHARED _PartNameForSuperkeyPath(STRING superkeyPath) := 'part_' + _CleanName(superkeyPath) + '.pkg';
SHARED FilePathLayout := RECORD
STRING path;
END;
/**
* Local helper function for checking the plattform's current version
*
* @param v The minimum platform version in either xx.xx.xx, xx.xx,
* or xx format (where xx is an integer and does not need
* to be zero-padded)
*
* @return If TRUE, the platform's current version is equal to or higher than
* the argument.
*/
SHARED PlatformVersionCheck(STRING v) := FUNCTION
major := (INTEGER)REGEXFIND('^(\\d+)', v, 1);
minor := (INTEGER)REGEXFIND('^\\d+\\.(\\d+)', v, 1);
subminor := (INTEGER)REGEXFIND('^\\d+\\.\\d+\\.(\\d+)', v, 1);
RETURN MAP
(
__ecl_version_major__ > major => TRUE,
__ecl_version_major__ = major AND __ecl_version_minor__ > minor => TRUE,
__ecl_version_major__ = major AND __ecl_version_minor__ = minor AND __ecl_version_subminor__ >= subminor => TRUE,
FALSE
);
END;
#IF(PlatformVersionCheck('7.0.0'))
EXPORT DEFAULT_ESP_URL := Std.File.GetEspURL();
#ELSE
EXPORT DEFAULT_ESP_URL := '';
#END
/**
* Helper function for creating the Authorization header value for
* authenticated SOAPCALL requests.
*
* @param username The user name to use when connecting
* to the cluster; REQUIRED
* @param userPW The username password to use when
* connecting to the cluster; REQUIRED
*
* @return Authorization header value, or an empty string if username
* is empty (SOAPCALL omits the header if the return value
* is an empty string).
*/
SHARED CreateAuthHeaderValue(STRING username, STRING userPW) := IF
(
TRIM(username, ALL) != '',
'Basic ' + Std.Str.EncodeBase64((DATA)(TRIM(username, ALL) + ':' + TRIM(userPW, LEFT, RIGHT))),
''
);
/**
* Local helper function that creates a ROXIE packagemap string that defines
* the base package names for all datastores that a ROXIE query references.
*
* @param roxieQueryName The name of the ROXIE query for which we are
* building this packagemap; REQUIRED
* @param superkeyPathList A dataset in DATASET(FilePathLayout) format
* defining the physical superkeys that the
* query will reference; these physical
* superkey paths will be used to construct
* data package names, which are what are
* actually written to the packagemap;
* REQUIRED
*
* @return String in ROXIE packagemap format defining the data packages
* that will be created and used to manage the actual superkey
* references
*
* @see CreateSuperkeyPackageMapString
*/
SHARED CreateROXIEBasePackageMapString(STRING roxieQueryName,
DATASET(FilePathLayout) superkeyPathList) := FUNCTION
StringRec := RECORD
STRING s;
END;
// Create packagemap-compatible string fragments that reference the
// data packages
basePackageDefinitions := PROJECT
(
superkeyPathList,
TRANSFORM
(
StringRec,
SELF.s := '<Base id="' + _PackageNameForSuperkeyPath(LEFT.path) + '"/>';
)
);
// Collapse to a single string
basePackageDefinitionStr := Std.Str.CombineWords((SET OF STRING)SET(basePackageDefinitions, s), '');
// Wrap the query definition (query package name plus references to
// data packages)
queryDefinition := '<Package id="' + roxieQueryName + '">' + basePackageDefinitionStr + '</Package>';
// Wrap the entire thing up with the right XML tag
finalDefinition := '<RoxiePackages>' + queryDefinition + '</RoxiePackages>';
RETURN finalDefinition;
END;
/**
* Local helper function that creates a ROXIE packagemap-compatible
* data package string. The data package will contain virtual superkey
* pathnames (which should be used by the ROXIE queries to access the
* indexes) along with individual citations for all physical subkeys
* given. The data package itself is referenced by the packagemap
* created with CreateROXIEBasePackageMapString().
*
* @param indexStorePath The full path of the generational data
* store; REQUIRED
* @param subkeys A dataset in
* DATASET(Std.File.FsLogicalFileNameRecord)
* format containing full paths to
* physical subkeys that should be
* included in the data package;
* REQUIRED
*
* @return String in ROXIE packagemap format defining the contents of
* one data package.
*
* @see CreateROXIEBasePackageMapString
*/
SHARED CreateSuperkeyPackageMapString(STRING indexStorePath,
DATASET(Std.File.FsLogicalFileNameRecord) subkeys) := FUNCTION
StringRec := RECORD
STRING s;
END;
superkeyPath := CurrentPath(indexStorePath);
// Create packagemap-compatible string fragments that reference the
// subkeys
subkeyDefinitions := PROJECT
(
subkeys,
TRANSFORM
(
StringRec,
SELF.s := '<SubFile value="' + LEFT.name + '"/>';
)
);
// Collapse to a single string
subkeyDefinitionStr0 := Std.Str.CombineWords((SET OF STRING)SET(subkeyDefinitions, s), '');
// Make sure an empty subfile tag is included if we have no subkeys
subkeyDefinitionStr := IF(EXISTS(subkeyDefinitions), subkeyDefinitionStr0, '<SubFile/>');
// Wrap the subkey declarations in a superfile tag
superkeyDefinitionStr := '<SuperFile id="' + _VirtualSuperkeyPathForDataStore(indexStorePath) + '">' + subkeyDefinitionStr + '</SuperFile>';
// Wrap the query definition (query package name plus references to
// data packages)
queryDefinition := '<Package id="' + _PackageNameForSuperkeyPath(superkeyPath) + '">' + superkeyDefinitionStr + '</Package>';
// Wrap the entire thing up with the right XML tag
finalDefinition := '<RoxiePackages>' + queryDefinition + '</RoxiePackages>';
RETURN finalDefinition;
END;
/**
* Helper function that adds or updates a packagemap part via web service
* calls.
*
* Note that this function requires HPCC 6.0.0 or later to succeed.
*
* This function returns a value but will likely often need to be called
* in an action context, such as within a SEQUENTIAL set of commands
* that includes superfile management. You can wrap the call to this
* function in an EVALUATE() to allow that construct to work.
*
* @param packagePartName The name to use when creating this
* packagemap string, typically from
* a call to _PartNameForSuperkeyPath();
* it is important to use the same
* name when referencing the same
* data package, as updates are
* applied at the data package level
* and they completely override any
* previous settings; REQUIRED
* @param packageMapString The constructed packagemap string
* to send; REQUIRED
* @param espURL The full URL to the ESP service,
* which is the same as the URL used
* for ECL Watch; REQUIRED
* @param roxieTargetName The name of the target ROXIE that
* will receive the new packagemap;
* REQUIRED
* @param roxieProcessName The name of the specific ROXIE
* process to target; REQUIRED
* @param sendActivateCommand If TRUE, an ActivatePackage web
* service call is made after the
* packagemap is sent (this is
* required for some packagemap
* instantiations, such as those from
* the CreateROXIEBasePackageMapString()
* call); REQUIRED
* @param _username The user name to use when connecting
* to the cluster; may be an empty
* string if authentication is not
* needed; REQUIRED
* @param _userPW The username password to use when
* connecting to the cluster; ignored
* if username is empty; REQUIRED
*
* @return A numeric code indicating success (zero = success).
*/
SHARED AddPackageMapPart(STRING packagePartName,
STRING packageMapString,
STRING espURL,
STRING roxieTargetName,
STRING roxieProcessName,
BOOLEAN sendActivateCommand,
STRING _username,
STRING _userPW) := FUNCTION
espHost := REGEXREPLACE('/+$', espURL, '');
auth := CreateAuthHeaderValue(_username, _userPW);
StatusRec := RECORD
INTEGER code {XPATH('Code')};
STRING description {XPATH('Description')};
END;
addPartToPackageMapResponse := SOAPCALL
(
espHost + '/WsPackageProcess/',
'AddPartToPackageMap',
{
STRING targetCluster {XPATH('Target')} := roxieTargetName;
STRING targetProcess {XPATH('Process')} := roxieProcessName;
STRING packageMapID {XPATH('PackageMap')} := ROXIE_PACKAGEMAP_NAME;
STRING partName {XPATH('PartName')} := packagePartName;
STRING packageMapData {XPATH('Content')} := packageMapString;
BOOLEAN deletePreviousPackagePart {XPATH('DeletePrevious')} := TRUE;
STRING daliIP {XPATH('DaliIp')} := Std.System.Thorlib.DaliServer();
},
StatusRec,
XPATH('AddPartToPackageMapResponse/status'),
HTTPHEADER('Authorization', auth)
);
activatePackageResponse := SOAPCALL
(
espHost + '/WsPackageProcess/',
'ActivatePackage',
{
STRING targetCluster {XPATH('Target')} := roxieTargetName;
STRING targetProcess {XPATH('Process')} := roxieProcessName;
STRING packageMapID {XPATH('PackageMap')} := ROXIE_PACKAGEMAP_NAME;
},
StatusRec,
XPATH('ActivatePackageResponse/status'),
HTTPHEADER('Authorization', auth)
);
finalResponse := IF
(
addPartToPackageMapResponse.code = 0 AND sendActivateCommand,
activatePackageResponse,
addPartToPackageMapResponse
);
RETURN finalResponse.code;
END;
/**
* Helper function that removes a packagemap part via a web service call.
*
* Note that this function requires HPCC 6.0.0 or later to succeed.
*
* This function returns a value but will likely often need to be called
* in an action context, such as within a SEQUENTIAL set of commands
* that includes superfile management. You can wrap the call to this
* function in an EVALUATE() to allow that construct to work.
*
* @param packagePartName The name of the packagemap part
* to remove, typically from a call
* to _PartNameForSuperkeyPath();
* REQUIRED
* @param espURL The full URL to the ESP service,
* which is the same as the URL used
* for ECL Watch; REQUIRED
* @param roxieTargetName The name of the target ROXIE that
* will receive the new packagemap;
* REQUIRED
* @param _username The user name to use when connecting
* to the cluster; may be an empty
* string if authentication is not
* needed; REQUIRED
* @param _userPW The username password to use when
* connecting to the cluster; ignored
* if username is empty; REQUIRED
*
* @return A numeric code indicating success (zero = success).
*/
SHARED RemovePackageMapPart(STRING packagePartName,
STRING espURL,
STRING roxieTargetName,
STRING _username,
STRING _userPW) := FUNCTION
espHost := REGEXREPLACE('/+$', espURL, '');
auth := CreateAuthHeaderValue(_username, _userPW);
StatusRec := RECORD
INTEGER code {XPATH('Code')};
STRING description {XPATH('Description')};
END;
removePartFromPackageMapResponse := SOAPCALL
(
espHost + '/WsPackageProcess/',
'RemovePartFromPackageMap',
{
STRING targetCluster {XPATH('Target')} := roxieTargetName;
STRING packageMapID {XPATH('PackageMap')} := ROXIE_PACKAGEMAP_NAME;
STRING partName {XPATH('PartName')} := packagePartName;
},
StatusRec,
XPATH('RemovePartFromPackageMapResponse/status'),
HTTPHEADER('Authorization', auth)
);
RETURN removePartFromPackageMapResponse.code;
END;
/**
* Helper function that removes the entire packagemap managed by this code.
*
* Note that this function requires HPCC 6.0.0 or later to succeed.
*
* This function returns a value but will likely often need to be called
* in an action context, such as within a SEQUENTIAL set of commands
* that includes superfile management. You can wrap the call to this
* function in an EVALUATE() to allow that construct to work.
*
* @param espURL The full URL to the ESP service,
* which is the same as the URL used
* for ECL Watch; REQUIRED
* @param roxieTargetName The name of the target ROXIE that
* will receive the new packagemap;
* REQUIRED
* @param roxieProcessName The name of the specific ROXIE
* process to target; REQUIRED
* @param _username The user name to use when connecting
* to the cluster; may be an empty
* string if authentication is not
* needed; REQUIRED
* @param _userPW The username password to use when
* connecting to the cluster; ignored
* if username is empty; REQUIRED
*
* @return A numeric code indicating success (zero = success).
*/
SHARED RemovePackageMap(STRING espURL,
STRING roxieTargetName,
STRING roxieProcessName,
STRING _username,
STRING _userPW) := FUNCTION
espHost := REGEXREPLACE('/+$', espURL, '');
auth := CreateAuthHeaderValue(_username, _userPW);
StatusRec := RECORD
INTEGER code {XPATH('Code')};
STRING description {XPATH('Description')};
END;
deletePackageResponse := SOAPCALL
(
espHost + '/WsPackageProcess/',
'RemovePartFromPackageMap',
{
STRING targetCluster {XPATH('Target')} := roxieTargetName;
STRING targetProcess {XPATH('Process')} := roxieProcessName;
STRING packageMapID {XPATH('PackageMap')} := ROXIE_PACKAGEMAP_NAME;
},
StatusRec,
XPATH('DeletePackageResponse/status'),
HTTPHEADER('Authorization', auth)
);
RETURN deletePackageResponse.code;
END;
//--------------------------------------------------------------------------
// Exported Functions
//--------------------------------------------------------------------------
/**
* Exported helper function that can be used to delay processing while
* Dali is updating its internal database after an update. This is
* particularly important when dealing with locked files.
*
* @param daliDelayMilliseconds Delay in milliseconds to pause
* execution; OPTIONAL, defaults to
* DALI_LOCK_DELAY
*
* @return An ACTION that simply sleeps for a short while.
*/
EXPORT WaitForDaliUpdate(UNSIGNED2 daliDelayMilliseconds = DALI_LOCK_DELAY) := Std.System.Debug.Sleep(daliDelayMilliseconds);
/**
* Function that creates, or recreates, all packagemaps needed that will
* allow a ROXIE query to access the current generation of data in one or
* more index stores via virtual superkeys. This function is generally
* called after Init() is called to create the superkey structure within
* the index store.
*
* @param roxieQueryName The name of the ROXIE query for which
* we are building this packagemap;
* REQUIRED
* @param indexStorePaths A SET OF STRING value containing full
* paths for every index store that
* roxieQueryName will reference;
* REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that performs all packagemap initializations via
* web service calls.
*/
EXPORT InitROXIEPackageMap(STRING roxieQueryName,
SET OF STRING indexStorePaths,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
STRING username = '',
STRING userPW = '') := FUNCTION
TempRec := RECORD(FilePathLayout)
STRING indexStorePath;
DATASET(Std.File.FsLogicalFileNameRecord) subkeys;
STRING packageMapStr;
END;
withSubkeys := NOTHOR
(
PROJECT
(
GLOBAL(DATASET(indexStorePaths, {STRING s}), FEW),
TRANSFORM
(
TempRec,
SELF.indexStorePath := LEFT.s,
SELF.path := CurrentPath(LEFT.s),
SELF.subkeys := _AllSuperfileContents(SELF.path),
SELF.packageMapStr := ''
)
)
);
withPackageMapStr := PROJECT
(
withSubkeys,
TRANSFORM
(
RECORDOF(LEFT),
SELF.packageMapStr := CreateSuperkeyPackageMapString(LEFT.indexStorePath, LEFT.subkeys),
SELF := LEFT
)
);
baseROXIEPackageMapStr := CreateROXIEBasePackageMapString(roxieQueryName, withPackageMapStr);
createBaseROXIEPackageAction := AddPackageMapPart
(
_PackageMapNameForQuery(roxieQueryName),
baseROXIEPackageMapStr,
espURL,
roxieTargetName,
roxieProcessName,
TRUE,
username,
userPW
);
createSuperkeyPackagesAction := APPLY
(
withPackageMapStr,
EVALUATE
(
AddPackageMapPart
(
_PartNameForSuperkeyPath(path),
packageMapStr,
espURL,
roxieTargetName,
roxieProcessName,
FALSE,
username,
userPW
)
)
);
allActions := ORDERED
(
createBaseROXIEPackageAction;
createSuperkeyPackagesAction;
);
RETURN allActions;
END;
/**
* Function that removes all packagemaps used for the given ROXIE query
* and all referenced index stores.
*
* @param roxieQueryName The name of the ROXIE query; REQUIRED
* @param indexStorePaths A SET OF STRING value containing full
* paths for every index store that
* roxieQueryName references; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that performs all packagemap removals via web
* service calls.
*/
EXPORT RemoveROXIEPackageMap(STRING roxieQueryName,
SET OF STRING indexStorePaths,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING username = '',
STRING userPW = '') := FUNCTION
TempRec := RECORD(FilePathLayout)
STRING indexStorePath;
DATASET(Std.File.FsLogicalFileNameRecord) subkeys;
END;
withSubkeys := NOTHOR
(
PROJECT
(
GLOBAL(DATASET(indexStorePaths, {STRING s}), FEW),
TRANSFORM
(
TempRec,
SELF.indexStorePath := LEFT.s,
SELF.path := CurrentPath(LEFT.s),
SELF.subkeys := DATASET([], Std.File.FsLogicalFileNameRecord)
)
)
);
baseROXIEPackageMapStr := CreateROXIEBasePackageMapString(roxieQueryName, withSubkeys);
removeBaseROXIEPackageAction := RemovePackageMapPart
(
_PackageMapNameForQuery(roxieQueryName),
espURL,
roxieTargetName,
username,
userPW
);
removeSuperkeyPackagesAction := APPLY
(
withSubkeys,
EVALUATE
(
RemovePackageMapPart
(
_PartNameForSuperkeyPath(path),
espURL,
roxieTargetName,
username,
userPW
)
)
);
allActions := ORDERED
(
removeSuperkeyPackagesAction;
removeBaseROXIEPackageAction;
);
RETURN allActions;
END;
/**
* Function removes all packagemaps maintained by this bundle.
*
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that performs removes the packagemap maintained by
* this bundle via web service calls.
*/
EXPORT DeleteManagedROXIEPackageMap(STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
STRING username = '',
STRING userPW = '') := FUNCTION
RETURN EVALUATE(RemovePackageMap(espURL, roxieTargetName, roxieProcessName, username, userPW));
END;
/**
* Return a virtual superkey path that references the current generation
* of data managed by an index store. ROXIE queries should use virtual
* superkeys when accessing indexes in order to always read the most up
* to date data.
*
* @param indexStorePath The full path of the generational index store;
* REQUIRED
*
* @return A STRING that can be used by ROXIE queries to access the current
* generation of data within an index store.
*/
EXPORT VirtualSuperkeyPath(STRING indexStorePath) := _VirtualSuperkeyPathForDataStore(indexStorePath);
/**
* Construct a path for a new index for the index store. Note that
* the returned value will have time-oriented components in it, therefore
* callers should probably mark the returned value as INDEPENDENT if name
* will be used more than once (say, creating the index via BUILD and then
* calling WriteSubkey() here to store it) to avoid a recomputation of
* the name.
*
* @param indexStorePath The full path of the generational index store;
* REQUIRED
*
* @return A STRING representing a new index that may be added to the
* index store.
*/
EXPORT NewSubkeyPath(STRING indexStorePath) := _NewSubfilePath(indexStorePath);
/**
* Function updates the data package associated with the current generation
* of the given index store. The current generation's file contents are
* used to create the data package.
*
* This function assumes that a base packagemap for queries using this
* index store has already been created, such as with InitROXIEPackageMap().
*
* @param indexStorePath The full path of the generational index
* store; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that updates the data package representing the data
* store's current generation of data.
*/
EXPORT UpdateROXIE(STRING indexStorePath,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
STRING username = '',
STRING userPW = '') := FUNCTION
dataPath := CurrentPath(indexStorePath);
subkeys := NOTHOR(_AllSuperfileContents(dataPath));
packageMapStr := CreateSuperkeyPackageMapString(indexStorePath, subkeys);
updateAction := EVALUATE
(
AddPackageMapPart
(
_PartNameForSuperkeyPath(dataPath),
packageMapStr,
espURL,
roxieTargetName,
roxieProcessName,
FALSE,
username,
userPW
)
);
RETURN updateAction;
END;
/**
* Make the given subkey the first generation of index for the index store,
* bump all existing generations of subkeys to the next level, then update
* the associated data package with the contents of the first generation.
* Any subkeys stored in the last generation will be deleted.
*
* This function assumes that a base packagemap for queries using this
* index store has already been created, such as with InitROXIEPackageMap().
*
* @param indexStorePath The full path of the generational index
* store; REQUIRED
* @param newSubkeyPath The full path of the new subkey to
* insert into the index store as the new
* current generation of data; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param daliDelayMilliseconds Delay in milliseconds to pause
* execution; OPTIONAL, defaults to
* DALI_LOCK_DELAY
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that inserts the given subkey into the index store.
* Existing generations of subkeys are bumped to the next
* generation, and any subkey(s) stored in the last generation will
* be deleted.
*
* @see AppendSubkey
*/
EXPORT WriteSubkey(STRING indexStorePath,
STRING newSubkeyPath,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
UNSIGNED2 daliDelayMilliseconds = DALI_LOCK_DELAY,
STRING username = '',
STRING userPW = '') := FUNCTION
dataPath := CurrentPath(indexStorePath);
subkeys := DATASET([newSubkeyPath], Std.File.FsLogicalFileNameRecord);
packageMapStr := NOTHOR(CreateSuperkeyPackageMapString(indexStorePath, subkeys));
updateAction := EVALUATE
(
AddPackageMapPart
(
_PartNameForSuperkeyPath(dataPath),
packageMapStr,
espURL,
roxieTargetName,
roxieProcessName,
FALSE,
username,
userPW
)
);
promoteAction := _WriteFile(indexStorePath, newSubkeyPath);
allActions := SEQUENTIAL
(
IF(espURL != '', ORDERED(updateAction, WaitForDaliUpdate(daliDelayMilliseconds)));
promoteAction;
);
RETURN allActions;
END;
/**
* Adds the given subkey to the first generation of subkeys for the index
* store. This does not replace any existing subkey, nor bump any subkey
* generations to another level. The record structure of the new subkey
* must be the same as the other subkeys in the index store.
*
* This function assumes that a base packagemap for queries using this
* index store has already been created, such as with InitROXIEPackageMap().
*
* @param indexStorePath The full path of the generational index
* store; REQUIRED
* @param newSubkeyPath The full path of the new subkey to
* append to the current generation of
* subkeys; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that appends the given subkey to the current
* generation of subkeys.
*
* @see WriteSubkey
*/
EXPORT AppendSubkey(STRING indexStorePath,
STRING newSubkeyPath,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
STRING username = '',
STRING userPW = '') := FUNCTION
updateROXIEAction := UpdateROXIE(indexStorePath, espURL, roxieTargetName, roxieProcessName, username, userPW);
promoteAction := _AppendFile(indexStorePath, newSubkeyPath);
allActions := SEQUENTIAL
(
promoteAction;
IF(espURL != '', updateROXIEAction);
);
RETURN allActions;
END;
/**
* Method promotes all subkeys associated with the first generation into the
* second, promotes the second to the third, and so on. The first
* generation of subkeys will be empty after this method completes.
*
* Note that if you have multiple subkeys associated with a generation,
* as via AppendSubkey(), all of those subkeys will be deleted
* or moved as appropriate.
*
* This function assumes that a base packagemap for queries using this
* index store has already been created, such as with InitROXIEPackageMap().
*
* @param indexStorePath The full path of the generational index
* store; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()
* (on >= 7.0 clusters)
* @param roxieTargetName The name of the ROXIE cluster to send
* the information to; OPTIONAL, defaults
* to 'roxie'
* @param roxieProcessName The name of the specific ROXIE process
* to target; OPTIONAL, defaults to '*'
* (all processes)
* @param daliDelayMilliseconds Delay in milliseconds to pause
* execution; OPTIONAL, defaults to
* DALI_LOCK_DELAY
* @param username The user name to use when connecting
* to the cluster; OPTIONAL, defaults to
* an empty string
* @param userPW The username password to use when
* connecting to the cluster; OPTIONAL,
* defaults to an empty string
*
* @return An ACTION that performs the generational promotion.
*
* @see RollbackGeneration
*/
EXPORT PromoteGeneration(STRING indexStorePath,
STRING espURL = DEFAULT_ESP_URL,
STRING roxieTargetName = DEFAULT_ROXIE_TARGET,
STRING roxieProcessName = DEFAULT_ROXIE_PROCESS,
UNSIGNED2 daliDelayMilliseconds = DALI_LOCK_DELAY,
STRING username = '',
STRING userPW = '') := FUNCTION
dataPath := CurrentPath(indexStorePath);
subkeys := DATASET([], Std.File.FsLogicalFileNameRecord);
packageMapStr := NOTHOR(CreateSuperkeyPackageMapString(indexStorePath, subkeys));
updateAction := EVALUATE
(
AddPackageMapPart
(
_PartNameForSuperkeyPath(dataPath),
packageMapStr,
espURL,
roxieTargetName,
roxieProcessName,
FALSE,
username,
userPW
)
);
promoteAction := _PromoteGeneration(indexStorePath);
allActions := SEQUENTIAL
(
IF(espURL != '', ORDERED(updateAction, WaitForDaliUpdate(daliDelayMilliseconds)));
promoteAction;
);
RETURN allActions;
END;
/**
* Method deletes all subkeys associated with the current (first)
* generation, moves the second generation of subkeys into the first
* generation, then repeats the process for any remaining generations. This
* functionality can be thought of as restoring older version of subkeys
* to the current generation.
*
* Note that if you have multiple subkeys associated with a generation,
* as via AppendSubkey(), all of those subkeys will be deleted
* or moved as appropriate.
*
* This function assumes that a base packagemap for queries using this
* index store has already been created, such as with InitROXIEPackageMap().
*
* @param indexStorePath The full path of the generational index
* store; REQUIRED
* @param espURL The URL to the ESP service on the
* cluster, which is the same URL as used
* for ECL Watch; set to an empty string
* to prevent ROXIE from being updated;
* OPTIONAL, defaults to either an empty
* string (on < 7.0 clusters) or to an ESP
* process found from Std.File.GetEspURL()