My favorites | Sign in
Project Logo
                
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
package shadoop

import org.apache.hadoop.fs.Path
import org.apache.hadoop.io.{BooleanWritable, IntWritable, LongWritable, FloatWritable, Text, UTF8}

object SHadoop {

implicit def writable2boolean(value: BooleanWritable) = value.get
implicit def boolean2writable(value: Boolean) = new BooleanWritable(value)

implicit def writable2int(value: IntWritable) = value.get
implicit def int2writable(value: Int) = new IntWritable(value)

implicit def writable2long(value: LongWritable) = value.get
implicit def long2writable(value: Long) = new LongWritable(value)

implicit def writable2float(value: FloatWritable) = value.get
implicit def float2writable(value: Float) = new FloatWritable(value)

implicit def text2string(value: Text) = value.toString
implicit def string2text(value: String) = new Text(value)

implicit def uft82string(value: UTF8) = value.toString
implicit def string2utf8(value: String) = new UTF8(value)

implicit def path2string(value: Path) = value.toString
implicit def string2path(value: String) = new Path(value)

implicit def javaIterator2Iterator[A](value: java.util.Iterator[A]) = new Iterator[A] {
def hasNext = value.hasNext
def next = value.next
}

implicit def javaIterator2BooleanIterator(value: java.util.Iterator[BooleanWritable]) = new Iterator[Boolean] {
def hasNext = value.hasNext
def next = value.next.get
}

implicit def javaIterator2IntIterator(value: java.util.Iterator[IntWritable]) = new Iterator[Int] {
def hasNext = value.hasNext
def next = value.next.get
}

implicit def javaIterator2LongIterator(value: java.util.Iterator[LongWritable]) = new Iterator[Long] {
def hasNext = value.hasNext
def next = value.next.get
}

implicit def javaIterator2FloatIterator(value: java.util.Iterator[FloatWritable]) = new Iterator[Float] {
def hasNext = value.hasNext
def next = value.next.get
}

implicit def javaIterator2TextIterator(value: java.util.Iterator[Text]) = new Iterator[String] {
def hasNext = value.hasNext
def next = value.next.toString
}

implicit def javaIterator2UTF8Iterator(value: java.util.Iterator[UTF8]) = new Iterator[String] {
def hasNext = value.hasNext
def next = value.next.toString
}

}
Show details Hide details

Change log

r37 by jonhnnyweslley on May 13, 2008   Diff
Initial version
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2256 bytes, 64 lines
Hosted by Google Code