Last active
July 14, 2016 19:04
-
-
Save clarkfitzg/a9742b19a7845eaef36dc62e2c147e0a to your computer and use it in GitHub Desktop.
Creating and accessing the parts of a nonuniform distributed array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> library(ddR) | |
Welcome to 'ddR' (Distributed Data-structures in R)! | |
For more information, visit: https://github.com/vertica/ddR | |
Attaching package: ‘ddR’ | |
The following objects are masked from ‘package:base’: | |
cbind, rbind | |
> m1 = matrix(1:4, nrow=2) | |
> m2 = matrix(1:20, nrow=2) | |
> m3 = matrix(1:20, ncol=2) | |
> m4 = matrix(0, nrow=10, ncol=10) | |
> dl = dlist(m1, m2, m3, m4) | |
> da = dmapply(function(x) x, dl, output.type = "darray", nparts = c(2, 2), combine = "rbind") | |
> da | |
ddR Distributed Object | |
Type: darray | |
# of partitions: 4 | |
Partitions per dimension: 2x2 | |
Partition sizes: [2, 2], [2, 10], [10, 2], [10, 10] | |
Dim: 12,12 | |
Backend: parallel | |
> collect(da) | |
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] | |
[1,] 1 3 1 3 5 7 9 11 13 15 17 19 | |
[2,] 2 4 2 4 6 8 10 12 14 16 18 20 | |
[3,] 1 11 0 0 0 0 0 0 0 0 0 0 | |
[4,] 2 12 0 0 0 0 0 0 0 0 0 0 | |
[5,] 3 13 0 0 0 0 0 0 0 0 0 0 | |
[6,] 4 14 0 0 0 0 0 0 0 0 0 0 | |
[7,] 5 15 0 0 0 0 0 0 0 0 0 0 | |
[8,] 6 16 0 0 0 0 0 0 0 0 0 0 | |
[9,] 7 17 0 0 0 0 0 0 0 0 0 0 | |
[10,] 8 18 0 0 0 0 0 0 0 0 0 0 | |
[11,] 9 19 0 0 0 0 0 0 0 0 0 0 | |
[12,] 10 20 0 0 0 0 0 0 0 0 0 0 | |
> parts(da, 2) | |
[[1]] | |
ddR Distributed Object | |
Type: darray | |
# of partitions: 1 | |
Partitions per dimension: 1x1 | |
Partition sizes: [2, 10] | |
Dim: 2,10 | |
Backend: parallel | |
> collect(da, 2) | |
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] | |
[1,] 1 3 5 7 9 11 13 15 17 19 | |
[2,] 2 4 6 8 10 12 14 16 18 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment