-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Serializable APIs for DataFrames (#389)
- Add keepValidPagesDF - Add HTTP status code column to all() - Add test for keepValidPagesDF - Addresses #223
- Loading branch information
Showing
2 changed files
with
86 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright © 2017 The Archives Unleashed Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.archivesunleashed | ||
|
||
import com.google.common.io.Resources | ||
import org.apache.spark.{SparkConf, SparkContext} | ||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.{BeforeAndAfter, FunSuite} | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class RecordDFTest extends FunSuite with BeforeAndAfter { | ||
private val arcPath = Resources.getResource("arc/example.arc.gz").getPath | ||
private val badPath = Resources.getResource("arc/badexample.arc.gz").getPath | ||
private val master = "local[4]" | ||
private val appName = "example-spark" | ||
private var sc: SparkContext = _ | ||
private val archive = "http://www.archive.org/" | ||
private val sloan = "http://www.sloan.org" | ||
private val regex = raw"Please visit our website at".r | ||
|
||
before { | ||
val conf = new SparkConf() | ||
.setMaster(master) | ||
.setAppName(appName) | ||
conf.set("spark.driver.allowMultipleContexts", "true"); | ||
sc = new SparkContext(conf) | ||
} | ||
|
||
test("keep Valid Pages") { | ||
val expected = "http://www.archive.org/" | ||
val base = RecordLoader.loadArchives(arcPath, sc).all() | ||
.keepValidPagesDF().take(1)(0)(1) | ||
assert (base.toString == expected) | ||
} | ||
|
||
after { | ||
if (sc != null) { | ||
sc.stop() | ||
} | ||
} | ||
} |