Search in sources :

Example 46 with Pair

use of org.apache.commons.math3.util.Pair in project DataX by alibaba.

the class OtsWriterSlaveProxy method write.

public void write(RecordReceiver recordReceiver, TaskPluginCollector collector) throws Exception {
    LOG.info("Writer slave started.");
    WriterConfig writerConfig = new WriterConfig();
    writerConfig.setConcurrency(conf.getConcurrencyWrite());
    writerConfig.setMaxBatchRowsCount(conf.getBatchWriteCount());
    writerConfig.setMaxBatchSize(conf.getRestrictConf().getRequestTotalSizeLimition());
    writerConfig.setBufferSize(conf.getBufferSize());
    writerConfig.setMaxAttrColumnSize(conf.getRestrictConf().getAttributeColumnSize());
    writerConfig.setMaxColumnsCount(conf.getRestrictConf().getMaxColumnsCount());
    writerConfig.setMaxPKColumnSize(conf.getRestrictConf().getPrimaryKeyColumnSize());
    otsWriter = new DefaultOTSWriter(otsAsync, conf.getTableName(), writerConfig, new WriterCallback(collector), Executors.newFixedThreadPool(3));
    int expectColumnCount = conf.getPrimaryKeyColumn().size() + conf.getAttributeColumn().size();
    Record record;
    while ((record = recordReceiver.getFromReader()) != null) {
        LOG.debug("Record Raw: {}", record.toString());
        int columnCount = record.getColumnNumber();
        if (columnCount != expectColumnCount) {
            // 如果Column的个数和预期的个数不一致时,认为是系统故障或者用户配置Column错误,异常退出
            throw new IllegalArgumentException(String.format(OTSErrorMessage.RECORD_AND_COLUMN_SIZE_ERROR, columnCount, expectColumnCount));
        }
        // 类型转换
        try {
            RowPrimaryKey primaryKey = Common.getPKFromRecord(conf.getPrimaryKeyColumn(), record);
            List<Pair<String, ColumnValue>> attributes = Common.getAttrFromRecord(conf.getPrimaryKeyColumn().size(), conf.getAttributeColumn(), record);
            RowChange rowChange = Common.columnValuesToRowChange(conf.getTableName(), conf.getOperation(), primaryKey, attributes);
            WithRecord withRecord = (WithRecord) rowChange;
            withRecord.setRecord(record);
            otsWriter.addRowChange(rowChange);
        } catch (IllegalArgumentException e) {
            LOG.warn("Found dirty data.", e);
            collector.collectDirtyRecord(record, e.getMessage());
        } catch (ClientException e) {
            LOG.warn("Found dirty data.", e);
            collector.collectDirtyRecord(record, e.getMessage());
        }
    }
    otsWriter.close();
    LOG.info("Writer slave finished.");
}
Also used : Record(com.alibaba.datax.common.element.Record) WriterConfig(com.aliyun.openservices.ots.internal.writer.WriterConfig) Pair(org.apache.commons.math3.util.Pair)

Example 47 with Pair

use of org.apache.commons.math3.util.Pair in project DataX by alibaba.

the class Common method getAttrFromRecord.

public static List<Pair<String, ColumnValue>> getAttrFromRecord(int pkCount, List<OTSAttrColumn> attrColumns, Record r) {
    List<Pair<String, ColumnValue>> attr = new ArrayList<Pair<String, ColumnValue>>(r.getColumnNumber());
    for (int i = 0; i < attrColumns.size(); i++) {
        Column col = r.getColumn(i + pkCount);
        OTSAttrColumn expect = attrColumns.get(i);
        if (col.getRawData() == null) {
            attr.add(new Pair<String, ColumnValue>(expect.getName(), null));
            continue;
        }
        ColumnValue cv = ColumnConversion.columnToColumnValue(col, expect);
        attr.add(new Pair<String, ColumnValue>(expect.getName(), cv));
    }
    return attr;
}
Also used : Column(com.alibaba.datax.common.element.Column) ArrayList(java.util.ArrayList) ColumnValue(com.aliyun.openservices.ots.model.ColumnValue) Pair(org.apache.commons.math3.util.Pair)

Example 48 with Pair

use of org.apache.commons.math3.util.Pair in project android by owncloud.

