Discussion:
Is it possible to that mutiple rows have same index in DrmLike[Int]
KHATWANI PARTH BHARAT
2017-04-29 19:08:58 UTC
Permalink
I am trying to assign same value to keys of DrmLike[Int] using keys.update
method inside the mapbloack() using the following code(Found from Apache
Mahout Beyond Mapreduce Books github Repo from TWCNB.scala example
<https://github.com/andrewpalumbo/mahout-samsara-book/blob/master/myMahoutApp/src/main/scala/myMahoutApp/TWCNB.scala>
)

1)val inCoreA = dense((1, 2, 3,0), (2, 3, 4,0), (3, 4, 5,1), (4, 5, 6,1))

2) val drmNtNonEmpty = drmParallelize(m = inCoreA).mapBlock(ncol =
inCoreA.ncol - 1){
3) case (keys, block) => // strip the classes off the
matrix 4) val classes = block(::, block.ncol - 1) 5)
for(i <- 0 until keys.size){ // set the keys as the class
for that row 6) println("i:-"+i+" cluster
index:-"+classes(i).toInt) 7) keys.update(i,
classes(i).toInt) 8) } 9) for(i <- 0 until keys.size){
10) println(keys(i)); 11) } 12) (keys ,
block(::, 0 until block.ncol - 1)) 13)}


now when i print drmNtNonEmpty using collect operation after step i
get the following result

{
0 => {0:1.0, 1: 1.0, 2: 1.0, 3: 3.0}
1 => {0:1.0, 1: 2.0, 2: 3.0, 3: 4.0}
2 => {0:1.0, 1: 3.0, 2: 4.0, 3: 5.0}
3 => {0:1.0, 1: 4.0, 2: 5.0, 3: 6.0}
}

print statement at line number 6 prints the following result
i:-0 cluster index:-0
i:-1 cluster index:-0
i:-2 cluster index:-1
i:-3 cluster index:-1


print statement at line number 10 print the following
0
0
1
1

When i try to print the matrix drmNtNonEmpty after line number 13
i am expecting the output to be as following

{
0 => {0:1.0, 1: 1.0, 2: 1.0, 3: 3.0}
0 => {0:1.0, 1: 2.0, 2: 3.0, 3: 4.0}
1 => {0:1.0, 1: 3.0, 2: 4.0, 3: 5.0}
1 => {0:1.0, 1: 4.0, 2: 5.0, 3: 6.0}
}

but what i am getting the output is

{
0 => {0:1.0, 1: 2.0, 2: 3.0, 3: 4.0}
1 => {0:1.0, 1: 4.0, 2: 5.0, 3: 6.0}
2 => {}
3 => {}
}

Now what i want to know is that weather it is possible to result
which i am trying to achive
Or is there any problem with what i have understood about the row keys
of DrmLike[Int]

Are DrmLike[Int] row keys immutable?
Need some reference regarding the same.



Thanks & Regards
Parth Khatwani

Loading...