Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Bacheloroppgave_2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eilert Tunheim
Bacheloroppgave_2022
Commits
17b8327c
Commit
17b8327c
authored
3 years ago
by
Karin Pettersen
Browse files
Options
Downloads
Patches
Plain Diff
Created getBuilder
parent
af92e084
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/application/DB/DB.java
+13
-7
13 additions, 7 deletions
src/main/java/com/application/DB/DB.java
src/main/java/com/application/DB/Sort.java
+5
-0
5 additions, 0 deletions
src/main/java/com/application/DB/Sort.java
with
18 additions
and
7 deletions
src/main/java/com/application/DB/DB.java
+
13
−
7
View file @
17b8327c
...
...
@@ -9,6 +9,7 @@ import com.google.cloud.bigquery.Job;
import
com.google.cloud.bigquery.JobInfo
;
import
com.google.cloud.bigquery.QueryJobConfiguration
;
import
com.google.cloud.bigquery.TableResult
;
import
com.sun.media.jfxmedia.AudioClip
;
import
java.io.File
;
import
java.io.FileInputStream
;
...
...
@@ -28,16 +29,20 @@ public class DB {
return
credentials
;
}
public
static
void
getFromExistingTable
()
throws
Exception
{
// Step 1: Initialize BigQuery service
// Here we set our project ID and get the `BigQuery` service object
// this is the interface to our BigQuery instance that
// we use to execute jobs on
// Step 1: Initialize BigQuery service
// Here we set our project ID and get the `BigQuery` service object
// this is the interface to our BigQuery instance that
// we use to execute jobs on
private
static
BigQuery
getBuilder
()
throws
Exception
{
BigQuery
bigquery
=
BigQueryOptions
.
newBuilder
().
setCredentials
(
getCredentials
()).
setProjectId
(
"sf-drying-optimization"
)
.
build
().
getService
();
return
bigquery
;
}
public
static
void
getFromExistingTable
()
throws
Exception
{
// Step 2: Prepare query job
// A "QueryJob" is a type of job that executes SQL queries
...
...
@@ -50,7 +55,8 @@ public class DB {
// Step 3: Run the job on BigQuery
// create a `Job` instance from the job configuration using the BigQuery service
// the job starts executing once the `create` method executes
Job
queryJob
=
bigquery
.
create
(
JobInfo
.
newBuilder
(
queryConfig
).
build
());
Job
queryJob
=
getBuilder
().
create
(
JobInfo
.
newBuilder
(
queryConfig
).
build
());
queryJob
=
queryJob
.
waitFor
();
// the waitFor method blocks until the job completes
// and returns `null` if the job doesn't exist anymore
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/application/DB/Sort.java
0 → 100644
+
5
−
0
View file @
17b8327c
package
com.application.DB
;
public
class
Sort
{
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment