<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.camel.processor.resume;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.apache.camel.resume.Cacheable;
import org.apache.camel.resume.Offset;
import org.apache.camel.resume.OffsetKey;
import org.apache.camel.resume.Resumable;
import org.apache.camel.resume.ResumeAdapter;
import org.apache.camel.resume.ResumeStrategy;
import org.apache.camel.resume.ResumeStrategyConfiguration;
import org.apache.camel.resume.ResumeStrategyConfigurationBuilder;
import org.apache.camel.resume.cache.ResumeCache;
import org.apache.camel.spi.annotations.JdkService;

/**
 * A resume strategy that keeps all the resume strategy information in memory. This is hardly useful for production
 * level implementations, but can be useful for testing the resume strategies
 */
@JdkService("transient-resume-strategy")
public class TransientResumeStrategy implements ResumeStrategy {
    private final ResumeAdapter resumeAdapter;

    public TransientResumeStrategy(ResumeAdapter resumeAdapter) {
        this.resumeAdapter = resumeAdapter;
    }

    @Override
    public void setAdapter(ResumeAdapter adapter) {
        // this is NO-OP
    }

    @Override
    public ResumeAdapter getAdapter() {
        return resumeAdapter;
    }

    @Override
    public <T extends ResumeAdapter> T getAdapter(Class<T> clazz) {
        return ResumeStrategy.super.getAdapter(clazz);
    }

    @Override
    public <T extends Resumable> void updateLastOffset(T offset) {
        // this is NO-OP
    }

    @Override
    public <T extends Resumable> void updateLastOffset(T offset, UpdateCallBack updateCallBack) throws Exception {
        // this is NO-OP
    }

    @Override
    public void updateLastOffset(OffsetKey<?> offsetKey, Offset<?> offset, UpdateCallBack updateCallBack) throws Exception {
        // this is NO-OP
    }

    @Override
    public void setResumeStrategyConfiguration(ResumeStrategyConfiguration resumeStrategyConfiguration) {
        // This is NO-OP
    }

    @Override
    public ResumeStrategyConfiguration getResumeStrategyConfiguration() {
        return configurationBuilder().build();
    }

    @Override
    public void updateLastOffset(OffsetKey<?> offsetKey, Offset<?> offset) {
        // this is NO-OP
    }

    @Override
    public void start() {
        // this is NO-OP
    }

    @Override
    public void stop() {
        // this is NO-OP
    }

