<commit_before>package org.sagebionetworks.dashboard.dao.redshift;

import java.util.HashMap;

import javax.annotation.Resource;

import org.sagebionetworks.dashboard.dao.RawAccessRecordDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("rawAccessRecordDao")
public class RawAccessRecordDaoImpl implements RawAccessRecordDao{

    private final Logger logger = LoggerFactory.getLogger(RawAccessRecordDaoImpl.class);

    @Resource
    private NamedParameterJdbcTemplate dwTemplate;

    private static final String COPY_HEAD = "COPY raw_access_record FROM '";
    private static final String COPY_CRED_U = "' CREDENTIALS 'aws_access_key_id=";
    private static final String COPY_CRED_P = ";aws_secret_access_key=";
    private static final String COPY_END = "' CSV GZIP FILLRECORD;";

    @Override
    public void copy(String filePath, String username, String password) {
        String query = COPY_HEAD + filePath + COPY_CRED_U + username + COPY_CRED_P + password + COPY_END;
        try {
            dwTemplate.update(query, new HashMap<String, Object>());
            logger.info("Finish adding " + filePath + " into raw_access_record table.");
        } catch (Throwable e) {
            logger.error("Failed to add " + filePath, e);
        }
    }

    @Override
    public long count() {
        // TODO Auto-generated method stub
        return 0;
    }

}
<commit_msg>add count method to RawAcessRecordDaoImpl<commit_after>package org.sagebionetworks.dashboard.dao.redshift;

import java.util.HashMap;

import javax.annotation.Resource;

import org.sagebionetworks.dashboard.dao.RawAccessRecordDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("rawAccessRecordDao")
public class RawAccessRecordDaoImpl implements RawAccessRecordDao{

    private final Logger logger = LoggerFactory.getLogger(RawAccessRecordDaoImpl.class);

    @Resource
    private NamedParameterJdbcTemplate dwTemplate;

    private static final String COPY_HEAD = "COPY raw_access_record FROM '";
    private static final String COPY_CRED_U = "' CREDENTIALS 'aws_access_key_id=";
    private static final String COPY_CRED_P = ";aws_secret_access_key=";
    private static final String COPY_END = "' CSV GZIP FILLRECORD;";

    private static final String COUNT = "SELECT COUNT(*) FROM raw_access_record;";

    @Override
    public void copy(String filePath, String username, String password) {
        String query = COPY_HEAD + filePath + COPY_CRED_U + username + COPY_CRED_P + password + COPY_END;
        try {
            dwTemplate.update(query, new HashMap<String, Object>());
            logger.info("Finish adding " + filePath + " into raw_access_record table.");
        } catch (Throwable e) {
            logger.error("Failed to add " + filePath, e);
        }
    }

    @SuppressWarnings("deprecation")
    @Override
    public long count() {
        return dwTemplate.getJdbcOperations().queryForInt(COUNT);
    }

}

{'fraction_non_alphanumeric': 0.08768656716417911, 'fraction_numerical': 0.001554726368159204, 'mean_word_length': 3.987596899224806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '263080', 'n_tokens_mistral': 932, 'n_tokens_neox': 949, 'n_words': 224}