-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrd.html
4883 lines (4749 loc) · 134 KB
/
rd.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
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="pandoc" />
<meta name="author" content="Ryan Hafen" />
<title>datadr</title>
<script src="assets/jquery-1.11.3/jquery.min.js"></script>
<link href="assets/bootstrap-3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<script src="assets/bootstrap-3.3.2/js/bootstrap.min.js"></script>
<script src="assets/bootstrap-3.3.2/shim/html5shiv.min.js"></script>
<script src="assets/bootstrap-3.3.2/shim/respond.min.js"></script>
<link href="assets/highlight-8.4/tomorrow.css" rel="stylesheet" />
<script src="assets/highlight-8.4/highlight.pack.js"></script>
<link href="assets/fontawesome-4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="assets/stickykit-1.1.1/sticky-kit.min.js"></script>
<script src="assets/jqueryeasing-1.3/jquery.easing.min.js"></script>
<link href="assets/packagedocs-0.0.1/pd.css" rel="stylesheet" />
<script src="assets/packagedocs-0.0.1/pd.js"></script>
<script src="assets/packagedocs-0.0.1/pd-collapse-toc.js"></script>
<style type="text/css">
.section h1 {
margin-top: 50px;
margin-bottom: 70px;
text-align: center;
border-bottom: 0px;
font-size: 35px;
font-weight: 400;
font-family: "PT Mono","Georgia",Arial,sans-serif;
}
.section h2 {
margin-left: -10px !important;
border-bottom: 3px solid #5d9fea;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<header class="navbar navbar-white navbar-fixed-top" role="banner" id="header">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a href="http://deltarho.org"> <img src='figures/icon.png' alt='deltarho icon' width='30px' height='30px' style='margin-top: -3px;'> </a>
</span>
<a href="index.html" class="navbar-brand page-scroll">
datadr - Package Reference
</a>
</div>
<nav class="collapse navbar-collapse" role="navigation">
<ul class="nav nav-pills pull-right">
<li>
<a href='index.html'>Docs</a>
</li>
<li class="active">
<a href='rd.html'>Package Ref</a>
</li>
<li>
<a href='https://github.com/delta-rho/datadr'>Github <i class='fa fa-github'></i></a>
</li>
</ul>
</nav>
</div>
</header>
<!-- Begin Body -->
<div class="container">
<div class="row">
<div class="col-md-3" id="sidebar-col">
<div id="toc">
<ul>
<li><a href="#key-value-pairs">Key-Value Pairs</a><ul>
<li><a href="#kvpair">kvPair</a></li>
<li><a href="#kvpairs">kvPairs</a></li>
<li><a href="#print.kvpair">print.kvPair</a></li>
<li><a href="#print.kvvalue">print.kvValue</a></li>
<li><a href="#kvapply">kvApply</a></li>
</ul></li>
<li><a href="#distributed-data-objects">Distributed data objects</a><ul>
<li><a href="#ddo">ddo</a></li>
<li><a href="#ddf">ddf</a></li>
<li><a href="#updateattributes">updateAttributes</a></li>
<li><a href="#ddf-accessors">ddf-accessors</a></li>
<li><a href="#ddo-ddf-accessors">ddo-ddf-accessors</a></li>
<li><a href="#ddo-ddf-attributes">ddo-ddf-attributes</a></li>
<li><a href="#print.ddo">print.ddo</a></li>
</ul></li>
<li><a href="#back-end-connections">Back End Connections</a><ul>
<li><a href="#localdiskconn">localDiskConn</a></li>
<li><a href="#digestfilehash">digestFileHash</a></li>
<li><a href="#charfilehash">charFileHash</a></li>
<li><a href="#localdiskcontrol">localDiskControl</a></li>
<li><a href="#hdfsconn">hdfsConn</a></li>
<li><a href="#rhipecontrol">rhipeControl</a></li>
</ul></li>
<li><a href="#data-io">Data I/O</a><ul>
<li><a href="#adddata">addData</a></li>
<li><a href="#removedata">removeData</a></li>
<li><a href="#drread.table">drRead.table</a></li>
<li><a href="#readhdfstextfile">readHDFStextFile</a></li>
<li><a href="#readtextfilebychunk">readTextFileByChunk</a></li>
<li><a href="#convert">convert</a></li>
<li><a href="#as.data.frame.ddf">as.data.frame.ddf</a></li>
<li><a href="#as.list.ddo">as.list.ddo</a></li>
<li><a href="#to_ddf">to_ddf</a></li>
</ul></li>
<li><a href="#division-independent-methods">Division Independent Methods</a><ul>
<li><a href="#draggregate">drAggregate</a></li>
<li><a href="#drhexbin">drHexbin</a></li>
<li><a href="#drquantile">drQuantile</a></li>
</ul></li>
<li><a href="#division">Division</a><ul>
<li><a href="#divide">divide</a></li>
<li><a href="#conddiv">condDiv</a></li>
<li><a href="#rrdiv">rrDiv</a></li>
</ul></li>
<li><a href="#transformations">Transformations</a><ul>
<li><a href="#addtransform">addTransform</a></li>
<li><a href="#applytransform">applyTransform</a></li>
<li><a href="#setuptransformenv">setupTransformEnv</a></li>
<li><a href="#drpersist">drPersist</a></li>
</ul></li>
<li><a href="#recombination">Recombination</a><ul>
<li><a href="#recombine">recombine</a></li>
<li><a href="#drblb">drBLB</a></li>
<li><a href="#drlm">drLM</a></li>
<li><a href="#drglm">drGLM</a></li>
<li><a href="#combcollect">combCollect</a></li>
<li><a href="#combddo">combDdo</a></li>
<li><a href="#combddf">combDdf</a></li>
<li><a href="#combrbind">combRbind</a></li>
<li><a href="#combmean">combMean</a></li>
<li><a href="#combmeancoef">combMeanCoef</a></li>
</ul></li>
<li><a href="#data-operations">Data Operations</a><ul>
<li><a href="#drfilter">drFilter</a></li>
<li><a href="#drjoin">drJoin</a></li>
<li><a href="#drlapply">drLapply</a></li>
<li><a href="#drsample">drSample</a></li>
<li><a href="#drsubset">drSubset</a></li>
</ul></li>
<li><a href="#mapreduce">MapReduce</a><ul>
<li><a href="#mrexec">mrExec</a></li>
</ul></li>
<li><a href="#misc">Misc</a><ul>
<li><a href="#flatten">flatten</a></li>
<li><a href="#bsv">bsv</a></li>
<li><a href="#drgetglobals">drGetGlobals</a></li>
<li><a href="#divide-internals">divide-internals</a></li>
<li><a href="#makeextractable">makeExtractable</a></li>
<li><a href="#mr-summary-stats">mr-summary-stats</a></li>
<li><a href="#getcondcuts">getCondCuts</a></li>
<li><a href="#getsplitvar">getSplitVar</a></li>
<li><a href="#getsplitvars">getSplitVars</a></li>
<li><a href="#getbsv">getBsv</a></li>
<li><a href="#getbsvs">getBsvs</a></li>
<li><a href="#adult">adult</a></li>
</ul></li>
</ul>
</div>
</div>
<div class="col-md-9" id="content-col">
<div id="content-top"></div>
<h1>
Divide and Recombine for Large, Complex Data
</h1>
<p>
<strong>Authors:</strong> <a href="mailto:[email protected]">Ryan Hafen</a> [aut, cre],Landon Sego [ctb]
</p>
<p>
<strong>Version:</strong> 0.8.5
</p>
<p>
<strong>License:</strong> BSD_3_clause + file LICENSE
</p>
<h4>
Description
</h4>
<p>
Methods for dividing data into subsets, applying analytical methods to the subsets, and recombining the results. Comes with a generic MapReduce interface as well. Works with key-value pairs stored in memory, on local disk, or on HDFS, in the latter case using the R and Hadoop Integrated Programming Environment (RHIPE).
</p>
<h4>
Depends
</h4>
<p>
(none)
</p>
<h4>
Imports
</h4>
<p>
data.table (>= 1.9.6), digest, codetools, hexbin, parallel, magrittr, dplyr, methods
</p>
<h4>
Suggests
</h4>
<p>
testthat (>= 0.11.0), roxygen2 (>= 5.0.1), Rhipe
</p>
<h4>
Enhances
</h4>
<p>
(none)
</p>
<div id="key-value-pairs" class="section level1">
<h1>Key-Value Pairs</h1>
<div id="kvpair" class="section level2">
<h2>kvPair</h2>
<h3>
Specify a Key-Value Pair
</h3>
<p class="rd-p">
Specify a key-value pair
</p>
<h4>
Usage
</h4>
<pre class="r"><code>kvPair(k, v)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
k
</dt>
<dd class="rd-dd">
key - any R object
</dd>
<dt>
v
</dt>
<dd class="rd-dd">
value - any R object
</dd>
</dl>
<h4>
Value
</h4>
<p class="rd-p">
<dl>
a list of objects of class “kvPair”
</dl>
</p>
<h4>
Examples
</h4>
<pre class="r"><code>kvPair("name", "bob")</code></pre>
<h4>
See also
</h4>
<p><code><a href=#kvpairs>kvPairs</a></code></p>
</div>
<div id="kvpairs" class="section level2">
<h2>kvPairs</h2>
<h3>
Specify a Collection of Key-Value Pairs
</h3>
<p class="rd-p">
Specify a collection of key-value pairs
</p>
<h4>
Usage
</h4>
<pre class="r"><code>kvPairs(...)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
…
</dt>
<dd class="rd-dd">
key-value pairs (lists with two elements)
</dd>
</dl>
<h4>
Value
</h4>
<p class="rd-p">
<dl>
a list of objects of class “kvPair”
</dl>
</p>
<h4>
Examples
</h4>
<pre class="r"><code>kvPairs(kvPair(1, letters), kvPair(2, rnorm(10)))</code></pre>
<h4>
See also
</h4>
<p><code><a href=#kvpair>kvPair</a></code></p>
</div>
<div id="print.kvpair" class="section level2">
<h2>print.kvPair</h2>
<h3>
Print a key-value pair
</h3>
<h4>
Usage
</h4>
<pre class="r"><code>printkvPair(x, ...)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
x
</dt>
<dd class="rd-dd">
object to be printed
</dd>
<dt>
…
</dt>
<dd class="rd-dd">
additional arguments
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code> kvPair(1, letters)</code></pre>
</div>
<div id="print.kvvalue" class="section level2">
<h2>print.kvValue</h2>
<h3>
Print value of a key-value pair
</h3>
<h4>
Usage
</h4>
<pre class="r"><code>printkvValue(x, ...)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
x
</dt>
<dd class="rd-dd">
object to be printed
</dd>
<dt>
…
</dt>
<dd class="rd-dd">
additional arguments
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code> kvPair(1, letters)</code></pre>
</div>
<div id="kvapply" class="section level2">
<h2>kvApply</h2>
<h3>
Apply Function to Key-Value Pair
</h3>
<p class="rd-p">
Apply a function to a single key-value pair - not a traditional R “apply” function.
</p>
<h4>
Usage
</h4>
<pre class="r"><code>kvApply(kvPair, fn)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
kvPair
</dt>
<dd class="rd-dd">
a key-value pair (a list with 2 elements or object created with <code><a href=#kvpair>kvPair</a></code>)
</dd>
<dt>
fn
</dt>
<dd class="rd-dd">
a function
</dd>
</dl>
<h4>
Details
</h4>
<p class="rd-p">
Determines how a function should be applied to a key-value pair and then applies it: if the function has two formals, it applies the function giving it the key and the value as the arguments; if the function has one formal, it applies the function giving it just the value. The function is assumed to return a value unless the result is a <code><a href=#kvpair>kvPair</a></code> object. When the function returns a value the original key will be returned in the resulting key-value pair.
</p>
<p class="rd-p">
This provides flexibility and simplicity for when a function is only meant to be applied to the value (the most common case), but still allows keys to be used if desired.
</p>
<h4>
Examples
</h4>
<pre class="r"><code>kv <- kvPair(1, 2)
kv
kvApply(kv, function(x) x^2)
kvApply(kv, function(k, v) v^2)
kvApply(kv, function(k, v) k + v)
kvApply(kv, function(x) kvPair("new_key", x))</code></pre>
</div>
</div>
<div id="distributed-data-objects" class="section level1">
<h1>Distributed data objects</h1>
<div id="ddo" class="section level2">
<h2>ddo</h2>
<h3>
Instantiate a Distributed Data Object (‘ddo’)
</h3>
<p class="rd-p">
Instantiate a distributed data object (‘ddo’)
</p>
<h4>
Usage
</h4>
<pre class="r"><code>ddo(conn, update = FALSE, reset = FALSE, control = NULL, verbose = TRUE)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
conn
</dt>
<dd class="rd-dd">
an object pointing to where data is or will be stored for the ddf object - can be a kvConnection object created from <code><a href=#localdiskconn>localDiskConn</a></code> or <code><a href=#hdfsconn>hdfsConn</a></code>, or a data frame or list of key-value pairs
</dd>
<dt>
update
</dt>
<dd class="rd-dd">
should the attributes of this object be updated? See <code><a href=#updateattributes>updateAttributes</a></code> for more details.
</dd>
<dt>
reset
</dt>
<dd class="rd-dd">
should all persistent metadata about this object be removed and the object created from scratch? This setting does not effect data stored in the connection location.
</dd>
<dt>
control
</dt>
<dd class="rd-dd">
parameters specifying how the backend should handle things if attributes are updated (most-likely parameters to <code>rhwatch</code> in RHIPE) - see <code><a href=#rhipecontrol>rhipeControl</a></code> and <code><a href=#localdiskcontrol>localDiskControl</a></code>
</dd>
<dt>
verbose
</dt>
<dd class="rd-dd">
logical - print messages about what is being done
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code>kv <- kvPairs(kvPair(1, letters), kvPair(2, rnorm(100)))
kvddo <- ddo(kv)
kvddo</code></pre>
</div>
<div id="ddf" class="section level2">
<h2>ddf</h2>
<h3>
Instantiate a Distributed Data Frame (‘ddf’)
</h3>
<p class="rd-p">
Instantiate a distributed data frame (‘ddf’)
</p>
<h4>
Usage
</h4>
<pre class="r"><code>ddf(conn, transFn = NULL, update = FALSE, reset = FALSE, control = NULL,
verbose = TRUE)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
conn
</dt>
<dd class="rd-dd">
an object pointing to where data is or will be stored for the ddf object - can be a kvConnection object created from <code><a href=#localdiskconn>localDiskConn</a></code> or <code><a href=#hdfsconn>hdfsConn</a></code>, or a data frame or list of key-value pairs
</dd>
<dt>
transFn
</dt>
<dd class="rd-dd">
transFn a function to be applied to the key-value pairs of this data prior to doing any processing, that transform the data into a data frame if it is not stored as such
</dd>
<dt>
update
</dt>
<dd class="rd-dd">
should the attributes of this object be updated? See <code><a href=#updateattributes>updateAttributes</a></code> for more details.
</dd>
<dt>
reset
</dt>
<dd class="rd-dd">
should all persistent metadata about this object be removed and the object created from scratch? This setting does not effect data stored in the connection location.
</dd>
<dt>
control
</dt>
<dd class="rd-dd">
parameters specifying how the backend should handle things if attributes are updated (most-likely parameters to <code>rhwatch</code> in RHIPE) - see <code><a href=#rhipecontrol>rhipeControl</a></code> and <code><a href=#localdiskcontrol>localDiskControl</a></code>
</dd>
<dt>
verbose
</dt>
<dd class="rd-dd">
logical - print messages about what is being done
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code># in-memory ddf
d <- ddf(iris)
d
# local disk ddf
conn <- localDiskConn(tempfile(), autoYes = TRUE)
addData(conn, list(list("1", iris[1:10,])))
addData(conn, list(list("2", iris[11:110,])))
addData(conn, list(list("3", iris[111:150,])))
dl <- ddf(conn)
dl
# hdfs ddf (requires RHIPE / Hadoop)
# connect to empty HDFS directory
conn <- hdfsConn("/tmp/irisSplit")
# add some data
addData(conn, list(list("1", iris[1:10,])))
addData(conn, list(list("2", iris[11:110,])))
addData(conn, list(list("3", iris[111:150,])))
# represent it as a distributed data frame
hdd <- ddf(conn)</code></pre>
</div>
<div id="updateattributes" class="section level2">
<h2>updateAttributes</h2>
<h3>
Update Attributes of a ‘ddo’ or ‘ddf’ Object
</h3>
<p class="rd-p">
Update attributes of a ‘ddo’ or ‘ddf’ object
</p>
<h4>
Usage
</h4>
<pre class="r"><code>updateAttributes(obj, control = NULL)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
obj
</dt>
<dd class="rd-dd">
an object of class ddo or ddf
</dd>
<dt>
control
</dt>
<dd class="rd-dd">
parameters specifying how the backend should handle things (most-likely parameters to <code>rhwatch</code> in RHIPE) - see <code><a href=#rhipecontrol>rhipeControl</a></code>
</dd>
</dl>
<h4>
Details
</h4>
<p class="rd-p">
This function looks for missing attributes related to a ddo or ddf (distributed data object or data frame) object and runs MapReduce to update them. These attributes include “splitSizeDistn”, “keys”, “nDiv”, “nRow”, and “splitRowDistn”. These attributes are useful for subsequent computations that might rely on them. The result is the input modified to reflect the updated attributes, and thus it should be used as <code>obj <- updateAttributes(obj)</code>.
</p>
<h4>
Value
</h4>
<p class="rd-p">
<dl>
an object of class ddo or ddf
</dl>
</p>
<h4>
References
</h4>
<p class="rd-p">
Bennett, Janine, et al. “Numerically stable, single-pass, parallel statistics algorithms. Cluster Computing and Workshops”, 2009. <em>CLUSTER09. IEEE International Conference on.</em> IEEE, 2009
</p>
<h4>
Examples
</h4>
<pre class="r"><code>d <- divide(iris, by = "Species")
# some attributes are missing:
d
summary(d)
d <- updateAttributes(d)
# now all attributes are available:
d
summary(d)</code></pre>
<h4>
See also
</h4>
<p><code><a href=#ddo>ddo</a></code>, <code><a href=#ddf>ddf</a></code>, <code><a href=#divide>divide</a></code></p>
<h4>
Author
</h4>
<p>Ryan Hafen</p>
</div>
<div id="ddf-accessors" class="section level2">
<h2>ddf-accessors</h2>
<h3>
Accessor methods for ‘ddf’ objects
</h3>
<h4>
Usage
</h4>
<pre class="r"><code>splitRowDistn(x)
summaryddo(object, ...)
summaryddf(object, ...)
nrow(x)
NROW(x)
ncol(x)
NCOL(x)
nrowddf(x)
NROWddf(x)
ncolddf(x)
NCOLddf(x)
namesddf(x)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
x
</dt>
<dd class="rd-dd">
a ddf object
</dd>
<dt>
object
</dt>
<dd class="rd-dd">
a ddf/ddo object
</dd>
<dt>
…
</dt>
<dd class="rd-dd">
additional arguments
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code>d <- divide(iris, by = "Species", update = TRUE)
nrow(d)
ncol(d)
length(d)
names(d)
summary(d)
getKeys(d)</code></pre>
</div>
<div id="ddo-ddf-accessors" class="section level2">
<h2>ddo-ddf-accessors</h2>
<h3>
Accessor Functions
</h3>
<p class="rd-p">
Accessor functions for attributes of ddo/ddf objects. Methods also include <code>nrow</code> and <code>ncol</code> for ddf objects.
</p>
<h4>
Usage
</h4>
<pre class="r"><code>kvExample(x)
bsvInfo(x)
counters(x)
splitSizeDistn(x)
getKeys(x)
hasExtractableKV(x)
lengthddo(x)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
x
</dt>
<dd class="rd-dd">
a ddf/ddo object
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code>d <- divide(iris, by = "Species", update = TRUE)
nrow(d)
ncol(d)
length(d)
names(d)
summary(d)
getKeys(d)</code></pre>
</div>
<div id="ddo-ddf-attributes" class="section level2">
<h2>ddo-ddf-attributes</h2>
<h3>
Managing attributes of ‘ddo’ or ‘ddf’ objects
</h3>
<p class="rd-p">
These are called internally in various datadr functions. They are not meant for use outside of there, but are exported for convenience, and can be useful for better understanding ddo/ddf objects.
</p>
<h4>
Usage
</h4>
<pre class="r"><code>setAttributes(obj, attrs)
setAttributesddf(obj, attrs)
setAttributesddo(obj, attrs)
getAttribute(obj, attrName)
getAttributes(obj, attrNames)
getAttributesddf(obj, attrNames)
getAttributesddo(obj, attrNames)
hasAttributes(obj, ...)
hasAttributesddf(obj, attrNames)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
obj
</dt>
<dd class="rd-dd">
ddo or ddf object
</dd>
<dt>
attrs
</dt>
<dd class="rd-dd">
a named list of attributes to set
</dd>
<dt>
attrName
</dt>
<dd class="rd-dd">
name of the attribute to get
</dd>
<dt>
attrNames
</dt>
<dd class="rd-dd">
vector of names of the attributes to get
</dd>
<dt>
…
</dt>
<dd class="rd-dd">
additional arguments
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code>d <- divide(iris, by = "Species")
getAttribute(d, "keys")</code></pre>
</div>
<div id="print.ddo" class="section level2">
<h2>print.ddo</h2>
<h3>
Print a “ddo” or “ddf” Object
</h3>
<p class="rd-p">
Print an overview of attributes of distributed data objects (ddo) or distributed data frames (ddf)
</p>
<h4>
Usage
</h4>
<pre class="r"><code>printddo(x, ...)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
x
</dt>
<dd class="rd-dd">
object to be printed
</dd>
<dt>
…
</dt>
<dd class="rd-dd">
additional arguments
</dd>
</dl>
<h4>
Examples
</h4>
<pre class="r"><code>kv <- kvPairs(kvPair(1, letters), kvPair(2, rnorm(100)))
kvddo <- ddo(kv)
kvddo</code></pre>
<h4>
Author
</h4>
<p>Ryan Hafen</p>
</div>
</div>
<div id="back-end-connections" class="section level1">
<h1>Back End Connections</h1>
<div id="localdiskconn" class="section level2">
<h2>localDiskConn</h2>
<h3>
Connect to Data Source on Local Disk
</h3>
<p class="rd-p">
Connect to a data source on local disk
</p>
<h4>
Usage
</h4>
<pre class="r"><code>localDiskConn(loc, nBins = 0, fileHashFn = NULL, autoYes = FALSE,
reset = FALSE, verbose = TRUE)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
loc
</dt>
<dd class="rd-dd">
location on local disk for the data source
</dd>
<dt>
nBins
</dt>
<dd class="rd-dd">
number of bins (subdirectories) to put data files into - if anticipating a large number of k/v pairs, it is a good idea to set this to something bigger than 0
</dd>
<dt>
fileHashFn
</dt>
<dd class="rd-dd">
an optional function that operates on each key-value pair to determine the subdirectory structure for where the data should be stored for that subset, or can be specified “asis” when keys are scalar strings
</dd>
<dt>
autoYes
</dt>
<dd class="rd-dd">
automatically answer “yes” to questions about creating a path on local disk
</dd>
<dt>
reset
</dt>
<dd class="rd-dd">
should existing metadata for this object be overwritten?
</dd>
<dt>
verbose
</dt>
<dd class="rd-dd">
logical - print messages about what is being done
</dd>
</dl>
<h4>
Details
</h4>
<p class="rd-p">
This simply creates a “connection” to a directory on local disk (which need not have data in it). To actually do things with this connection, see <code><a href=#ddo>ddo</a></code>, etc. Typically, you should just use <code>loc</code> to specify where the data is or where you would like data for this connection to be stored. Metadata for the object is also stored in this directory.
</p>
<h4>
Value
</h4>
<p class="rd-p">
<dl>
a “kvConnection” object of class “localDiskConn”
</dl>
</p>
<h4>
Examples
</h4>
<pre class="r"><code># connect to empty localDisk directory
conn <- localDiskConn(file.path(tempdir(), "irisSplit"), autoYes = TRUE)
# add some data
addData(conn, list(list("1", iris[1:10,])))
addData(conn, list(list("2", iris[11:110,])))
addData(conn, list(list("3", iris[111:150,])))
# represent it as a distributed data frame
irisDdf <- ddf(conn, update = TRUE)
irisDdf</code></pre>
<h4>
See also
</h4>
<p><code><a href=#adddata>addData</a></code>, <code><a href=#ddo>ddo</a></code>, <code><a href=#ddf>ddf</a></code>, <code><a href=#localdiskconn>localDiskConn</a></code></p>
<h4>
Author
</h4>
<p>Ryan Hafen</p>
</div>
<div id="digestfilehash" class="section level2">
<h2>digestFileHash</h2>
<h3>
Digest File Hash Function
</h3>
<p class="rd-p">
Function to be used to specify the file where key-value pairs get stored for local disk connections, useful when keys are arbitrary objects. File names are determined using a md5 hash of the object. This is the default argument for <code>fileHashFn</code> in <code><a href='localDiskConn.html'>localDiskConn</a></code>.
</p>
<h4>
Usage
</h4>
<pre class="r"><code>digestFileHash(keys, conn)</code></pre>
<h4>
Arguments
</h4>
<dl class="rd-dl">
<dt>
keys
</dt>
<dd class="rd-dd">
keys to be hashed
</dd>
<dt>
conn
</dt>
<dd class="rd-dd">
a “localDiskConn” object
</dd>
</dl>
<h4>
Details
</h4>
<p class="rd-p">
You shouldnt need to call this directly other than to experiment with what the output looks like or to get ideas on how to write your own custom hash.
</p>
<h4>
Examples
</h4>
<pre class="r"><code># connect to empty localDisk directory
path <- file.path(tempdir(), "irisSplit")
unlink(path, recursive = TRUE)
conn <- localDiskConn(path, autoYes = TRUE, fileHashFn = digestFileHash)
# add some data
addData(conn, list(list("key1", iris[1:10,])))
addData(conn, list(list("key2", iris[11:110,])))
addData(conn, list(list("key3", iris[111:150,])))
# see that files were stored by their key
list.files(path)</code></pre>
<h4>
See also
</h4>
<p><code><a href=#localdiskconn>localDiskConn</a></code>, <code><a href=#charfilehash>charFileHash</a></code></p>
<h4>
Author
</h4>
<p>Ryan Hafen</p>
</div>
<div id="charfilehash" class="section level2">
<h2>charFileHash</h2>