-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDB Shredder: send shredding info to SQS when it's done (close #200)
- Loading branch information
Showing
13 changed files
with
303 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
modules/common/src/test/scala/com.snowplowanalytics.snowplow.rdbloader.common/S3Spec.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2020-2021 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. | ||
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the Apache License Version 2.0 is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
*/ | ||
|
||
package com.snowplowanalytics.snowplow.rdbloader.common | ||
|
||
import org.specs2.mutable.Specification | ||
|
||
class S3Spec extends Specification { | ||
"S3.Folder.parse()" should { | ||
"support s3:// prefix" >> { | ||
val folder = "s3://foo/" | ||
S3.Folder.parse(folder) must beRight | ||
} | ||
"support s3a:// prefix" >> { | ||
val folder = "s3a://foo/" | ||
S3.Folder.parse(folder) must beRight | ||
} | ||
"support s3n:// prefix" >> { | ||
val folder = "s3n://foo/" | ||
S3.Folder.parse(folder) must beRight | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
61 changes: 61 additions & 0 deletions
61
...rc/main/scala/com.snowplowanalytics.snowplow.storage/spark/ShreddedTypesAccumulator.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Apache License Version 2.0, | ||
* and you may not use this file except in compliance with the Apache License Version 2.0. | ||
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the Apache License Version 2.0 is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
*/ | ||
package com.snowplowanalytics.snowplow.storage.spark | ||
|
||
import org.apache.spark.util.AccumulatorV2 | ||
|
||
import scala.collection.mutable | ||
|
||
import com.snowplowanalytics.snowplow.rdbloader.common.LoaderMessage.ShreddedType | ||
|
||
import ShreddedTypesAccumulator._ | ||
|
||
class ShreddedTypesAccumulator extends AccumulatorV2[KeyAccum, KeyAccum] { | ||
|
||
private val accum = mutable.Set.empty[ShreddedType] | ||
|
||
def merge(other: AccumulatorV2[KeyAccum, KeyAccum]): Unit = other match { | ||
case o: ShreddedTypesAccumulator => accum ++= o.accum | ||
case _ => throw new UnsupportedOperationException( | ||
s"Cannot merge ${this.getClass.getName} with ${other.getClass.getName}") | ||
} | ||
|
||
def isZero: Boolean = accum.isEmpty | ||
|
||
def copy(): AccumulatorV2[KeyAccum, KeyAccum] = { | ||
val newAcc = new ShreddedTypesAccumulator | ||
accum.synchronized { | ||
newAcc.accum ++= accum | ||
} | ||
newAcc | ||
} | ||
|
||
def value = accum | ||
|
||
def add(keys: KeyAccum): Unit = { | ||
accum ++= keys | ||
} | ||
|
||
def add(keys: Set[ShreddedType]): Unit = { | ||
val mutableSet = mutable.Set(keys.toList: _*) | ||
add(mutableSet) | ||
} | ||
|
||
def reset(): Unit = { | ||
accum.clear() | ||
} | ||
} | ||
|
||
object ShreddedTypesAccumulator { | ||
type KeyAccum = mutable.Set[ShreddedType] | ||
} |
Oops, something went wrong.