<commit_before>package com.cascaio.backend.v1.control.batch.stockquote;

import com.cascaio.backend.v1.boundary.reference.StockService;
import com.cascaio.backend.v1.entity.reference.Stock;
import org.slf4j.Logger;

import javax.batch.api.partition.PartitionPlanImpl;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
@Named
public class StockQuotePartitionPlan extends PartitionPlanImpl {

    @Inject
    StockService stockService;

    @Inject
    Logger logger;

    private List<Stock> stockList;
    private static final int MAX_THREADS = 250;

    @Override
    public int getPartitions() {
        // one partition per stock
        return getStockList().size();
    }

    @Override
    public int getThreads() {
        return Math.min(getStockList().size(), MAX_THREADS); // at most, MAX_THREADS threads
    }

    @Override
    public Properties[] getPartitionProperties() {
        Properties[] properties = new Properties[getPartitions()];
        for (int i = 0 ; i < getPartitions() ; i++) {
            Stock stock = getStockList().get(i);
            logger.trace("Adding to {} partition plan position {}", stock.getSymbol(), i);
            properties[i] = new Properties();
            properties[i].put("stockSymbol", stock.getSymbol());
            properties[i].put("stockId", stock.getId());
        }

        return properties;
    }

    public List<Stock> getStockList() {
        return getAllStocks();
    }

    public List<Stock> getSingleStockList() {
        List<Stock> stocks = new ArrayList<>(1);
        stocks.add(stockService.readAsEntity("b4031c4b-6e6b-4dda-8a63-68251e686f97")); // RHT at NYSE
        return stocks;
    }

    public List<Stock> getAllStocks() {
        if (null == stockList) {
            stockList = stockService.listAsEntity(null);
        }
        return stockList;
    }
}
<commit_msg>reduced the number of partitions for stock quote<commit_after>package com.cascaio.backend.v1.control.batch.stockquote;

import com.cascaio.backend.v1.boundary.reference.StockService;
import com.cascaio.backend.v1.entity.reference.Stock;
import org.slf4j.Logger;

import javax.batch.api.partition.PartitionPlanImpl;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
@Named
public class StockQuotePartitionPlan extends PartitionPlanImpl {

    @Inject
    StockService stockService;

    @Inject
    Logger logger;

    private List<Stock> stockList;
    private static final int MAX_THREADS = 25;

    @Override
    public int getPartitions() {
        // one partition per stock
        return getStockList().size();
    }

    @Override
    public int getThreads() {
        return Math.min(getStockList().size(), MAX_THREADS); // at most, MAX_THREADS threads
    }

    @Override
    public Properties[] getPartitionProperties() {
        Properties[] properties = new Properties[getPartitions()];
        for (int i = 0 ; i < getPartitions() ; i++) {
            Stock stock = getStockList().get(i);
            logger.trace("Adding to {} partition plan position {}", stock.getSymbol(), i);
            properties[i] = new Properties();
            properties[i].put("stockSymbol", stock.getSymbol());
            properties[i].put("stockId", stock.getId());
        }

        return properties;
    }

    public List<Stock> getStockList() {
        return getAllStocks();
    }

    public List<Stock> getSingleStockList() {
        List<Stock> stocks = new ArrayList<>(1);
        stocks.add(stockService.readAsEntity("b4031c4b-6e6b-4dda-8a63-68251e686f97")); // RHT at NYSE
        return stocks;
    }

    public List<Stock> getAllStocks() {
        if (null == stockList) {
            stockList = stockService.listAsEntity(null);
        }
        return stockList;
    }
}

{'fraction_non_alphanumeric': 0.12288557213930348, 'fraction_numerical': 0.014676616915422885, 'mean_word_length': 2.9344422700587085, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, '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': '7155901', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1185, 'n_words': 261}