rx.functions.Func6 Java Examples

The following examples show how to use rx.functions.Func6. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RxUtils.java    From RxBinding with Apache License 2.0 6 votes vote down vote up
public static <T1, T2, T3, T4, T5, T6, R> Observable<R> toObservable(
    final Func6<T1, T2, T3, T4, T5, T6, R> func,
    final T1 arg1, final T2 arg2, final T3 arg3, final T4 arg4, final T5 arg5,
    final T6 arg6) {
  return Observable.create(new Observable.OnSubscribe<R>() {
    @Override
    public void call(Subscriber<? super R> subscriber) {
      try {
        final R result = func.call(
            arg1, arg2, arg3, arg4, arg5,
            arg6);
        onNextIfSubscribed(subscriber, result);
        onCompletedIfSubsribed(subscriber);
      } catch (Exception e) {
        onErrorIfSubscribed(subscriber, e);
      }
    }
  });
}
 
Example #2
Source File: MetricsServiceImpl.java    From hawkular-metrics with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> Func6<MetricId<T>, Long, Long, Integer, Order, Integer, Observable<Row>> getDataPointFinder(
        MetricType<T> metricType) {
    Func6<MetricId<T>, Long, Long, Integer, Order, Integer, Observable<Row>> finder;
    finder = (Func6<MetricId<T>, Long, Long, Integer, Order, Integer, Observable<Row>>) dataPointFinders
            .get(metricType);
    if (finder == null) {
        throw new UnsupportedOperationException(metricType.getText());
    }
    return finder;
}
 
Example #3
Source File: Observable.java    From letv with Apache License 2.0 4 votes vote down vote up
public static <T1, T2, T3, T4, T5, T6, R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> combineFunction) {
    return combineLatest(Arrays.asList(new Observable[]{o1, o2, o3, o4, o5, o6}), Functions.fromFunc(combineFunction));
}
 
Example #4
Source File: Observable.java    From letv with Apache License 2.0 4 votes vote down vote up
public static <T1, T2, T3, T4, T5, T6, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> zipFunction) {
    return just(new Observable[]{o1, o2, o3, o4, o5, o6}).lift(new OperatorZip(zipFunction));
}
 
Example #5
Source File: RxHelper.java    From sfs with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static final <T1, T2, T3, T4, T5, T6, R> Observable<R> combineSinglesDelayError(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6,
                                                                                       Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> combineFunction) {
    return combineSinglesDelayError(asList(o1.single(), o2.single(), o3.single(), o4.single(), o5.single(), o6.single()), fromFunc(combineFunction));
}
 
Example #6
Source File: MetricsServiceImpl.java    From hawkular-metrics with Apache License 2.0 4 votes vote down vote up
public void startUp(Session session, String keyspace, boolean resetDb, boolean createSchema,
        MetricRegistry metricRegistry) {
    session.execute("USE " + keyspace);
    log.infoKeyspaceUsed(keyspace);
    metricsTasks = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(4, new MetricsThreadFactory()));
    loadDataRetentions();

    this.metricRegistry = metricRegistry;

    pointsInserter = ImmutableMap
            .<MetricType<?>, Func1<Observable<? extends Metric<?>>, Observable<Integer>>>builder()
            .put(GAUGE, metric -> {
                @SuppressWarnings("unchecked")
                Observable<Metric<Double>> gauge = (Observable<Metric<Double>>) metric;
                return dataAccess.insertData(gauge);
            })
            .put(COUNTER, metric -> {
                @SuppressWarnings("unchecked")
                Observable<Metric<Long>> counter = (Observable<Metric<Long>>) metric;
                return dataAccess.insertData(counter);
            })
            .put(AVAILABILITY, metric -> {
                @SuppressWarnings("unchecked")
                Observable<Metric<AvailabilityType>> avail = (Observable<Metric<AvailabilityType>>) metric;
                return dataAccess.insertData(avail);
            })
            .put(STRING, metric -> {
                @SuppressWarnings("unchecked")
                Observable<Metric<String>> string = (Observable<Metric<String>>) metric;
                return dataAccess.insertStringDatas(string, this::getTTL, maxStringSize);
            })
            .build();

    dataPointFinders = ImmutableMap
            .<MetricType<?>, Func6<? extends MetricId<?>, Long, Long, Integer, Order, Integer,
                    Observable<Row>>>builder()
            .put(STRING, (metricId, start, end, limit, order, pageSize) -> {
                @SuppressWarnings("unchecked")
                MetricId<String> stringId = (MetricId<String>) metricId;
                return dataAccess.findStringData(stringId, start, end, limit, order, pageSize);
            })
            .build();

    dataPointMappers = ImmutableMap.<MetricType<?>, Func1<Row, ? extends DataPoint<?>>> builder()
            .put(GAUGE, Functions::getGaugeDataPoint)
            .put(AVAILABILITY, Functions::getAvailabilityDataPoint)
            .put(COUNTER, Functions::getCounterDataPoint)
            .put(STRING, Functions::getStringDataPoint)
            .build();

    tempDataPointMappers = ImmutableMap.<MetricType<?>, Func1<Row, ? extends DataPoint<?>>> builder()
            .put(GAUGE, Functions::getTempGaugeDataPoint)
            .put(COUNTER, Functions::getTempCounterDataPoint)
            .put(AVAILABILITY, Functions::getTempAvailabilityDataPoint)
            .build();

    initConfiguration(session);
    setDefaultTTL(session, keyspace);

    verifyAndCreateTempTables();

    int defaultPageSize = session.getCluster().getConfiguration().getQueryOptions().getFetchSize();
    int pageThreshold = Integer.getInteger("hawkular.metrics.page-threshold", 10);
    tagQueryParser = new SimpleTagQueryParser(this.dataAccess, this, disableACostOptimization, defaultPageSize,
            pageThreshold);
    expresssionTagQueryParser = new ExpressionTagQueryParser(this.dataAccess, this);
}
 
