Returns a BigQuery Load Job Configuration for the given destination table, format and source
URI.
772539
public static LoadJobConfiguration of(
      TableId destinationTable, String sourceUri, FormatOptions format) {
    return of(destinationTable, ImmutableList.of(sourceUri), format);
  }
1284769
def _prepare_source(selector, source):
    """"""
    tablename, fields = get_data_specifier(selector)
    if len(fields) != 1:
        raise ItsdbError(
            'Selector must specify exactly one data column: {}'
            .format(selector)
        )
    if isinstance(source, TestSuite):
        if not tablename:
            tablename = source.relations.find(fields[0])[0]
        source = source[tablename]
    cols = list(source.fields.keys()) + fields
    return source, cols
86759
@SuppressWarnings("unchecked")
  private static <E> Dataset<E> loadOrCreateJobDataset(JobContext jobContext) {
    Dataset<Object> dataset = load(jobContext).getDataset();
    String jobDatasetName = getJobDatasetName(jobContext);
    DatasetRepository repo = getDatasetRepository(jobContext);
    if (repo.exists(TEMP_NAMESPACE, jobDatasetName)) {
      Dataset<E> tempDataset = repo.load(TEMP_NAMESPACE, jobDatasetName,
        DatasetKeyOutputFormat.<E>getType(jobContext));
      try {
        Compatibility.checkCompatible(dataset.getDescriptor(),
          tempDataset.getDescriptor());
        return tempDataset;
      } catch (RuntimeException ex) {
        // swallow
      }
    }

    return repo.create(TEMP_NAMESPACE, jobDatasetName,
        copy(dataset.getDescriptor()),
        DatasetKeyOutputFormat.<E>getType(jobContext));
  }
233994
def get_load(jid):
    '''
    
    '''
    with _get_serv(ret=None, commit=True) as cur:

        sql = '''SELECT `load` FROM `jids` WHERE `jid` = %s;'''
        cur.execute(sql, (jid,))
        data = cur.fetchone()
        if data:
            return salt.utils.json.loads(data[0])
        return {}
548097
def load(self):
        
        if not self.ns.info_hash and not self.parse():
            return

        self.addinfo()

        # TODO: dry_run
        try:
            # TODO: Scrub metafile if requested

            # Determine target state
            start_it = self.job.config.load_mode.lower() in ("start", "started")
            queue_it = self.job.config.queued

            if "start" in self.ns.flags:
                start_it = True
            elif "load" in self.ns.flags:
                start_it = False

            if "queue" in self.ns.flags:
                queue_it = True

            # Load metafile into client
            load_cmd = self.job.proxy.load.verbose
            if queue_it:
                if not start_it:
                    self.ns.commands.append("d.priority.set=0")
            elif start_it:
                load_cmd = self.job.proxy.load.start_verbose

            self.job.LOG.debug("Templating values are:\n    %s" % "\n    ".join("%s=%s" % (key, repr(val))
                for key, val in sorted(self.ns.items())
            ))

            load_cmd(xmlrpc.NOHASH, self.ns.pathname, *tuple(self.ns.commands))
            time.sleep(.05) # let things settle

            # Announce new item
            if not self.job.config.quiet:
                msg = "%s: Loaded '%s' from '%s/'%s%s" % (
                    self.job.__class__.__name__,
                    fmt.to_utf8(self.job.proxy.d.name(self.ns.info_hash, fail_silently=True)),
                    os.path.dirname(self.ns.pathname).rstrip(os.sep),
                    " [queued]" if queue_it else "",
                    (" [startable]"  if queue_it else " [started]") if start_it else " [normal]",
                )
                self.job.proxy.log(xmlrpc.NOHASH, msg)

            # TODO: Evaluate fields and set client values
            # TODO: Add metadata to tied file if requested

            # TODO: Execute commands AFTER adding the item, with full templating
            # Example: Labeling - add items to a persistent view, i.e. "postcmd = view.set_visible={{label}}"
            #   could also be done automatically from the path, see above under "flags" (autolabel = True)
            #   and add traits to the flags, too, in that case

        except xmlrpc.ERRORS as exc:
            self.job.LOG.error("While loading #%s: %s" % (self.ns.info_hash, exc))
