Search in sources :

Example 21 with IntStream

use of java.util.stream.IntStream in project systemml by apache.

the class DenseBlockLDRB method reset.

@SuppressWarnings("resource")
private void reset(int rlen, int clen, int blen, double v) {
    long llen = (long) rlen * clen;
    int numPart = (int) Math.ceil((double) rlen / blen);
    if (this.blen == blen && llen < capacity()) {
        for (int i = 0; i < numPart; i++) {
            int lrlen = (int) (Math.min((i + 1) * blen, rlen) - i * blen);
            Arrays.fill(data[i], 0, lrlen * clen, v);
        }
    } else {
        data = new double[numPart][];
        IntStream range = PARALLEL_ALLOC ? IntStream.range(0, numPart).parallel() : IntStream.range(0, numPart);
        range.forEach(i -> data[i] = allocArray(i, rlen, clen, blen, v));
    }
    this.rlen = rlen;
    this.clen = clen;
    this.blen = blen;
}
Also used : IntStream(java.util.stream.IntStream)

Example 22 with IntStream

use of java.util.stream.IntStream in project junit5 by junit-team.

the class CollectionUtilsTests method toStreamWithIntStream.

@SuppressWarnings("unchecked")
@Test
void toStreamWithIntStream() {
    IntStream input = IntStream.of(23, 42);
    Stream<Integer> result = (Stream<Integer>) CollectionUtils.toStream(input);
    assertThat(result).containsExactly(23, 42);
}
Also used : IntStream(java.util.stream.IntStream) LongStream(java.util.stream.LongStream) DoubleStream(java.util.stream.DoubleStream) Stream(java.util.stream.Stream) IntStream(java.util.stream.IntStream) Test(org.junit.jupiter.api.Test) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 23 with IntStream

use of java.util.stream.IntStream in project data-prep by Talend.

the class PreparationService method extractActionsAfterStep.

/**
 * Extract all actions after a provided step
 *
 * @param stepsIds The steps list
 * @param afterStep The (excluded) step id where to start the extraction
 * @return The actions after 'afterStep' to the end of the list
 */
private List<AppendStep> extractActionsAfterStep(final List<String> stepsIds, final String afterStep) {
    final int stepIndex = stepsIds.indexOf(afterStep);
    if (stepIndex == -1) {
        return emptyList();
    }
    final List<Step> steps;
    try (IntStream range = IntStream.range(stepIndex, stepsIds.size())) {
        steps = range.mapToObj(index -> getStep(stepsIds.get(index))).collect(toList());
    }
    final List<List<Action>> stepActions = steps.stream().map(this::getActions).collect(toList());
    try (IntStream filteredActions = IntStream.range(1, steps.size())) {
        return filteredActions.mapToObj(index -> {
            final List<Action> previous = stepActions.get(index - 1);
            final List<Action> current = stepActions.get(index);
            final Step step = steps.get(index);
            final AppendStep appendStep = new AppendStep();
            appendStep.setDiff(step.getDiff());
            appendStep.setActions(current.subList(previous.size(), current.size()));
            return appendStep;
        }).collect(toList());
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) PREPARATION(org.talend.dataprep.api.folder.FolderContentType.PREPARATION) ActionFactory(org.talend.dataprep.transformation.actions.common.ActionFactory) MAX_VALUE(java.lang.Integer.MAX_VALUE) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) PreparationRepository(org.talend.dataprep.preparation.store.PreparationRepository) LockedResourceRepository(org.talend.dataprep.lock.store.LockedResourceRepository) BeanConversionService(org.talend.dataprep.conversions.BeanConversionService) DataprepBundle.message(org.talend.dataprep.i18n.DataprepBundle.message) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) ConstraintViolation(javax.validation.ConstraintViolation) Collectors.toSet(java.util.stream.Collectors.toSet) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) Validator(javax.validation.Validator) PreparationErrorCodes(org.talend.dataprep.exception.error.PreparationErrorCodes) Collectors(java.util.stream.Collectors) Stream(java.util.stream.Stream) SortAndOrderHelper.getPreparationComparator(org.talend.dataprep.util.SortAndOrderHelper.getPreparationComparator) Pattern(java.util.regex.Pattern) ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) Security(org.talend.dataprep.security.Security) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) RunnableAction(org.talend.dataprep.transformation.actions.common.RunnableAction) IntStream(java.util.stream.IntStream) ImplicitParameters(org.talend.dataprep.transformation.actions.common.ImplicitParameters) java.util(java.util) TDPException(org.talend.dataprep.exception.TDPException) TqlBuilder(org.talend.tql.api.TqlBuilder) JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription) org.talend.dataprep.api.preparation(org.talend.dataprep.api.preparation) Expression(org.talend.tql.model.Expression) Function(java.util.function.Function) FolderEntry(org.talend.dataprep.api.folder.FolderEntry) ExceptionContext.build(org.talend.daikon.exception.ExceptionContext.build) ExceptionContext(org.talend.daikon.exception.ExceptionContext) Folder(org.talend.dataprep.api.folder.Folder) Service(org.springframework.stereotype.Service) VersionService(org.talend.dataprep.api.service.info.VersionService) FolderRepository(org.talend.dataprep.folder.store.FolderRepository) Logger(org.slf4j.Logger) ActionRegistry(org.talend.dataprep.transformation.pipeline.ActionRegistry) DecimalFormat(java.text.DecimalFormat) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) PreparationSearchCriterion.filterPreparation(org.talend.dataprep.preparation.service.PreparationSearchCriterion.filterPreparation) Collectors.toList(java.util.stream.Collectors.toList) ActionMetadataValidation(org.talend.dataprep.transformation.api.action.validation.ActionMetadataValidation) Lookup(org.talend.dataprep.transformation.actions.datablending.Lookup) DataSetGetMetadata(org.talend.dataprep.command.dataset.DataSetGetMetadata) PATH_SEPARATOR(org.talend.dataprep.folder.store.FoldersRepositoriesConstants.PATH_SEPARATOR) Collections.emptyList(java.util.Collections.emptyList) Collectors.toList(java.util.stream.Collectors.toList) IntStream(java.util.stream.IntStream)

