forked from vmware-archive/docs-hd-staging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPXFExternalTableandAPIReference.html
1619 lines (1505 loc) · 86.4 KB
/
PXFExternalTableandAPIReference.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine or request Chrome Frame -->
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<!-- REPLACE X WITH PRODUCT NAME -->
<title>PXF External Table and API Reference | Pivotal Docs</title>
<!-- Local CSS stylesheets -->
<link href="/stylesheets/master.css" media="screen,print" rel="stylesheet" type="text/css" />
<link href="/stylesheets/breadcrumbs.css" media="screen,print" rel="stylesheet" type="text/css" />
<link href="/stylesheets/search.css" media="screen,print" rel="stylesheet" type="text/css" />
<link href="/stylesheets/portal-style.css" media="screen,print" rel="stylesheet" type="text/css" />
<link href="/stylesheets/printable.css" media="print" rel="stylesheet" type="text/css" />
<!-- Confluence HTML stylesheet -->
<link href="/stylesheets/site-conf.css" media="screen,print" rel="stylesheet" type="text/css" />
<!-- Left-navigation code -->
<!-- http://www.designchemical.com/lab/jquery-vertical-accordion-menu-plugin/examples/# -->
<link href="/stylesheets/dcaccordion.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="/javascripts/jquery.cookie.js" type="text/javascript"></script>
<script src="/javascripts/jquery.hoverIntent.minified.js" type="text/javascript"></script>
<script src="/javascripts/jquery.dcjqaccordion.2.7.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function($){
$('#accordion-1').dcAccordion({
eventType: 'click',
autoClose: true,
saveState: true,
disableLink: false,
speed: 'fast',
classActive: 'test',
showCount: false
});
});
</script>
<link href="/stylesheets/grey.css" rel="stylesheet" type="text/css" />
<!-- End left-navigation code -->
<script src="/javascripts/all.js" type="text/javascript"></script>
<link href='http://www.gopivotal.com/misc/favicon.ico' rel='shortcut icon'>
<script type="text/javascript">
if (window.location.host === 'docs.gopivotal.com') {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39702075-1']);
_gaq.push(['_setDomainName', 'gopivotal.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}
</script>
</head>
<body class="pivotalcf pivotalcf_getstarted pivotalcf_getstarted_index">
<div class="viewport">
<div class="mobile-navigation--wrapper mobile-only">
<div class="navigation-drawer--container">
<div class="navigation-item-list">
<div class="navbar-link active">
<a href="http://gopivotal.com">
Home
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/paas">
PaaS
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/big-data">
Big Data
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/agile">
Agile
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/support">
Help & Support
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/products">
Products
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/solutions">
Solutions
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
<div class="navbar-link">
<a href="http://gopivotal.com/partners">
Partners
<i class="icon-chevron-right pull-right"></i>
</a>
</div>
</div>
</div>
<div class="mobile-nav">
<div class="nav-icon js-open-nav-drawer">
<i class="icon-reorder"></i>
</div>
<div class="header-center-icon">
<a href="http://gopivotal.com">
<div class="icon icon-pivotal-logo-mobile"></div>
</a>
</div>
</div>
</div>
<div class='wrap'>
<script src="//use.typekit.net/clb0qji.js" type="text/javascript"></script>
<script type="text/javascript">
try {
Typekit.load();
} catch (e) {
}
</script>
<script type="text/javascript">
document.domain = "gopivotal.com";
</script>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Source+Sans+Pro:300italic,400italic,600italic,300,400,600:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})(); </script>
<div id="search-dropdown-box">
<div class="search-dropdown--container js-search-dropdown">
<div class="container-fluid">
<div class="close-menu-large"><img src="http://www.gopivotal.com/sites/all/themes/gopo13/images/icon-close.png" /></div>
<div class="search-form--container">
<div class="form-search">
<div class='gcse-search'></div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script src="/javascripts/cse.js" type="text/javascript"></script>
</div>
</div>
</div>
</div>
</div>
<header class="navbar desktop-only" id="nav">
<div class="navbar-inner">
<div class="container-fluid">
<div class="pivotal-logo--container">
<a class="pivotal-logo" href="http://gopivotal.com"><span></span></a>
</div>
<ul class="nav pull-right">
<li class="navbar-link">
<a href="http://www.gopivotal.com/paas" id="paas-nav-link">PaaS</a>
</li>
<li class="navbar-link">
<a href="http://www.gopivotal.com/big-data" id="big-data-nav-link">BIG DATA</a>
</li>
<li class="navbar-link">
<a href="http://www.gopivotal.com/agile" id="agile-nav-link">AGILE</a>
</li>
<li class="navbar-link">
<a href="http://www.gopivotal.com/oss" id="oss-nav-link">OSS</a>
</li>
<li class="nav-search">
<a class="js-search-input-open" id="click-to-search"><span></span></a>
</li>
</ul>
</div>
<a href="http://www.gopivotal.com/contact">
<img id="get-started" src="http://www.gopivotal.com/sites/all/themes/gopo13/images/get-started.png">
</a>
</div>
</header>
<div class="main-wrap">
<div class="container-fluid">
<!-- Google CSE Search Box -->
<div id='docs-search'>
<gcse:search></gcse:search>
</div>
<div id='all-docs-link'>
<a href="http://docs.gopivotal.com/">All Documentation</a>
</div>
<div class="container">
<div id="sub-nav" class="nav-container">
<!-- Collapsible left-navigation-->
<ul class="accordion" id="accordion-1">
<!-- REPLACE <li/> NODES-->
<li>
<a href="index.html">Home</a></br>
<li>
<a href="PivotalHD.html">Pivotal HD 2.0.1</a>
<ul>
<li>
<a href="PHDEnterprise2.0.1ReleaseNotes.html">PHD Enterprise 2.0.1 Release Notes</a>
</li>
</ul>
<ul>
<li>
<a href="PHDInstallationandAdministration.html">PHD Installation and Administration</a>
<ul>
<li>
<a href="OverviewofPHD.html">Overview of PHD</a>
</li>
</ul>
<ul>
<li>
<a href="InstallationOverview.html">Installation Overview</a>
</li>
</ul>
<ul>
<li>
<a href="PHDInstallationChecklist.html">PHD Installation Checklist</a>
</li>
</ul>
<ul>
<li>
<a href="InstallingPHDUsingtheCLI.html">Installing PHD Using the CLI</a>
</li>
</ul>
<ul>
<li>
<a href="UpgradeChecklist.html">Upgrade Checklist</a>
</li>
</ul>
<ul>
<li>
<a href="UpgradingPHDUsingtheCLI.html">Upgrading PHD Using the CLI</a>
</li>
</ul>
<ul>
<li>
<a href="AdministeringPHDUsingtheCLI.html">Administering PHD Using the CLI</a>
</li>
</ul>
<ul>
<li>
<a href="PHDFAQFrequentlyAskedQuestions.html">PHD FAQ (Frequently Asked Questions)</a>
</li>
</ul>
<ul>
<li>
<a href="PHDTroubleshooting.html">PHD Troubleshooting</a>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<a href="StackandToolsReference.html">Stack and Tools Reference</a>
<ul>
<li>
<a href="OverviewofApacheStackandPivotalComponents.html">Overview of Apache Stack and Pivotal Components</a>
</li>
</ul>
<ul>
<li>
<a href="ManuallyInstallingPivotalHD2.0Stack.html">Manually Installing Pivotal HD 2.0 Stack</a>
</li>
</ul>
<ul>
<li>
<a href="ManuallyUpgradingPivotalHDStackfrom1.1.1to2.0.html">Manually Upgrading Pivotal HD Stack from 1.1.1 to 2.0</a>
</li>
</ul>
<ul>
<li>
<a href="PivotalHadoopEnhancements.html">Pivotal Hadoop Enhancements</a>
</li>
</ul>
<ul>
<li>
<a href="Security.html">Security</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="PivotalCommandCenter.html">Pivotal Command Center 2.2.1</a>
<ul>
<li>
<a href="PCC2.2.1ReleaseNotes.html">PCC 2.2.1 Release Notes</a>
</li>
</ul>
<ul>
<li>
<a href="PCCUserGuide.html">PCC User Guide</a>
<ul>
<li>
<a href="PCCOverview.html">PCC Overview</a>
</li>
</ul>
<ul>
<li>
<a href="PCCInstallationChecklist.html">PCC Installation Checklist</a>
</li>
</ul>
<ul>
<li>
<a href="InstallingPCC.html">Installing PCC</a>
</li>
</ul>
<ul>
<li>
<a href="UsingPCC.html">Using PCC</a>
</li>
</ul>
<ul>
<li>
<a href="CreatingaYUMEPELRepository.html">Creating a YUM EPEL Repository</a>
</li>
</ul>
<ul>
<li>
<a href="CommandLineReference.html">Command Line Reference</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="PivotalHAWQ.html">Pivotal HAWQ 1.2.0</a>
<ul>
<li>
<a href="HAWQ1.2.0.1ReleaseNotes.html">HAWQ 1.2.0.1 Release Notes</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQInstallationandUpgrade.html">HAWQ Installation and Upgrade</a>
<ul>
<li>
<a href="PreparingtoInstallHAWQ.html">Preparing to Install HAWQ</a>
</li>
</ul>
<ul>
<li>
<a href="InstallingHAWQ.html">Installing HAWQ</a>
</li>
</ul>
<ul>
<li>
<a href="InstallingtheHAWQComponents.html">Installing the HAWQ Components</a>
</li>
</ul>
<ul>
<li>
<a href="UpgradingHAWQandComponents.html">Upgrading HAWQ and Components</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQConfigurationParameterReference.html">HAWQ Configuration Parameter Reference</a>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<a href="HAWQAdministration.html">HAWQ Administration</a>
<ul>
<li>
<a href="HAWQOverview.html">HAWQ Overview</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQQueryProcessing.html">HAWQ Query Processing</a>
</li>
</ul>
<ul>
<li>
<a href="UsingHAWQtoQueryData.html">Using HAWQ to Query Data</a>
</li>
</ul>
<ul>
<li>
<a href="ConfiguringClientAuthentication.html">Configuring Client Authentication</a>
</li>
</ul>
<ul>
<li>
<a href="KerberosAuthentication.html">Kerberos Authentication</a>
</li>
</ul>
<ul>
<li>
<a href="ExpandingtheHAWQSystem.html">Expanding the HAWQ System</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQInputFormatforMapReduce.html">HAWQ InputFormat for MapReduce</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQFilespacesandHighAvailabilityEnabledHDFS.html">HAWQ Filespaces and High Availability Enabled HDFS</a>
</li>
</ul>
<ul>
<li>
<a href="SQLCommandReference.html">SQL Command Reference</a>
</li>
</ul>
<ul>
<li>
<a href="ManagementUtilityReference.html">Management Utility Reference</a>
</li>
</ul>
<ul>
<li>
<a href="ClientUtilityReference.html">Client Utility Reference</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQServerConfigurationParameters.html">HAWQ Server Configuration Parameters</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQEnvironmentVariables.html">HAWQ Environment Variables</a>
</li>
</ul>
<ul>
<li>
<a href="HAWQDataTypes.html">HAWQ Data Types</a>
</li>
</ul>
<ul>
<li>
<a href="SystemCatalogReference.html">System Catalog Reference</a>
</li>
</ul>
<ul>
<li>
<a href="hawq_toolkitReference.html">hawq_toolkit Reference</a>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<a href="PivotalExtensionFrameworkPXF.html">Pivotal Extension Framework (PXF)</a>
<ul>
<li>
<a href="PXFInstallationandAdministration.html">PXF Installation and Administration</a>
</li>
</ul>
<ul>
<li>
<a href="PXFExternalTableandAPIReference.html">PXF External Table and API Reference</a>
</li>
</ul>
</div><!--end of sub-nav-->
<h3 class="title-container">PXF External Table and API Reference</h3>
<div class="content">
<!-- Python script replaces main content -->
<div id ="main"><div style="visibility:hidden; height:2px;">Pivotal Product Documentation : PXF External Table and API Reference</div><div class="wiki-content group" id="main-content">
<p align="LEFT">You can extend PXF functionality and add new services and formats using the Java API without changing HAWQ. The API includes the four classes Fragmenter, Accessor, Resolver, Analyzer. The Fragmenter, Accessor, and Resolver classes must be implemented to add a new service. The Analyzer class is optional.</p><p align="LEFT"><style type="text/css">/*<![CDATA[*/
div.rbtoc1400035797057 {padding: 0px;}
div.rbtoc1400035797057 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1400035797057 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style><div class="toc-macro rbtoc1400035797057">
<ul class="toc-indentation">
<li><a href="#PXFExternalTableandAPIReference-CreatinganExternalTable">Creating an External Table</a></li>
<li><a href="#PXFExternalTableandAPIReference-AbouttheJavaClassServicesandFormats">About the Java Class Services and Formats</a>
<ul class="toc-indentation">
<li><a href="#PXFExternalTableandAPIReference-Fragmenter">Fragmenter</a></li>
<li><a href="#PXFExternalTableandAPIReference-Accessor">Accessor</a></li>
<li><a href="#PXFExternalTableandAPIReference-Resolver">Resolver</a></li>
<li><a href="#PXFExternalTableandAPIReference-Analyzer">Analyzer</a></li>
</ul>
</li>
<li><a href="#PXFExternalTableandAPIReference-AboutCustomProfiles">About Custom Profiles</a></li>
<li><a href="#PXFExternalTableandAPIReference-AboutQueryFilterPush-Down">About Query Filter Push-Down</a>
<ul class="toc-indentation">
<li><a href="#PXFExternalTableandAPIReference-FilterAvailabilityandOrdering">Filter Availability and Ordering</a></li>
<li><a href="#PXFExternalTableandAPIReference-CreatingaFilterBuilderClass">Creating a Filter Builder Class</a></li>
<li><a href="#PXFExternalTableandAPIReference-FilterOperations">Filter Operations</a></li>
<li><a href="#PXFExternalTableandAPIReference-SampleImplementation">Sample Implementation</a></li>
<li><a href="#PXFExternalTableandAPIReference-UsingFilters">Using Filters</a></li>
</ul>
</li>
<li><a href="#PXFExternalTableandAPIReference-Reference">Reference</a>
<ul class="toc-indentation">
<li><a href="#PXFExternalTableandAPIReference-ExternalTableExamples">External Table Examples</a></li>
<li><a href="#PXFExternalTableandAPIReference-PluginExamples">Plugin Examples</a></li>
<li><a href="#PXFExternalTableandAPIReference-ConfigurationFiles">Configuration Files</a></li>
</ul>
</li>
<li><a href="#PXFExternalTableandAPIReference-CredentialsforRemoteServices">Credentials for Remote Services</a></li>
<li><a href="#PXFExternalTableandAPIReference-CredentialsforremoteservicesisallowingaPXFplugintoaccessaremoteservicethatrequirescredentials.">Credentials for remote services is allowing a PXF plugin to access a remote service that requires credentials.</a>
<ul class="toc-indentation">
<li><a href="#PXFExternalTableandAPIReference-InHawq">In Hawq</a></li>
<li><a href="#PXFExternalTableandAPIReference-InaPXFPlugin">In a PXF Plugin</a></li>
</ul>
</li>
</ul>
</div></p><h2 id="PXFExternalTableandAPIReference-CreatinganExternalTable">Creating an External Table</h2><p align="LEFT">Syntax for an <em>EXTERNAL TABLE</em> that uses the PXF protocol is as follows:.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px;">CREATE EXTERNAL TABLE ext_table <attr list, ...>
LOCATION('pxf://<namenode>:<port>/path/to/data?FRAGMENTER=package.name.FragmenterForX&ACCESSOR=package.name.AccessorForX&RESOLVER=package.name.ResolverForX&<Other custom user options>=<value>')FORMAT 'custom'(formatter='pxfwritable_import');</pre>
</div></div><p> Where:</p><h5 id="PXFExternalTableandAPIReference-Table:Parametervaluesanddescription">Table: Parameter values and description</h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><td class="confluenceTd"><p align="LEFT"><strong>Parameter</strong></p></td><td class="confluenceTd"><p align="LEFT"><strong>Value and description</strong></p></td></tr><tr><td class="confluenceTd"><p align="LEFT">namenode</p></td><td class="confluenceTd"><p align="LEFT">The current host of the PXF service is HDFS Namenode port.</p></td></tr><tr><td class="confluenceTd"><p align="LEFT">REST </p></td><td class="confluenceTd"><p align="LEFT">Port for Namenode, 50070 by default.</p></td></tr><tr><td class="confluenceTd" colspan="1"> path/to/data</td><td class="confluenceTd" colspan="1"> A directory, file name, wildcard pattern, table name, etc</td></tr><tr><td class="confluenceTd" colspan="1"> FRAGMENTER</td><td class="confluenceTd" colspan="1"> The plugin (java class) to use for fragmenting data. Used in READABLE external tables only.</td></tr><tr><td class="confluenceTd" colspan="1"> ACCESSOR</td><td class="confluenceTd" colspan="1">The plugin (java class) to use for accessing the data. Used in READABLE and WRITABLE tables.</td></tr><tr><td class="confluenceTd" colspan="1"> RESOLVER</td><td class="confluenceTd" colspan="1">The plugin (java class) to use for serializing and deserializing the data. Used in READABLE and WRITABLE tables.</td></tr><tr><td class="confluenceTd" colspan="1"> Custom Options</td><td class="confluenceTd" colspan="1">Anything else that is desired to add. Will be passed in runtime to the plugins indicated above. </td></tr></tbody></table></div><p align="LEFT">For more information about this example, see <em>"About the Java Class Services and Formats" and the Pivotal Extension Installation and Administrator Guide.</em></p><h2 id="PXFExternalTableandAPIReference-AbouttheJavaClassServicesandFormats">About the Java Class Services and Formats</h2><p>The Java class names you must include in the PXF URI are Fragmenter, Accessor, and Resolver. The Fragmenter class is mandatory for READABLE tables, and not supported for WRITABLE tables. Pivotal recommends that you reuse a previously-defined Accessor or Resolver data format.</p><p>All the attributes are passed from HAWQ as headers to the PXF Java service. The Java service retrieves the source data and converts it to a HAWQ-readable format. You can pass any additional information to the user-implemented services.</p><p>The example in<em> "Creating an External Table"</em> shows the available keys and associated values. The example also contains attributes that are passed in from the HAWQ side. The available keys and associated values are as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">FRAGMENTER: ‘pkg.name.FragmenterForX’
ACCESSOR: ‘pkg.name.AccessorForX’
RESOLVER: ‘pkg.name.ResolverForX’
</pre>
</div></div><p>These three Java plugins and the optional plugin, Analyzer, extend the <em>com.pivotal.pxf.api.utilities.Plugin</em> class.</p><p>The Java classes can be described as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api.utilities;
/*
* Base class for all plugin types (Accessor, Resolver, Fragmenter, Analyzer)
* Holds InputData as well (the meta data information used by all plugin types)
*/
public class Plugin
{
protected InputData inputData;
/*
* C'tor
*/
public Plugin(InputData input);
/**
* Checks if the plugin is thread safe or not, based on inputData.
*
* @return if plugin is thread safe or not
*/
public boolean isThreadSafe() {
return true;
}
}</pre>
</div></div><p>Attributes are available through the <em>com.pivotal.pxf.api.utilities.InputData</em> class. The following example shows how <em>inputData.getProperty(‘USERINFO1’)</em> returns <em>optional_info</em>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api.utilities;
/*
* Common configuration of all MetaData classes
* Provides read-only access to common parameters supplied using system properties
*/
public class InputData
{
/*
* Constructor of InputData
* Parses X-GP-* configuration variables
*
* @param paramsMap contains all query-specific parameters from Hawq
* @param servletContext Servlet context contains attributes required by SecuredHDFS
*/
public InputData(Map<String, String> paramsMap);
/*
* Expose the parameters map
*/
public Map<String, String> getParametersMap();
/* Copy contructor of InputData
* Used to create from an extending class
*/
public InputData(InputData copy);
/*
* Returns a property as a string type
*/
public String getProperty(String property);
/*
* returns the number of segments in GP
*/
public int totalSegments();
/*
* returns the current segment ID
*/
public int segmentId();
/* returns the current outputFormat
* currently either text or gpdbwritable
*/
public OutputFormat outputFormat();
/*
* returns the server name providing the service
*/
public String serverName();
/*
* returns the server port providing the service
*/
public int serverPort();
/*
* Returns true if there is a filter string to parse
*/
public boolean hasFilter();
/*
* The filter string
*/
public String filterString();
/*
* returns the number of columns in Tuple Description
*/
public int columns();
/*
* returns column index from Tuple Description
*/
public ColumnDescriptor getColumn(int index);
/*
* returns fragment serialized metadata
*/
public byte[] getFragmentMetadata();
/*
* Set fragment serialized metadata
*/
public void setFragmentMetadata(byte[] location);
/*
* returns fragment user data
*/
public byte[] getFragmentUserData();
/*
* returns a data fragment index
*/
public int getDataFragment();
/*
* returns the column descriptor of the recordkey column.
* If the recordkey column was not specified by the user in the create table statement,
* then getRecordkeyColumn will return null.
*/
public ColumnDescriptor getRecordkeyColumn();
/*
* Returns the data source of the required resource (i.e a file path or a table name).
*/
public String dataSource();
/*
* Sets the data source of the required resource (i.e a file path or a table name).
*/
public void setDataSource(String dataSource);
/* returns the path of the schema used for various deserializers
* e.g, Avro file name, Java object file name.
*/
public String srlzSchemaName() throws FileNotFoundException, IllegalArgumentException;
/*
* returns the ClassName for the java class that handles the file access
*/
public String accessor();
/*
* returns the ClassName for the java class that handles the record deserialization
*/
public String resolver();
/*
* The avroSchema fetched by the AvroResolver and used in case of Avro File
* In case of avro records inside a sequence file this variable will be null
* and the AvroResolver will not use it.
*/
public Object getSchema();
/*
* The avroSchema is set from the outside by the AvroFileAccessor
*/
public void setSchema(Object schema);
/*
* Returns the compression codec (can be null - means no compression)
*/
public String compressCodec();
}</pre>
</div></div><h3 id="PXFExternalTableandAPIReference-Fragmenter">Fragmenter</h3> <div class="aui-message hint shadowed information-macro">
<p class="title">Note</p>
<span class="aui-icon icon-hint">Icon</span>
<div class="message-content">
<p>The Fragmenter Plugin reads data into HAWQ. Such tables are called READABLE PXF tables. The Fragmenter Plugin cannot write data out of HAWQ. Such tables are called WRITABLE tables.</p>
</div>
</div>
<p align="LEFT">The Fragmenter is responsible for passing datasource metadata back to HAWQ. It also returns a list of data fragments to the Accessor or Resolver. Each data fragment describes some part of the requested data set. It contains the datasource name, such as the file or table name, including the hostname where it is located. For example, if the source is a HDFS file, the Fragmenter returns a list of data fragments containing a HDFS file block. Each fragment includes the location of the block. If the source data is an HBase table, the Fragmenter returns information about table regions, including their locations.</p><p align="LEFT">The following implementations are shipped with PXF 2.2 and higher:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">com.pivotal.pxf.plugins.hdfs.HdfsDataFragmenter
com.pivotal.pxf.plugins.hbase.HBaseDataFragmenter
com.pivotal.pxf.plugins.hive.HiveDataFragmenter</pre>
</div></div><p>The Fragmenter.getFragments() methods returns a List<Fragment>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Fragment holds a data fragment' information.
* Fragmenter.getFragments() returns a list of fragments.
*/
public class Fragment
{
private String sourceName; // File path+name, table name, etc.
private int index; // Fragment index (incremented per sourceName)
private String[] replicas; // Fragment replicas (1 or more)
private byte[] metadata; // Fragment metadata information (starting point + length, region location, etc.)
private byte[] userData; // ThirdParty data added to a fragment. Ignored if null
...
}</pre>
</div></div><p>Any Fragmenter class needs to extend <em>com.pivotal.pxf.api.Fragmenter</em>:</p><h4 id="PXFExternalTableandAPIReference-com.pivotal.pxf.api.Fragmenter">com.pivotal.pxf.api.Fragmenter</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Interface that defines the splitting of a data resource into fragments that can be processed in parallel
* GetFragments returns the fragments information of a given path (source name and location of each fragment).
* Used to get fragments of data that could be read in parallel from the different segments.
*/
public abstract class Fragmenter extends Plugin {
protected List<Fragment> fragments;
public Fragmenter(InputData metaData) {
super(metaData);
fragments = new LinkedList<Fragment>();
}
/*
* path is a data source URI that can appear as a file name, a directory name or a wildcard
* returns the data fragments
*/
public abstract List<Fragment> getFragments() throws Exception;
} </pre>
</div></div><h4 id="PXFExternalTableandAPIReference-ClassDescription">Class Description</h4><p><em>getFragments()</em> returns a string in a JSON format of the retrieved fragment. For example, if the input path is a HDFS directory, the source name for each fragment should include the file name including the path for the fragment. </p><h3 id="PXFExternalTableandAPIReference-Accessor"><a name="RTF37363238383a204865616432" rel="nofollow"></a>Accessor</h3><p>The Accessor retrieves specific fragments and passes records back to the Resolver. For example, the Accessor creates a <em>FileInputFormat</em> and a Record Reader for an HDFS file and sends this to the Resolver. In the case of HBase or Hive files, the Accessor returns single rows from an HBase or Hive table. PXF 1.x or higher contains the following implementations:</p><h5 id="PXFExternalTableandAPIReference-Table:Accessorbaseclasses">Table: Accessor base classes<span lang="EN"> </span></h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><td class="confluenceTd"><p align="LEFT"><strong>Accessor class</strong></p></td><td class="confluenceTd"><p align="LEFT"><strong>Description</strong></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hdfs.HdfsAtomicDataAccessor</em></p></td><td class="confluenceTd"><p align="LEFT">Base class for accessing datasources which cannot be split. These will be accessed by a single HAWQ segment.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: plain; gutter: false" style="font-size:12px;">QuotedLineBreakAccessor - Accessor for TEXT files that has records with embedded linebreaks</pre>
</div></div></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hdfs.HdfsSplittableDataAccessor</em></p><p align="LEFT"> </p><p align="LEFT"> </p></td><td class="confluenceTd"><p align="LEFT">Base class for accessing HDFS files using <em>RecordReaders</em>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: plain; gutter: false" style="font-size:12px;">LineBreakAccessor - Accessor for TEXT files (replaced the deprecated TextFileAccessor, LineReaderAccessor)
AvroFileAccessor - Accessor for Avro files
</pre>
</div></div><p><span style="font-size: xx-small;"> </span></p></td></tr><tr><td class="confluenceTd" colspan="1"> com.pivotal.pxf.plugins.hive.HiveAccessor</td><td class="confluenceTd" colspan="1">Accessor for Hive tables </td></tr><tr><td class="confluenceTd" colspan="1">com.pivotal.pxf.plugins.hbase.HBaseAccessor </td><td class="confluenceTd" colspan="1">Accessor for HBase tables </td></tr></tbody></table></div><p align="LEFT">The class needs to extend the <em>com.pivotal.pxf.Plugin class,</em> and implement one or both interface<em>s: </em></p><ul><li><em>com.pivotal.pxf.api.ReadAccessor</em></li><li><em>com.pivotal.pxf.api.WriteAccessor</em></li></ul><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Internal interface that defines the access to data on the source
* data store (e.g, a file on HDFS, a region of an HBase table, etc).
* All classes that implement actual access to such data sources must
* respect this interface
*/
public interface ReadAccessor {
public boolean openForRead() throws Exception;
public OneRow readNextObject() throws Exception;
public void closeForRead() throws Exception;
}</pre>
</div></div><p><span style="font-size: medium;"> </span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* An interface for writing data into a data store
* (e.g, a sequence file on HDFS).
* All classes that implement actual access to such data sources must
* respect this interface
*/
public interface WriteAccessor {
public boolean openForWrite() throws Exception;
public OneRow writeNextObject(OneRow onerow) throws Exception;
public void closeForWrite() throws Exception;
}</pre>
</div></div><p><span style="font-size: medium;"> </span></p><p align="LEFT">The Accessor calls o<em>penForRead() to read existing data</em>. After reading the data, it calls c<em>loseForRead()</em>. <em>readNextObject()</em> and returns one of the following:</p><ul><li>a single record, encapsulated in a OneRow object</li><li>null if it reaches <em>EOF</em></li></ul><p align="LEFT">The Accessor calls<em> openForWrite() </em>to write data out.<em> </em>After writing the data, it writes a <em>OneRow</em> object with <em>writeNextObject()</em>, and when done calls <em>closeForWrite()</em>. <em>OneRow</em> represents a key-value item.</p><h4 id="PXFExternalTableandAPIReference-com.pivotal.pxf.api.OneRow:">com.pivotal.pxf.api.OneRow:</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Represents one row in the external system data store. Supports
* the general case where one row contains both a record and a
* separate key like in the HDFS key/value model for MapReduce
* (Example: HDFS sequence file)
*/
public class OneRow {
/*
* Default constructor
*/
public OneRow()
/*
* Constructor sets key and data
*/
public OneRow(Object inKey, Object inData)
/*
* Copy constructor
*/
public OneRow(OneRow copy)
/*
* Setter for key
*/
public void setKey(Object inKey)
/*
* Setter for data
*/
public void setData(Object inData)
/*
* Accessor for key
*/
public Object getKey()
/*
* Accessor for data
*/
public Object getData()
/*
* Show content
*/
public String toString()
}</pre>
</div></div><h3 id="PXFExternalTableandAPIReference-Resolver">Resolver</h3><p>The Resolver deserializes records in the <em>OneRow</em> format and serializes them to a list of <em>OneField</em> objects. PXF converts a <em>OneField</em> object to a HAWQ-readable <em>GPDBWritable</em> format. PXF 1.x or higher contains the following implementations:</p><h5 id="PXFExternalTableandAPIReference-Table:Resolverbaseclasses">Table: Resolver base classes<span lang="EN"> </span></h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><td class="confluenceTd"><p align="LEFT"><strong>Resolver class</strong></p></td><td class="confluenceTd"><p align="LEFT"><strong>Description</strong></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hdfs.StringPassResolver</em></p><p align="LEFT"> </p><p align="LEFT"> </p></td><td class="confluenceTd"><p align="LEFT">Supports:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">GPBWritable VARCHAR</pre>
</div></div><p><em>StringPassResolver </em>replaced the deprecated <em>TextResolver. </em>It passes whole records (composed of any data types) as strings without parsing them</p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hdfs.WritableResolver</em></p></td><td class="confluenceTd"><p align="LEFT">Resolver for custom Hadoop Writable implementations. Custom class can be specified with the schema<em> {{,}}</em> and supports the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">DataType.BOOLEAN
DataType.INTEGER
DataType.BIGINT
DataType.REAL
DataType.FLOAT8
DataType.VARCHAR
DataType.BYTEA</pre>
</div></div></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hdfs.AvroResolver</em></p></td><td class="confluenceTd"><p align="LEFT">Supports the same field objects as <em>WritableResolver</em>. </p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hbase.HBaseResolver</em></p></td><td class="confluenceTd"><p align="LEFT">Supports the same field objects as <em>WritableResolver</em> and also supports the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">DataType.SMALLINT
DataType.NUMERIC
DataType.TEXT
DataType.BPCHAR
DataType.TIMESTAMP</pre>
</div></div></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>com.pivotal.pxf.plugins.hive.HiveResolver</em></p><p align="LEFT"> </p><p align="LEFT"> </p></td><td class="confluenceTd"><p align="LEFT">Supports the same field objects as <em>WritableResolver</em> and also supports the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">DataType.SMALLINT
DataType.TEXT
DataType.TIMESTAMP</pre>
</div></div></td></tr></tbody></table></div><p>The class needs to extend the <em>com.pivotal.pxf.resolvers.Plugin class </em>, and implement one or both interface<em>s: </em></p><ul><li><em>com.pivotal.pxf.api.ReadResolver</em></li><li><em>com.pivotal.pxf.api.WriteResolver</em></li></ul><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Interface that defines the deserialization of one record brought from
* the data Accessor. Every implementation of a deserialization method
* (e.g, Writable, Avro, ...) must implement this interface.
*/
public interface ReadResolver {
public List<OneField> getFields(OneRow row) throws Exception;
}</pre>
</div></div><p><em><br/></em></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Interface that defines the serialization of data read from the DB
* into a OneRow object.
* Every implementation of a serialization method
* (e.g, Writable, Avro, ...) must implement this interface.
*/
public interface WriteResolver {
public OneRow setFields(List<OneField> record) throws Exception;
}</pre>
</div></div> <div class="aui-message hint shadowed information-macro">
<p class="title">Notes</p>
<span class="aui-icon icon-hint">Icon</span>
<div class="message-content">
<ul><li>getFields should return a List<OneField>, each OneField representing a single field.</li><li><em>setFields </em>should return a single <em>OneRow </em>object, given a List<OneField>.</li></ul>
</div>
</div>
<p> </p><h4 id="PXFExternalTableandAPIReference-com.pivotal.pxf.api.OneField">com.pivotal.pxf.api.OneField</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
/*
* Defines one field on a deserialized record.
* 'type' is in OID values recognized by GPDBWritable
* 'val' is the actual field value
*/
public class OneField {
public OneField() {}
public OneField(int type, Object val) {
this.type = type;
this.val = val;
}
public int type;
public Object val;
}</pre>
</div></div><p> </p><p>The value of t<em>ype</em> should follow the com.pivotal.pxf.api.io.DataType <em>enums</em>. v<em>al</em> is the appropriate Java class. Supported types are as follows:</p><h4 id="PXFExternalTableandAPIReference-Table:Resolversupportedtypes">Table: Resolver supported types</h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><td class="confluenceTd"><p align="LEFT"><strong>DataType recognized OID</strong></p></td><td class="confluenceTd"><p align="LEFT"><strong>Field value</strong></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.SMALLINT</em></p></td><td class="confluenceTd"><p align="LEFT"><em>Short</em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.INTEGER</em></p></td><td class="confluenceTd"><p align="LEFT"><em>Integer</em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.BIGINT</em></p></td><td class="confluenceTd"><p align="LEFT"><em>Long</em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.REAL </em></p></td><td class="confluenceTd"><p align="LEFT"><em>Float</em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.FLOAT8</em></p></td><td class="confluenceTd"><p align="LEFT"><em>Double</em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.NUMERIC</em></p></td><td class="confluenceTd"><p align="LEFT"><em>String ( "651687465135468432168421") </em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.BOOLEAN</em></p></td><td class="confluenceTd"><p align="LEFT">Boolean</p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.VARCHAR</em><em style="line-height: 1.4285;background-color: transparent;"> </em></p></td><td class="confluenceTd"> </td></tr><tr><td class="confluenceTd" colspan="1"><em>DataType.BPCHAR</em></td><td class="confluenceTd" colspan="1"> </td></tr><tr><td class="confluenceTd" colspan="1"><em>DataType.TEXT</em></td><td class="confluenceTd" colspan="1"><em>String</em></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.BYTEA</em></p></td><td class="confluenceTd"><p align="LEFT"><em>byte [] </em></p></td></tr><tr><td class="confluenceTd"><p align="LEFT"><em>DataType.TIMESTAMP</em></p></td><td class="confluenceTd"><p align="LEFT"><em>Timestamp</em></p></td></tr></tbody></table></div><h3 id="PXFExternalTableandAPIReference-Analyzer">Analyzer</h3><p align="LEFT">The Analyzer provides PXF statistical data for the HAWQ query optimizer. For a detailed explanation about HAWQ statistical data gathering, see <em>ANALYZE</em> in the <em>Pivotal ADS Administrator Guide</em>. Implement the PXF Analyzer for the HDFS text, sequence, and AVRO files. For HBase tables and Hive tables, the Analyzer returns default values.</p><p align="LEFT"><strong>Notes</strong>:</p><ul><li>The new <em>boolean guc pxf_enable_stat_collection</em> requests statistics. The default value is <em>on</em>. When you turn it off, the statistics collected reflect default values.</li><li>Pivotal recommends that you implement the Analyzer to return an estimated result as fast as possible.</li></ul><p align="LEFT">The class needs to extend <em>com.pivotal.pxf.api.Analyzer</em>.</p><h4 id="PXFExternalTableandAPIReference-com.pivotal.pxf.analyzers.Analyzer">com.pivotal.pxf.analyzers.Analyzer</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
import com.pivotal.pxf.api.utilities.InputData;
import com.pivotal.pxf.api.utilities.Plugin;
/*
* Abstract class that defines getting statistics for ANALYZE.
* getEstimatedStats returns statistics for a given path
* (block size, number of blocks, number of tuples).
* Used when calling ANALYZE on a PXF external table, to get
* table's statistics that are used by the optimizer to plan queries.
*/
public abstract class Analyzer extends Plugin
{
public Analyzer(InputData inputData)
{
super(inputData);
}
/*
* 'path' is the data source name (e.g, file, dir, wildcard, table name).
* returns the data statistics in json format.
*
* NOTE: It is highly recommended to implement an extremely fast logic
* that returns *estimated* statistics. Scanning all the data for exact
* statistics is considered bad practice.
*/
public AnalyzerStats getEstimatedStats(String data) throws Exception
{
/* Return default values */
return new AnalyzerStats();
}
}</pre>
</div></div><p align="LEFT"><em>getEstimatedStats</em> creates a<em>n AnalyzerStats</em> , and returns the result <em>AnalyzerStats</em><em>.dataToJSON</em>.</p><h4 id="PXFExternalTableandAPIReference-com.pivotal.pxf.api.AnalyzerStats">com.pivotal.pxf.api.<em>AnalyzerStats</em></h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px;">package com.pivotal.pxf.api;
import java.io.IOException;
import org.codehaus.jackson.map.ObjectMapper;
/*
* AnalyzerStats is a public class that represents the size
* information of given path.
*/
public class AnalyzerStats {
private static final long DEFAULT_BLOCK_SIZE = 67108864L; // 64MB (in bytes)
private static final long DEFAULT_NUMBER_OF_BLOCKS = 1L;
private static final long DEFAULT_NUMBER_OF_TUPLES = 1000000L;
private long blockSize; // block size (in bytes)
private long numberOfBlocks; // number of blocks