embulk-output-key_to_redis 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57b3d726f99858c48efbd8330847c5559aefeeb0
4
- data.tar.gz: 47c6ffb23ff8fe4855b3ae454a934e99f1e82b8e
3
+ metadata.gz: cacc8741d9141b1fc1de001245082f1542849df9
4
+ data.tar.gz: f91d317b22fc2a87d30044d14f0498a1bf39e368
5
5
  SHA512:
6
- metadata.gz: a1414c7c8d0a857993158ef9676928eb0669fe127b89806867c8e6b961869a5b2e1e44be43841332522a30298b417c223e3786aa567de9daf975d1c96d4f647c
7
- data.tar.gz: d681bb485688f4c644765fd0c3725b1b7c099b5da1d71e8b11c1c89fbc01c758cce26b322d0b878c4e9815f158f7b69b978095b6a992ea6dc4a2a5d839835e1d
6
+ metadata.gz: cfeb481de84ff42d12b0c361b989736851bdf007ae73b25ea1de18837b2a676e3a35465c642cc82c887b7943404c5ed3a6c00a3064582761f6b1591a5bb05514
7
+ data.tar.gz: 3fcfac83f63fbbfc9cd7e2b5142d3ddd7bffe0158d0d8c5935fd2fab2ea40d37190061e2bfb30b81ddf6ceaff3bc77e0a3a5780e2d88c21a3ae9f64770c8d804
@@ -0,0 +1,27 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ executorType: docker
5
+ docker:
6
+ - image: hseeberger/scala-sbt
7
+ working_directory: /root/embulk-output-key_to_redis/
8
+ steps:
9
+ - checkout
10
+ - restore_cache:
11
+ name: Restoring Cache
12
+ keys:
13
+ - sbt
14
+ - setup_remote_docker
15
+ - run:
16
+ name: prepare
17
+ command: sbt update exit
18
+ - save_cache:
19
+ name: Saving Cache sbt
20
+ key: sbt
21
+ paths:
22
+ - "/root/.sbt"
23
+ - "/root/.ivy2"
24
+ - run:
25
+ name: compile
26
+ command: |
27
+ sbt compile test scalafmt::test exit
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Key To Redis output plugin for Embulk
2
2
 
3
- Output the aggregated key into set of the Redis plugin.
3
+ Generate the aggregated key from input values and output to Redis's SET value.
4
4
 
5
5
  This plugin is designed to extract data set diff files used with the combination in below use cases.
6
6
 
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.0"
16
+ version = "0.1.1"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -8,8 +8,12 @@ import org.embulk.output.key_to_redis.column._
8
8
  import org.embulk.spi.time.TimestampFormatter
9
9
  import org.embulk.spi._
10
10
  import org.bouncycastle.util.encoders.Hex
11
+ import org.embulk.output.key_to_redis.redis.Redis
11
12
 
12
13
  import scala.collection.JavaConverters._
14
+ import scala.concurrent.duration._
15
+ import scala.collection.mutable.ListBuffer
16
+ import scala.concurrent.{Await, Future}
13
17
 
14
18
  case class PageOutput(taskSource: TaskSource,
15
19
  schema: Schema,
@@ -21,6 +25,10 @@ case class PageOutput(taskSource: TaskSource,
21
25
  def timestampFormatter(): TimestampFormatter =
22
26
  new TimestampFormatter(task, Optional.absent())
23
27
 
28
+ val buffer = new ListBuffer[Future[Long]]
29
+ val redis: Redis =
30
+ KeyToRedisOutputPlugin.redis.getOrElse(sys.error("could not find redis."))
31
+
24
32
  override def add(page: Page): Unit = {
25
33
  val reader: PageReader = new PageReader(schema)
26
34
  reader.setPage(page)
@@ -37,17 +45,21 @@ case class PageOutput(taskSource: TaskSource,
37
45
  if (putAsMD5) {
38
46
  val hash = Hex.toHexString(
39
47
  digestMd5.digest(setValueVisitor.getValue.getBytes()))
40
- KeyToRedisOutputPlugin.redis.foreach(_.sadd(hash))
48
+ buffer.append(redis.sadd(hash))
41
49
  } else {
42
- KeyToRedisOutputPlugin.redis.foreach(
43
- _.sadd(setValueVisitor.getValue))
50
+ buffer.append(redis.sadd(setValueVisitor.getValue))
44
51
  }
45
52
  }
46
53
  }
47
54
  reader.close()
48
55
  }
49
56
 
50
- override def finish(): Unit = ()
57
+ override def finish(): Unit = {
58
+ import scala.concurrent.ExecutionContext.Implicits.global
59
+ val sequence = Future.sequence(buffer)
60
+ Await.result(sequence, Duration.Inf)
61
+ }
62
+
51
63
  override def close(): Unit = ()
52
64
  override def commit(): TaskReport = Exec.newTaskReport
53
65
  override def abort(): Unit = ()
@@ -23,9 +23,8 @@ case class Redis(setKey: String, host: String, port: Int, db: Option[Int]) {
23
23
  }
24
24
  Await.result(s, 10.minute)
25
25
  }
26
- def sadd(value: String): Long = {
27
- val s = redis.sadd(setKey, value)
28
- Await.result(s, 10.minute)
26
+ def sadd(value: String): Future[Long] = {
27
+ redis.sadd(setKey, value)
29
28
  }
30
29
 
31
30
  def flush(): Boolean = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-key_to_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - smdmts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - .circleci/config.yml
48
49
  - .gitignore
49
50
  - LICENSE.txt
50
51
  - README.md
@@ -77,7 +78,7 @@ files:
77
78
  - classpath/circe-numbers_2.11-0.8.0.jar
78
79
  - classpath/circe-parser_2.11-0.8.0.jar
79
80
  - classpath/config-1.2.1.jar
80
- - classpath/embulk-output-key_to_redis-0.1.0.jar
81
+ - classpath/embulk-output-key_to_redis-0.1.1.jar
81
82
  - classpath/jawn-parser_2.11-0.10.4.jar
82
83
  - classpath/machinist_2.11-0.6.1.jar
83
84
  - classpath/macro-compat_2.11-1.1.1.jar