<commit_before>package org.commonjava.indy.folo.data;

import com.datastax.driver.core.*;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import org.commonjava.indy.IndyWorkflowException;
import org.commonjava.indy.action.IndyLifecycleException;
import org.commonjava.indy.action.StartupAction;
import org.commonjava.indy.folo.change.FoloBackupListener;
import org.commonjava.indy.folo.change.FoloExpirationWarningListener;
import org.commonjava.indy.folo.conf.FoloConfig;
import org.commonjava.indy.folo.model.TrackedContent;
import org.commonjava.indy.folo.model.TrackedContentEntry;
import org.commonjava.indy.folo.model.TrackingKey;
import org.commonjava.indy.model.core.StoreKey;
import org.commonjava.indy.subsys.cassandra.CassandraClient;
import org.commonjava.indy.subsys.infinispan.CacheHandle;
import org.commonjava.maven.galley.util.UrlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import java.net.MalformedURLException;
import java.util.*;
import java.util.stream.Collectors;

import static org.commonjava.indy.folo.data.DtxTrackingRecord.fromCassandraRow;

@ApplicationScoped
@FoloStoreToCassandra
public class FoloRecordCassandra implements FoloRecord,StartupAction {

    private final static String DOWNLOADS = "DOWNLOAD";
    private final static String UPLOADS = "UPLOAD";

    private final Logger logger = LoggerFactory.getLogger( this.getClass() );

    @Inject
    CassandraClient cassandraClient;

    @Inject
    FoloConfig config;

    @Context
    UriInfo uriInfo;

    @FoloInprogressCache
    @Inject
    private CacheHandle<TrackedContentEntry, TrackedContentEntry> inProgressRecords;

    @FoloSealedCache
    @Inject
    private CacheHandle<TrackingKey, TrackedContent> sealedRecords;

    @Inject
    private FoloBackupListener foloBackupListener;

    @Inject
    private FoloExpirationWarningListener expirationWarningListener;



    private Session session;
    private Mapper<DtxTrackingRecord> trackingMapper;

    private PreparedStatement getTrackingRecordByBuildIdAndPath;
    private PreparedStatement getTrackingRecordBySealed;
    private PreparedStatement getTrackingRecordsByTrackingKey;


    private static String createFoloRecordsTable( String keyspace )
    {
        return "CREATE TABLE IF NOT EXISTS " + keyspace + ".records ("
                + "tracking_key text,"
                + "sealed boolean,"
                + "store_key text,"<commit_msg>Remove unused injected variables<commit_after>package org.commonjava.indy.folo.data;

import com.datastax.driver.core.*;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import org.commonjava.indy.IndyWorkflowException;
import org.commonjava.indy.action.IndyLifecycleException;
import org.commonjava.indy.action.StartupAction;
import org.commonjava.indy.folo.change.FoloBackupListener;
import org.commonjava.indy.folo.change.FoloExpirationWarningListener;
import org.commonjava.indy.folo.conf.FoloConfig;
import org.commonjava.indy.folo.model.TrackedContent;
import org.commonjava.indy.folo.model.TrackedContentEntry;
import org.commonjava.indy.folo.model.TrackingKey;
import org.commonjava.indy.model.core.StoreKey;
import org.commonjava.indy.subsys.cassandra.CassandraClient;
import org.commonjava.indy.subsys.infinispan.CacheHandle;
import org.commonjava.maven.galley.util.UrlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import java.net.MalformedURLException;
import java.util.*;
import java.util.stream.Collectors;

import static org.commonjava.indy.folo.data.DtxTrackingRecord.fromCassandraRow;

@ApplicationScoped
@FoloStoreToCassandra
public class FoloRecordCassandra implements FoloRecord,StartupAction {

    private final static String DOWNLOADS = "DOWNLOAD";
    private final static String UPLOADS = "UPLOAD";

    private final Logger logger = LoggerFactory.getLogger( this.getClass() );

    @Inject
    CassandraClient cassandraClient;

    @Inject
    FoloConfig config;

    @Context
    UriInfo uriInfo;

    private Session session;
    private Mapper<DtxTrackingRecord> trackingMapper;

    private PreparedStatement getTrackingRecordByBuildIdAndPath;
    private PreparedStatement getTrackingRecordBySealed;
    private PreparedStatement getTrackingRecordsByTrackingKey;


    private static String createFoloRecordsTable( String keyspace )
    {
        return "CREATE TABLE IF NOT EXISTS " + keyspace + ".records ("
                + "tracking_key text,"
                + "sealed boolean,"
                + "store_key text,"
{'fraction_non_alphanumeric': 0.08323232323232323, 'fraction_numerical': 0.0008080808080808081, 'mean_word_length': 4.908114558472554, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5741733', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1457, 'n_words': 274}