<commit_before>/**
 * Copyright 2016 Eventchain team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 */
package org.eventchain;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.eventchain.hlc.HybridTimestamp;
import org.eventchain.layout.LayoutIgnore;

import java.util.UUID;

public class Entity {

    @Setter @Accessors(fluent = true)
    private UUID uuid;

    @LayoutIgnore
    public UUID uuid() {
        if (uuid == null) {
            uuid = UUID.randomUUID();
        }
        return uuid;
    }

    @Getter(onMethod = @__(@LayoutIgnore)) @Setter @Accessors(fluent = true)
    private HybridTimestamp timestamp;

}<commit_msg>Improve Entity UUID generation time by pre-generating them<commit_after>/**
 * Copyright 2016 Eventchain team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 */
package org.eventchain;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.eventchain.hlc.HybridTimestamp;
import org.eventchain.layout.LayoutIgnore;

import java.util.UUID;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.LinkedBlockingDeque;

public class Entity {

    private static LinkedBlockingDeque<UUID> uuids = new LinkedBlockingDeque<>(1_000_000);

    static {
        ForkJoinPool.commonPool().execute(() -> {
            while (true) {
                try {
                    uuids.put(UUID.randomUUID());
                } catch (InterruptedException e) {
                }
            }
        });
    }

    @Setter @Accessors(fluent = true)
    private UUID uuid;

    @LayoutIgnore
    public UUID uuid() {
        while (uuid == null) {
            try {
                uuid = uuids.take();
            } catch (InterruptedException e) {
            }
        }
        return uuid;
    }

    @Getter(onMethod = @__(@LayoutIgnore)) @Setter @Accessors(fluent = true)
    private HybridTimestamp timestamp;

}
{'fraction_non_alphanumeric': 0.08951667801225323, 'fraction_numerical': 0.007828454731109599, 'mean_word_length': 2.950268817204301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2556948', 'n_tokens_mistral': 839, 'n_tokens_neox': 813, 'n_words': 274}