<commit_before>import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Random;
import java.util.logging.Logger;


/**
 * Generates 64-bit integer ids with a time component, sequence number component, and partition component.
 *
 * This system of generating IDs requires no central authority to generate key values.
 *
 * Since the time component of the ID is the first bits of the integer IDs are inherently sortable.
 * This is advantage for storage and retrieval of rows in a database, but may be a disadvantage if it's not desirable to
 * expose the sorted identifiers in URLs.  To overcome this limitation it is recommended to translate IDs before showing
 * them to users by using HashIds (http://hashids.org/) or Knuth's Integer Hash.
 * The time component of the id locates the ID in time.
 *
 *
 * <li>the time value will roll over every 2231 years
 * <li>since longs are signed in Java, negative ids will appear in 1115 years
 * <li>the time is the first part of the key to facilitate an implied temporal order to IDs.
 * The sequence component of the id allows up to 1024 ids to be generated per millisecond per partition.
 * <li>this implementation keeps a serial counter for sequence
 * <li>other stateless implementations may use a random serial value
 * The partition component of the id has one of the following uses:
 * <li>guarantee uniqueness across partitions that may have time drift
 * <li>create a pool of generators capable of generating more than 1024 IDs per millisecond
 * <li>compute a shard value that may be used to locate data onto to a particular node
 *
 *
 */
public class FlexId {
    private static final Logger logger = Logger.getLogger(FlexId.class.getName());

    public static final long UNIX_EPOCH = 0L;
    public static final long DEFAULT_EPOCH = 1420070400000L;
    public static final long INSTAGRAM_EPOCH = 1293840000000L;

    private final int sequenceBits;
    private final int partitionBits;
    private final int sequenceMask;
    private final int partitionMask;
    private final long epoch;
    private int sequence =  0;
    private int partition = 0;

    /**
     * Creates an ID generator.
     * @param epoch the start date for the time component.
     * @param sequenceBits the number of sequence bits for avoiding sub-millisecond id collisions; recommend between 8 and 12.
     * @param partitionBits the number of partition bits for identifying nodes/shards; recommend between 6 and 8.
     */
    public FlexId(long epoch, int sequenceBits, int partitionBits) {
        this.epoch = epoch;
        this.sequenceBits = sequenceBits;
        this.partitionBits = partitionBits;

        int mask = 0;
        for (int i = 0; i < sequenceBits; i++) {
            mask = (mask << 1) | 1;<commit_msg>cleaning up Javadoc<commit_after>import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Random;
import java.util.logging.Logger;


/**
 * Generates 64-bit integer ids with a time component, sequence number component, and partition component.
 *
 * This system of generating IDs requires no central authority to generate key values.
 *
 * Since the time component of the ID is the first bits of the integer IDs are inherently sortable.
 * This is advantage for storage and retrieval of rows in a database, but may be a disadvantage if it's not desirable to
 * expose the sorted identifiers in URLs.  To overcome this limitation it is recommended to translate IDs before showing
 * them to users by using HashIds (http://hashids.org/) or Knuth's Integer Hash.
 * The time component of the id locates the ID in time.
 */
public class FlexId {
    private static final Logger logger = Logger.getLogger(FlexId.class.getName());

    public static final long UNIX_EPOCH = 0L;
    public static final long DEFAULT_EPOCH = 1420070400000L;
    public static final long INSTAGRAM_EPOCH = 1293840000000L;

    private final int sequenceBits;
    private final int partitionBits;
    private final int sequenceMask;
    private final int partitionMask;
    private final long epoch;
    private int sequence =  0;
    private int partition = 0;

    /**
     * Creates an ID generator.
     * @param epoch the start date for the time component.
     * @param sequenceBits the number of sequence bits for avoiding sub-millisecond id collisions; recommend between 8 and 12.
     * @param partitionBits the number of partition bits for identifying nodes/shards; recommend between 6 and 8.
     */
    public FlexId(long epoch, int sequenceBits, int partitionBits) {
        this.epoch = epoch;
        this.sequenceBits = sequenceBits;
        this.partitionBits = partitionBits;

        int mask = 0;
        for (int i = 0; i < sequenceBits; i++) {
            mask = (mask << 1) | 1;
{'fraction_non_alphanumeric': 0.06259426847662142, 'fraction_numerical': 0.01809954751131222, 'mean_word_length': 3.669894366197183, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1972594', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1342, 'n_words': 638}