Search in sources :

Example 6 with VisibleForTesting

use of org.assertj.core.util.VisibleForTesting in project assertj-core by assertj.

the class AbstractDateAssert method parse.

/**
 * Thread safe utility method to parse a Date with {@link #userDateFormats} first, then {@link #DEFAULT_DATE_FORMATS}.
 * <p>
 * Returns <code>null</code> if dateAsString parameter is <code>null</code>.
 *
 * @param dateAsString the string to parse as a Date with {@link #userDateFormats}
 * @return the corresponding Date, null if dateAsString parameter is null.
 * @throws AssertionError if the string can't be parsed as a Date
 */
@VisibleForTesting
Date parse(String dateAsString) {
    if (dateAsString == null)
        return null;
    // parse with date format specified by user if any, otherwise use default formats
    // no synchronization needed as userCustomDateFormat is thread local
    Date date = parseDateWith(dateAsString, userDateFormats.get());
    if (date != null)
        return date;
    // no matching user date format, let's try default format
    date = parseDateWithDefaultDateFormats(dateAsString);
    if (date != null)
        return date;
    // no matching date format, throw an error
    throw new AssertionError(String.format("Failed to parse %s with any of these date formats:%n   %s", dateAsString, info.representation().toStringOf(dateFormatsInOrderOfUsage())));
}
Also used : Date(java.util.Date) VisibleForTesting(org.assertj.core.util.VisibleForTesting)

Example 7 with VisibleForTesting

use of org.assertj.core.util.VisibleForTesting in project cassandra by apache.

the class RangeCommands method rangeCommandIterator.

@VisibleForTesting
// created iterators will be closed in CQL layer through the chain of transformations
@SuppressWarnings("resource")
static RangeCommandIterator rangeCommandIterator(PartitionRangeReadCommand command, ConsistencyLevel consistencyLevel, long queryStartNanoTime) {
    Tracing.trace("Computing ranges to query");
    Keyspace keyspace = Keyspace.open(command.metadata().keyspace);
    ReplicaPlanIterator replicaPlans = new ReplicaPlanIterator(command.dataRange().keyRange(), keyspace, consistencyLevel);
    // our estimate of how many result rows there will be per-range
    float resultsPerRange = estimateResultsPerRange(command, keyspace);
    // underestimate how many rows we will get per-range in order to increase the likelihood that we'll
    // fetch enough rows in the first round
    resultsPerRange -= resultsPerRange * CONCURRENT_SUBREQUESTS_MARGIN;
    int maxConcurrencyFactor = Math.min(replicaPlans.size(), MAX_CONCURRENT_RANGE_REQUESTS);
    int concurrencyFactor = resultsPerRange == 0.0 ? 1 : Math.max(1, Math.min(maxConcurrencyFactor, (int) Math.ceil(command.limits().count() / resultsPerRange)));
    logger.trace("Estimated result rows per range: {}; requested rows: {}, ranges.size(): {}; concurrent range requests: {}", resultsPerRange, command.limits().count(), replicaPlans.size(), concurrencyFactor);
    Tracing.trace("Submitting range requests on {} ranges with a concurrency of {} ({} rows per range expected)", replicaPlans.size(), concurrencyFactor, resultsPerRange);
    ReplicaPlanMerger mergedReplicaPlans = new ReplicaPlanMerger(replicaPlans, keyspace, consistencyLevel);
    return new RangeCommandIterator(mergedReplicaPlans, command, concurrencyFactor, maxConcurrencyFactor, replicaPlans.size(), queryStartNanoTime);
}
Also used : Keyspace(org.apache.cassandra.db.Keyspace) VisibleForTesting(org.assertj.core.util.VisibleForTesting)

Aggregations

VisibleForTesting (org.assertj.core.util.VisibleForTesting)7 Date (java.util.Date)2 ImmutableList (com.google.common.collect.ImmutableList)1 Futures.immediateFuture (com.google.common.util.concurrent.Futures.immediateFuture)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 FDate (de.invesdwin.util.time.date.FDate)1 CubeAggregateFunction (io.hetu.core.spi.cube.CubeAggregateFunction)1 CubeFilter (io.hetu.core.spi.cube.CubeFilter)1 CubeMetadataBuilder (io.hetu.core.spi.cube.CubeMetadataBuilder)1 CubeStatus (io.hetu.core.spi.cube.CubeStatus)1 AggregationSignature (io.hetu.core.spi.cube.aggregator.AggregationSignature)1 CubeMetaStore (io.hetu.core.spi.cube.io.CubeMetaStore)1 Session (io.prestosql.Session)1 CubeManager (io.prestosql.cube.CubeManager)1 STAR_TREE (io.prestosql.cube.CubeManager.STAR_TREE)1 WarningCollector (io.prestosql.execution.warnings.WarningCollector)1 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)1 Metadata (io.prestosql.metadata.Metadata)1 MetadataUtil.createQualifiedObjectName (io.prestosql.metadata.MetadataUtil.createQualifiedObjectName)1 TableMetadata (io.prestosql.metadata.TableMetadata)1