the class FileDataStorageManager method getAvailableOfflineFilesFromEveryAccount.

/**
     * Get a collection with all the files set by the user as available offline, from all the accounts
     * in the device.
     *
     * This is the only method working with a NULL account in {@link #mAccount}. Not something to do often.
     *
     * @return      List with all the files set by the user as available offline.
     */
public List<Pair<OCFile, String>> getAvailableOfflineFilesFromEveryAccount() {
    List<Pair<OCFile, String>> result = new ArrayList<>();
    Cursor cursorOnKeptInSync = null;
    try {
        // query for any favorite file in any OC account
        cursorOnKeptInSync = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?", new String[] { String.valueOf(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE.getValue()) }, // do NOT get also AVAILABLE_OFFLINE_PARENT: only those SET BY THE USER (files or folders)
        null);
        if (cursorOnKeptInSync != null && cursorOnKeptInSync.moveToFirst()) {
            OCFile file;
            String accountName;
            do {
                file = createFileInstance(cursorOnKeptInSync);
                accountName = cursorOnKeptInSync.getString(cursorOnKeptInSync.getColumnIndex(ProviderTableMeta.FILE_ACCOUNT_OWNER));
                result.add(new Pair<>(file, accountName));
            } while (cursorOnKeptInSync.moveToNext());
        }
    } catch (Exception e) {
        Log_OC.e(TAG, "Exception retrieving all the available offline files", e);
    } finally {
        if (cursorOnKeptInSync != null) {
            cursorOnKeptInSync.close();
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException) IOException(java.io.IOException) OperationApplicationException(android.content.OperationApplicationException) Pair(android.support.v4.util.Pair)

Example 49 with Pair

use of org.apache.commons.math3.util.Pair in project android by owncloud.

the class FileObserverService method startObservation.

/**
     * Read from the local database the list of files that must to be kept
     * synchronized and starts observers to monitor local changes on them.
     * 
     * Updates the list of currently observed files if called multiple times.
     */
private void startObservation() {
    Log_OC.d(TAG, "Loading all available offline files from database to start watching them");
    FileDataStorageManager fds = new FileDataStorageManager(// this is dangerous - handle with care
    null, getContentResolver());
    List<Pair<OCFile, String>> availableOfflineFiles = fds.getAvailableOfflineFilesFromEveryAccount();
    OCFile file;
    String accountName;
    Account account;
    for (Pair<OCFile, String> pair : availableOfflineFiles) {
        file = pair.first;
        accountName = pair.second;
        account = new Account(accountName, MainApp.getAccountType());
        if (!AccountUtils.exists(account, this)) {
            continue;
        }
        addObservedFile(file, account);
    }
    // watch for instant uploads
    updateInstantUploadsObservers();
// service does not stopSelf() ; that way it tries to be alive forever
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Account(android.accounts.Account) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) Pair(android.support.v4.util.Pair)

Example 50 with Pair

use of org.apache.commons.math3.util.Pair in project GSYVideoPlayer by CarGuo.

the class JumpUtils method goToVideoPlayer.

/**
     * 跳转到视频播放
     *
     * @param activity
     * @param view
     */
public static void goToVideoPlayer(Activity activity, View view) {
    Intent intent = new Intent(activity, PlayActivity.class);
    intent.putExtra(PlayActivity.TRANSITION, true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION);
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pair);
        ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
    }
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Aggregations

Pair (android.support.v4.util.Pair)38 ArrayList (java.util.ArrayList)22 View (android.view.View)16 Collectors (java.util.stream.Collectors)16 IntStream (java.util.stream.IntStream)16 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)13 Logger (org.apache.logging.log4j.Logger)12 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)12 Intent (android.content.Intent)11 Pair (org.apache.commons.math3.util.Pair)11 IOException (java.io.IOException)10 java.util (java.util)10 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)10 Pair (org.apache.commons.lang3.tuple.Pair)10 RealMatrix (org.apache.commons.math3.linear.RealMatrix)10 File (java.io.File)9 List (java.util.List)9 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)8 UserException (org.broadinstitute.hellbender.exceptions.UserException)8 org.broadinstitute.hellbender.tools.exome (org.broadinstitute.hellbender.tools.exome)8