233086
protected Bigquery getBigQuery(Configuration config)
      throws GeneralSecurityException, IOException {
    BigQueryFactory factory = new BigQueryFactory();
    return factory.getBigQuery(config);
  }
279649
public MigrationJob[] retrieveJobs(int batchSize, int startIndex, JobType jobType)
            throws IOException, LightblueException {
        LOGGER.debug("Retrieving jobs: batchSize={}, startIndex={}", batchSize, startIndex);

        DataFindRequest findRequest = new DataFindRequest("migrationJob", null);

        List<Query> conditions = new ArrayList<>(Arrays.asList(new Query[] {
                // get jobs for this configuration
                Query.withValue("configurationName", Query.eq, migrationConfiguration.getConfigurationName()),
                // get jobs whose state ara available
                Query.withValue("status", Query.eq, "available"),
                // only get jobs that are
                Query.withValue("scheduledDate", Query.lte, new Date())
        }));

        if (jobType == JobType.GENERATED) {
            LOGGER.debug("Looking for generated job");
            conditions.add(Query.withValue("generated", Query.eq, true));
        } else if (jobType == JobType.NONGENERATED) {
            LOGGER.debug("Looking for non generated job");
            conditions.add(Query.withValue("generated", Query.eq, false));
        }

        findRequest.where(Query.and(conditions));

        findRequest.select(Projection.includeField("*"));

        findRequest.range(startIndex, startIndex + batchSize - 1);

        LOGGER.debug("Finding Jobs to execute: {}", findRequest.getBody());

        return lbClient.data(findRequest, MigrationJob[].class);
    }
861964
def atlasdb_load_peer_table( con=None, path=None ):
    
    peer_table = {}
    
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT * FROM peers;"
        args = ()

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        # build it up 
        count = 0
        for row in res:
           if count > 0 and count % 100 == 0:
               log.debug("Loaded %s peers..." % count)

           atlas_init_peer_info( peer_table, row['peer_hostport'] )
           count += 1

    return peer_table
1149076
function(options) {
        var params = {
          skip: this._skip,
          limit: this._limit,
        };

        return request({
          path: `/bigquery/jobs/${this.id}`,
          method: 'GET',
          query: params,
          authOptions: options,
          signKey: false,
        }).then(function(response) {
          if (response.error) {
            return Promise.reject(new AVError(response.code, response.error));
          }
          return Promise.resolve(response);
        });
      }
1352381
private InputColumn<?> findOrderByColumn(final AnalysisJobBuilder jobBuilder) {
        final Table sourceTable = jobBuilder.getSourceTables().get(0);

        // preferred strategy: Use the primary key
        final List<Column> primaryKeys = sourceTable.getPrimaryKeys();
        if (primaryKeys.size() == 1) {
            final Column primaryKey = primaryKeys.get(0);
            final InputColumn<?> sourceColumn = jobBuilder.getSourceColumnByName(primaryKey.getName());
            if (sourceColumn == null) {
                jobBuilder.addSourceColumn(primaryKey);
                logger.info("Added PK source column for ORDER BY clause on slave jobs: {}", sourceColumn);
                return jobBuilder.getSourceColumnByName(primaryKey.getName());
            } else {
                logger.info("Using existing PK source column for ORDER BY clause on slave jobs: {}", sourceColumn);
                return sourceColumn;
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Found {} primary keys, cannot select a single for ORDER BY clause on slave jobs: {}",
                        primaryKeys.size(), primaryKeys.size());
            }
        }

        // secondary strategy: See if there's a source column called something
        // like 'ID' or so, and use that.
        final List<MetaModelInputColumn> sourceColumns = jobBuilder.getSourceColumns();
        final String tableName = sourceTable.getName().toLowerCase();
        for (final MetaModelInputColumn sourceColumn : sourceColumns) {
            String name = sourceColumn.getName();
            if (name != null) {
                name = StringUtils.replaceWhitespaces(name, "");
                name = StringUtils.replaceAll(name, "_", "");
                name = StringUtils.replaceAll(name, "-", "");
                name = name.toLowerCase();
                if ("id".equals(name) || (tableName + "id").equals(name) || (tableName + "number").equals(name) || (
                        tableName + "key").equals(name)) {
                    logger.info("Using existing source column for ORDER BY clause on slave jobs: {}", sourceColumn);
                    return sourceColumn;
                }
            }
        }

        // last resort: Pick any source column and sort on that (might not work
        // if the column contains a lot of repeated values)
        final MetaModelInputColumn sourceColumn = sourceColumns.get(0);
        logger.warn(
                "Couldn't pick a good source column for ORDER BY clause on slave jobs. Picking the first column: {}",
                sourceColumn);
        return sourceColumn;
    }
