Skip to content

Commit 1e2b145

Browse files
committed
README: mv all the comments into code blocks
1 parent e42320c commit 1e2b145

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spark-Redis
22

3-
Spark-Redis is a connector for reading/writing from Redis cluster directly via Spark. It supports all the
4-
types of Redis structures: Plain Key/Value, Hash, ZSet, Set, List
3+
Spark-Redis is a connector for reading/writing from Redis cluster or non-cluster directly via Spark.
4+
It supports all the types of Redis structures: Plain Key/Value, Hash, ZSet, Set, List.
55
In Spark, the data from Redis is represented as an RDD with the tolerance of reshard and down of nodes.
66

77
Integrating Redis and Spark gives us a system that combines the best of both worlds.
@@ -79,50 +79,50 @@ In the example we can see how to read from Redis Server.
7979
```
8080
import com.redislabs.provider.redis._
8181
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
82+
#keyPattern should be a plain string or a RedisRegex.
83+
#keysRDD is a RDD holds all the keys of keyPattern of the redis server.
84+
#keysRDD is divided into 5(default 3) partitions by hash slots.
8285
```
83-
keyPattern should be a plain string or a RedisRegex.
84-
keysRDD is a RDD holds all the keys of keyPattern of the redis server.
85-
keysRDD is divided into 5(default 3) partitions by hash slots.
8686

8787
Using Redis' Key/Values
8888
```
8989
import com.redislabs.provider.redis._
9090
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
9191
val kvRDD = keysRDD.getKV
92+
#kvRDD is a RDD holds all the k/v pairs whose k's pattern is keyPattern, and k must be of 'string' type in redis-server.
9293
```
93-
kvRDD is a RDD holds all the k/v pairs whose k's pattern is keyPattern, and k must be of 'string' type in redis-server.
9494

9595
Using Redis' Hash
9696
```
9797
import com.redislabs.provider.redis._
9898
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
9999
val hashRDD = keysRDD.getHash
100+
#hashRDD is a RDD holds all the dicts' contents, and the dicts' names must be of keyPattern and exists in the redis-server.
100101
```
101-
hashRDD is a RDD holds all the dicts' contents, and the dicts' names must be of keyPattern and exists in the redis-server.
102102

103103
Using Redis' ZSet
104104
```
105105
import com.redislabs.provider.redis._
106106
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
107107
val zsetRDD = keysRDD.getZSet
108+
#zsetRDD is a RDD holds all the zsets' contents(key, score), and the zsets' names must be of keyPattern and exists in the redis-server.
108109
```
109-
zsetRDD is a RDD holds all the zsets' contents(key, score), and the zsets' names must be of keyPattern and exists in the redis-server.
110110

111111
Using Redis' List
112112
```
113113
import com.redislabs.provider.redis._
114114
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
115115
val listRDD = keysRDD.getList
116+
#listRDD is a RDD holds all the lists' contents, and the lists' names must be of keyPattern and exists in the redis-server.
116117
```
117-
listRDD is a RDD holds all the lists' contents, and the lists' names must be of keyPattern and exists in the redis-server.
118118

119119
Using Redis' Set
120120
```
121121
import com.redislabs.provider.redis._
122122
val keysRDD = sc.fromRedisKeyPattern(("127.0.0.1", 7000), "keyPattern", 5)
123123
val setRDD = keysRDD.getSet
124+
#setRDD is a RDD holds all the sets' contents, score), and the sets' names must be of keyPattern and exists in the redis-server.
124125
```
125-
setRDD is a RDD holds all the sets' contents, score), and the sets' names must be of keyPattern and exists in the redis-server.
126126

127127
*****
128128

@@ -135,37 +135,37 @@ Saving as Redis' Key/Values
135135
import com.redislabs.provider.redis._
136136
val kvRDD = ...
137137
sc.toRedisKV(kvRDD, ("127.0.0.1", 7000))
138+
#kvRDD is a RDD holds k/v pairs, we will store all the k/v pairs of kvRDD to the redis-server
138139
```
139-
kvRDD is a RDD holds k/v pairs, we will store all the k/v pairs of kvRDD to the redis-server
140140

141141
Saving as Redis' Hash
142142
```
143143
import com.redislabs.provider.redis._
144144
val hashRDD = ...
145145
sc.toRedisHASH(hashRDD, hashName, ("127.0.0.1", 7000))
146+
#hashRDD is a RDD holds k/v pairs, we will store all the k/v pairs of hashRDD to a dict named hashName to the redis-server
146147
```
147-
hashRDD is a RDD holds k/v pairs, we will store all the k/v pairs of hashRDD to a dict named hashName to the redis-server
148148

149149
Saving as Redis' ZSet
150150
```
151151
import com.redislabs.provider.redis._
152152
val zsetRDD = ...
153153
sc.toRedisZSET(zsetRDD, zsetName, ("127.0.0.1", 7000))
154+
#zsetRDD is a RDD holds k/v pairs, we will store all the k/v pairs of zsetRDD to a zset named zsetName to the redis-server
154155
```
155-
zsetRDD is a RDD holds k/v pairs, we will store all the k/v pairs of zsetRDD to a zset named zsetName to the redis-server
156156

157157
Saving as Redis' List
158158
```
159159
import com.redislabs.provider.redis._
160160
val listRDD = ...
161161
sc.toRedisLIST(listRDD, listName, ("127.0.0.1", 7000))
162+
#listRDD is a RDD holds strings, we will store all the strings of listRDD to a list named listName to the redis-server
162163
```
163-
listRDD is a RDD holds strings, we will store all the strings of listRDD to a list named listName to the redis-server
164164

165165
Saving as Redis' Set
166166
```
167167
import com.redislabs.provider.redis._
168168
val setRDD = ...
169169
sc.toRedisSET(setRDD, setName, ("127.0.0.1", 7000))
170+
#setRDD is a RDD holds strings, we will store all the unique strings of setRDD to a set named setName to the redis-server
170171
```
171-
setRDD is a RDD holds strings, we will store all the unique strings of setRDD to a set named setName to the redis-server

0 commit comments

Comments
 (0)