Example #7
Source File: MetricsServiceImpl.java    From hawkular-metrics with Apache License 2.0 4 votes vote down vote up
@Override
    public <T> Observable<DataPoint<T>> findDataPoints(MetricId<T> metricId, long start, long end, int limit,
                                                       Order order, int pageSize) {

        Timer.Context context = getRawDataReadLatency().time();
        checkArgument(isValidTimeRange(start, end), "Invalid time range");
        Order safeOrder = (null == order) ? Order.ASC : order;
        MetricType<T> metricType = metricId.getType();
        Func1<Row, DataPoint<T>> mapper = getDataPointMapper(metricType);

        if (metricType == GAUGE || metricType == AVAILABILITY || metricType == COUNTER) {
            long sliceStart = DateTimeService.getTimeSlice(start, Duration.standardHours(2));

            Func1<Row, DataPoint<T>> tempMapper = (Func1<Row, DataPoint<T>>) tempDataPointMappers.get(metricType);

            // Calls mostly deprecated methods..
//            Observable<DataPoint<T>> uncompressedPoints = dataAccess.findOldData(metricId, start, end, limit, safeOrder,
//                    pageSize).map(mapper).doOnError(Throwable::printStackTrace);

            Observable<DataPoint<T>> compressedPoints =
                    dataAccess.findCompressedData(metricId, sliceStart, end, limit, safeOrder)
                            .compose(new DataPointDecompressTransformer(metricType, safeOrder, limit, start, end));

            Observable<DataPoint<T>> tempStoragePoints = dataAccess.findTempData(metricId, start, end, limit,
                    safeOrder, pageSize)
                    .map(tempMapper);

            Comparator<DataPoint<T>> comparator = getDataPointComparator(safeOrder);
            List<Observable<? extends DataPoint<T>>> sources = new ArrayList<>(3);
//            sources.add(uncompressedPoints);
            sources.add(compressedPoints);
            sources.add(tempStoragePoints);

            Observable<DataPoint<T>> dataPoints = SortedMerge.create(sources, comparator, false)
                    .distinctUntilChanged(
                            (tDataPoint, tDataPoint2) -> comparator.compare(tDataPoint, tDataPoint2) == 0);

            if (limit > 0) {
                dataPoints = dataPoints.take(limit);
            }

            return dataPoints;
        }
        Func6<MetricId<T>, Long, Long, Integer, Order, Integer, Observable<Row>> finder =
                getDataPointFinder(metricType);

        Observable<DataPoint<T>> results =
                finder.call(metricId, start, end, limit, safeOrder, pageSize).map(mapper);
        return results.doOnCompleted(context::stop);
    }