1281490
def get_load(jid):
    '''
    
    '''
    log.debug('sdstack_etcd returner <get_load> called jid: %s', jid)
    read_profile = __opts__.get('etcd.returner_read_profile')
    client, path = _get_conn(__opts__, read_profile)
    return salt.utils.json.loads(client.get('/'.join((path, 'jobs', jid, '.load.p'))).value)
845468
public Job createJob(String query) {
    // [START ]
    Job job = null;
    JobConfiguration jobConfiguration = QueryJobConfiguration.of(query);
    JobInfo jobInfo = JobInfo.of(jobConfiguration);
    try {
      job = bigquery.create(jobInfo);
    } catch (BigQueryException e) {
      // the job was not created
    }
    // [END ]
    return job;
  }
383270
public ListenableFuture<Map<JobId, Job>> jobs(@Nullable final String jobQuery,
                                                @Nullable final String hostNamePattern) {
    final Map<String, String> params = new HashMap<>();
    if (!Strings.isNullOrEmpty(jobQuery)) {
      params.put("q", jobQuery);
    }
    if (!Strings.isNullOrEmpty(hostNamePattern)) {
      params.put("hostPattern", hostNamePattern);
    }
    return get(uri("/jobs", params), jobIdMap);
  }
1122393
public Job copyTableId(String dataset, String tableName) throws BigQueryException {
    // [START bigquery_copy_table]
    TableId destinationId = TableId.of(dataset, tableName);
    JobOption options = JobOption.fields(JobField.STATUS, JobField.USER_EMAIL);
    Job job = table.copy(destinationId, options);
    // Wait for the job to complete.
    try {
      Job completedJob =
          job.waitFor(
              RetryOption.initialRetryDelay(Duration.ofSeconds(1)),
              RetryOption.totalTimeout(Duration.ofMinutes(3)));
      if (completedJob != null && completedJob.getStatus().getError() == null) {
        // Job completed successfully.
      } else {
        // Handle error case.
      }
    } catch (InterruptedException e) {
      // Handle interrupted wait
    }
    // [END bigquery_copy_table]
    return job;
  }
783539
public static Builder newBuilder(TableId destinationTable, FormatOptions format) {
    return newBuilder(destinationTable).setFormatOptions(format);
  }
624708
public static LoadJobConfiguration of(TableId destinationTable, List<String> sourceUris) {
    return newBuilder(destinationTable, sourceUris).build();
  }
530437
def returner(load):
    '''
    
    '''
    conn = _get_conn()
    if conn is None:
        return None
    cur = conn.cursor()
    sql = '''INSERT INTO salt_returns
            (fun, jid, return, id, success)
            VALUES (%s, %s, %s, %s, %s)'''
    try:
        ret = six.text_type(load['return'])
    except UnicodeDecodeError:
        ret = str(load['return'])
    job_ret = {'return': ret}
    if 'retcode' in load:
        job_ret['retcode'] = load['retcode']
    if 'success' in load:
        job_ret['success'] = load['success']
    cur.execute(
        sql, (
            load['fun'],
            load['jid'],
            salt.utils.json.dumps(job_ret),
            load['id'],
            load.get('success'),
        )
    )
    _close_conn(conn)