Example 24 with IntStream

use of java.util.stream.IntStream in project RoaringBitmap by RoaringBitmap.

the class RandomisedTestData method randomBitmap.

public static RoaringBitmap randomBitmap(int maxKeys) {
    int[] keys = createSorted16BitInts(ThreadLocalRandom.current().nextInt(1, maxKeys));
    double rleLimit = ThreadLocalRandom.current().nextDouble();
    double denseLimit = ThreadLocalRandom.current().nextDouble(rleLimit, 1D);
    OrderedWriter writer = new OrderedWriter();
    IntStream.of(keys).forEach(key -> {
        double choice = ThreadLocalRandom.current().nextDouble();
        final IntStream stream;
        if (choice < rleLimit) {
            stream = rleRegion();
        } else if (choice < denseLimit) {
            stream = denseRegion();
        } else {
            stream = sparseRegion();
        }
        stream.map(i -> (key << 16) | i).forEach(writer::add);
    });
    writer.flush();
    return writer.getUnderlying();
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) List(java.util.List) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ArrayList(java.util.ArrayList) IntStream(java.util.stream.IntStream)

Example 25 with IntStream

use of java.util.stream.IntStream in project RecordManager2 by moravianlibrary.

the class PublishDateMarcFunctions method range.

private List<Integer> range(int from, int to) {
    IntStream stream = IntStream.rangeClosed(from, to);
    List<Integer> result = new ArrayList<Integer>();
    for (int year : stream.toArray()) {
        result.add(year);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) IntStream(java.util.stream.IntStream)

Aggregations

IntStream (java.util.stream.IntStream)80 Test (org.junit.Test)20 List (java.util.List)15 ArrayList (java.util.ArrayList)13 Arrays (java.util.Arrays)10 Stream (java.util.stream.Stream)9 Random (java.util.Random)7 Collectors (java.util.stream.Collectors)7 Map (java.util.Map)5 Pattern (java.util.regex.Pattern)5 DoubleStream (java.util.stream.DoubleStream)5 LongStream (java.util.stream.LongStream)5 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)5 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)5 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)5 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)5 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)5 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)5 Assert (org.junit.Assert)4 Test (org.junit.jupiter.api.Test)4