<commit_before>/* This file is part of VoltDB.
 * Copyright (C) 2008-2018 VoltDB Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.voltdb;

import static org.voltdb.DRLogSegmentId.isEmptyDRId;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.json_voltpatches.JSONArray;
import org.json_voltpatches.JSONException;
import org.json_voltpatches.JSONObject;
import org.voltcore.logging.VoltLogger;
import org.voltdb.iv2.UniqueIdGenerator;

import com.google_voltpatches.common.collect.BoundType;
import com.google_voltpatches.common.collect.DiscreteDomain;
import com.google_voltpatches.common.collect.Range;
import com.google_voltpatches.common.collect.RangeSet;
import com.google_voltpatches.common.collect.TreeRangeSet;

/*
 * WARNING:
 * The implementation assumes that the range set is never completely empty in methods like
 * getSafePointDrId, getFirstDrId, getLastDrId. However, the assumption is based on a single thread
 * (DR partition buffer receiver thread) modifying and accessing this. When accessing this from other threads,
 * we will need to be careful to make sure to add proper checks to ensure safe access.
 */
public class DRConsumerDrIdTracker implements Serializable {
    private static final long serialVersionUID = -4057397384030151271L;

    protected RangeSet<Long> m_map;
    private long m_lastSpUniqueId;
    private long m_lastMpUniqueId;
    private int m_producerPartitionId;


    public static class DRSiteDrIdTracker extends DRConsumerDrIdTracker {
        private long m_lastReceivedLogId;

        private DRSiteDrIdTracker(long lastReceived, long spUniqueId, long mpUniqueId, int producerPartitionId) {
            super(spUniqueId, mpUniqueId, producerPartitionId);
            m_lastReceivedLogId = lastReceived;
        }

        public DRSiteDrIdTracker(DRSiteDrIdTracker other) {<commit_msg>Add public values for serialized offsets<commit_after>/* This file is part of VoltDB.
 * Copyright (C) 2008-2018 VoltDB Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.voltdb;

import static org.voltdb.DRLogSegmentId.isEmptyDRId;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.json_voltpatches.JSONArray;
import org.json_voltpatches.JSONException;
import org.json_voltpatches.JSONObject;
import org.voltcore.logging.VoltLogger;
import org.voltdb.iv2.UniqueIdGenerator;

import com.google_voltpatches.common.collect.BoundType;
import com.google_voltpatches.common.collect.DiscreteDomain;
import com.google_voltpatches.common.collect.Range;
import com.google_voltpatches.common.collect.RangeSet;
import com.google_voltpatches.common.collect.TreeRangeSet;

/*
 * WARNING:
 * The implementation assumes that the range set is never completely empty in methods like
 * getSafePointDrId, getFirstDrId, getLastDrId. However, the assumption is based on a single thread
 * (DR partition buffer receiver thread) modifying and accessing this. When accessing this from other threads,
 * we will need to be careful to make sure to add proper checks to ensure safe access.
 */
public class DRConsumerDrIdTracker implements Serializable {
    private static final long serialVersionUID = -4057397384030151271L;

    /** The offset at which {@link #m_lastSpUniqueId} can be found in the result of {@link #serialize(ByteBuffer)} */
    public static final int LAST_SP_UNIQUE_ID_OFFSET = 0;
    /** The offset at which {@link #m_lastMpUniqueId} can be found in the result of {@link #serialize(ByteBuffer)} */
    public static final int LAST_MP_UNIQUE_ID_OFFSET = LAST_SP_UNIQUE_ID_OFFSET + Long.BYTES;

    protected RangeSet<Long> m_map;
    private long m_lastSpUniqueId;
    private long m_lastMpUniqueId;
    private int m_producerPartitionId;


    public static class DRSiteDrIdTracker extends DRConsumerDrIdTracker {
        private long m_lastReceivedLogId;

        private DRSiteDrIdTracker(long lastReceived, long spUniqueId, long mpUniqueId, int producerPartitionId) {
            super(spUniqueId, mpUniqueId, producerPartitionId);
            m_lastReceivedLogId = lastReceived;
        }

        public DRSiteDrIdTracker(DRSiteDrIdTracker other) {
{'fraction_non_alphanumeric': 0.06545961002785515, 'fraction_numerical': 0.01027158774373259, 'mean_word_length': 4.534682080924855, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '820505', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1586, 'n_words': 572}