<commit_before>/*
 *   Blumoon Technologies Corp.
 *   Copyright 2013.
 */
package com.blumoon.springmvcredis.service;

import com.blumoon.springmvcredis.keys.SetKeys;
import com.blumoon.springmvcredis.keys.StringKeys;
import com.blumoon.springmvcredis.util.KeysUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 *
 * @author <NAME>. <<EMAIL>>
 */
@Service
public class SampleService {

    private static final Log LOG = LogFactory.getLog(SampleService.class);
    @Autowired
    private StringRedisTemplate template;

    public Object sample(String sample) {

        KeysUtil keysUtil = new KeysUtil();

        // generate id
        String sampleId = keysUtil.generateUUID();

        // check from set if id exists
        if (template.opsForSet().isMember(SetKeys.SAMPLE, sampleId)) {
            // regenerate id
            sampleId = keysUtil.generateUUID();
        }

        // add id to set and check if added
        if (1 == template.opsForSet().add(SetKeys.SAMPLE, sampleId)) {

            // set next object if id was added
            boolean result = template.opsForValue().setIfAbsent(StringKeys.SAMPLE.concat(KeysUtil.DELIMITER).concat(sampleId), sample);

            LOG.debug(new StringBuilder("SampleId: ")
                    .append(sample)
                    .append(result));
        }

        return sampleId;<commit_msg>update sampleservice to use key.build<commit_after>/*
 *   Blumoon Technologies Corp.
 *   Copyright 2013.
 */
package com.blumoon.springmvcredis.service;

import com.blumoon.springmvcredis.keys.SetKeys;
import com.blumoon.springmvcredis.keys.StringKeys;
import com.blumoon.springmvcredis.util.KeysUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 *
 * @author <NAME>. <<EMAIL>>
 */
@Service
public class SampleService {

    private static final Log LOG = LogFactory.getLog(SampleService.class);
    @Autowired
    private StringRedisTemplate template;

    public Object sample(String sample) {

        KeysUtil keysUtil = new KeysUtil();

        // generate id
        String sampleId = keysUtil.generateUUID();

        // check from set if id exists
        if (template.opsForSet().isMember(SetKeys.SAMPLE, sampleId)) {
            // regenerate id
            sampleId = keysUtil.generateUUID();
        }

        // add id to set and check if added
        if (1 == template.opsForSet().add(SetKeys.SAMPLE, sampleId)) {

            // set next object if id was added
            boolean result = template.opsForValue().setIfAbsent(keysUtil.build(StringKeys.SAMPLE, sampleId), sample);

            LOG.debug(new StringBuilder("SampleId: ")
                    .append(sampleId).append(" Value: ")
                    .append(sample).append(" Result: ")
                    .append(result));
        }

        return sampleId;
{'fraction_non_alphanumeric': 0.10726429675425038, 'fraction_numerical': 0.0030911901081916537, 'mean_word_length': 2.802585193889542, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4740898', 'n_tokens_mistral': 933, 'n_tokens_neox': 904, 'n_words': 199}