Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle UDFs in the context of DataFrames #427

Draft
wants to merge 2 commits into
base: master
from

Conversation

@SinghGursimran
Copy link
Collaborator

SinghGursimran commented Mar 6, 2020

Restyle UDFs in the context of DataFrames.

#425

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"url",$"http_status_code")
			.filter(hasHttpStatusDF($"http_status_code", lit(Array("200","000"))))
			.show(10,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"content")
			.filter(hasContentDF($"content", lit(Array("Content-Length: [0-9]{4}"))))
			.show(3,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"url")
			.filter(hasUrlPatternsDF($"url", lit(Array(".*images.*"))))
			.show(10,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select(DetectLanguageDF(RemoveHTMLDF($"content")).as("language"))
			.filter(hasLanguagesDF(DetectLanguageDF(RemoveHTMLDF($"content")), lit(Array("de","ht"))))
			.show(10,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"mime_type_web_server")
			.filter(hasMimeTypesDF($"mime_type_web_server", lit(Array("text/html"))))
			.show(10,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"url")
			.filter(hasUrlsDF($"url", lit(Array("http://www.archive.org/","http://www.archive.org/robots.txt"))))
			.show(10,false)

import org.apache.spark.sql.functions.lit
import io.archivesunleashed._
import io.archivesunleashed.df._

RecordLoader.loadArchives("./src/test/resources/arc/example.arc.gz",sc)
			.all()
			.select($"url")
			.filter(hasDomainsDF(ExtractDomainDF($"url"), lit(Array("www.archive.org"))))
			.show(10,false)
g285sing
@SinghGursimran

This comment has been minimized.

Copy link
Collaborator Author

SinghGursimran commented Mar 6, 2020

Please let me know if this format is fine so I will change the other API's as well. It requires a bit more function calls on the user side.

@codecov

This comment has been minimized.

Copy link

codecov bot commented Mar 6, 2020

Codecov Report

Merging #427 into master will decrease coverage by 0.37%.
The diff coverage is 44.44%.

@@            Coverage Diff             @@
##           master     #427      +/-   ##
==========================================
- Coverage   78.15%   77.77%   -0.38%     
==========================================
  Files          41       41              
  Lines        1584     1602      +18     
  Branches      299      303       +4     
==========================================
+ Hits         1238     1246       +8     
- Misses        218      228      +10     
  Partials      128      128
@ruebot

This comment has been minimized.

Copy link
Member

ruebot commented Mar 6, 2020

Format appears right, but I believe one of the goals was to collapse the keep/discard into has.

So, it should be:

  • filter(hasHTTPStatus($"column_name", lit(Array("200","000"))))
  • filter(!hasHTTPStatus($"column_name", lit(Array("200","000"))))

@lintool sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.