    public static ResumeStrategyConfigurationBuilder<ResumeStrategyConfigurationBuilder, ResumeStrategyConfiguration> configurationBuilder() {
        return new ResumeStrategyConfigurationBuilder<>() {
            @Override
            public ResumeStrategyConfigurationBuilder withCacheFillPolicy(Cacheable.FillPolicy cacheFillPolicy) {
                return this;
            }

            @Override
            public ResumeStrategyConfigurationBuilder withResumeCache(ResumeCache<?> resumeCache) {
                return this;
            }

            @Override
            public ResumeStrategyConfiguration build() {
                return new ResumeStrategyConfiguration() {

                    @Override
                    public ResumeCache<?> getResumeCache() {
                        return new ResumeCache<>() {
                            private Map<Object, Object> cache = new HashMap<>();

                            @Override
                            public Object computeIfAbsent(Object key, Function<? super Object, ? super Object> mapping) {
                                return cache.computeIfAbsent(key, mapping);
                            }

                            @Override
                            public Object computeIfPresent(Object key, BiFunction<? super Object, ? super Object, ? super Object> remapping) {
                                return cache.computeIfPresent(key, remapping);
                            }

                            @Override
                            public boolean contains(Object key, Object entry) {
                                return Objects.equals(cache.get(key), entry);
                            }

                            @Override
                            public void add(Object key, Object offsetValue) {<commit_msg>Regen for commit 4ce3e5ad95946f21725628d0fae133ea8f57f44a<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.camel.processor.resume;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.apache.camel.resume.Cacheable;
import org.apache.camel.resume.Offset;
import org.apache.camel.resume.OffsetKey;
import org.apache.camel.resume.Resumable;
import org.apache.camel.resume.ResumeAdapter;
import org.apache.camel.resume.ResumeStrategy;
import org.apache.camel.resume.ResumeStrategyConfiguration;
import org.apache.camel.resume.ResumeStrategyConfigurationBuilder;
import org.apache.camel.resume.cache.ResumeCache;
import org.apache.camel.spi.annotations.JdkService;

/**
 * A resume strategy that keeps all the resume strategy information in memory. This is hardly useful for production
 * level implementations, but can be useful for testing the resume strategies
 */
@JdkService("transient-resume-strategy")
public class TransientResumeStrategy implements ResumeStrategy {
    private final ResumeAdapter resumeAdapter;

    public TransientResumeStrategy(ResumeAdapter resumeAdapter) {
        this.resumeAdapter = resumeAdapter;
    }

    @Override
    public void setAdapter(ResumeAdapter adapter) {
        // this is NO-OP
    }

    @Override
    public ResumeAdapter getAdapter() {
        return resumeAdapter;
    }

    @Override
    public <T extends ResumeAdapter> T getAdapter(Class<T> clazz) {
        return ResumeStrategy.super.getAdapter(clazz);
    }

    @Override
    public <T extends Resumable> void updateLastOffset(T offset) {
        // this is NO-OP
    }

    @Override
    public <T extends Resumable> void updateLastOffset(T offset, UpdateCallBack updateCallBack) throws Exception {
        // this is NO-OP
    }

    @Override
    public void updateLastOffset(OffsetKey<?> offsetKey, Offset<?> offset, UpdateCallBack updateCallBack) throws Exception {
        // this is NO-OP
    }

    @Override
    public void setResumeStrategyConfiguration(ResumeStrategyConfiguration resumeStrategyConfiguration) {
        // This is NO-OP
    }

    @Override
    public ResumeStrategyConfiguration getResumeStrategyConfiguration() {
        return configurationBuilder().build();
    }

    @Override
    public void updateLastOffset(OffsetKey<?> offsetKey, Offset<?> offset) {
        // this is NO-OP
    }

    @Override
    public void start() {
        // this is NO-OP
    }

    @Override
    public void stop() {
        // this is NO-OP
    }

    public static ResumeStrategyConfigurationBuilder<ResumeStrategyConfigurationBuilder, ResumeStrategyConfiguration> configurationBuilder() {
        return new ResumeStrategyConfigurationBuilder<>() {
            @Override
            public ResumeStrategyConfigurationBuilder withCacheFillPolicy(Cacheable.FillPolicy cacheFillPolicy) {
                return this;
            }

            @Override
            public ResumeStrategyConfigurationBuilder withResumeCache(ResumeCache<?> resumeCache) {
                return this;
            }

            @Override
            public ResumeStrategyConfiguration build() {
                return new ResumeStrategyConfiguration() {

                    @Override
                    public ResumeCache<?> getResumeCache() {
                        return new ResumeCache<>() {
                            private Map<Object, Object> cache = new HashMap<>();

                            @Override
                            public Object computeIfAbsent(Object key, Function<? super Object, ? super Object> mapping) {
                                return cache.computeIfAbsent(key, mapping);
                            }

                            @Override
                            public Object computeIfPresent(
                                    Object key, BiFunction<? super Object, ? super Object, ? super Object> remapping) {
                                return cache.computeIfPresent(key, remapping);
                            }

                            @Override
                            public boolean contains(Object key, Object entry) {
                                return Objects.equals(cache.get(key), entry);
                            }

                            @Override
                            public void add(Object key, Object offsetValue) {
{'fraction_non_alphanumeric': 0.07165620473201352, 'fraction_numerical': 0.0031868662481892803, 'mean_word_length': 2.39207337045529, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3529015', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2462, 'n_words': 764}