<commit_before>package org.sirix.io.chronicle;

import static com.google.common.base.Preconditions.checkNotNull;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;

import javax.annotation.Nullable;

import org.sirix.api.PageReadTrx;
import org.sirix.exception.SirixIOException;
import org.sirix.io.Reader;
import org.sirix.io.bytepipe.ByteHandler;
import org.sirix.page.PagePersistenter;
import org.sirix.page.PageReference;
import org.sirix.page.UberPage;
import org.sirix.page.interfaces.Page;

import com.higherfrequencytrading.chronicle.Chronicle;
import com.higherfrequencytrading.chronicle.Excerpt;
import com.higherfrequencytrading.chronicle.impl.IndexedChronicle;

public final class ChronicleReader implements Reader {

	/** Beacon of the other references. */
	final static int OTHER_BEACON = 4;

	private final Chronicle mChronicle;
	final ByteHandler mByteHandler;

	private final Excerpt mExcerpt;

	public ChronicleReader(final File concreteStorage, final ByteHandler handler)
			throws SirixIOException {
		try {
			if (!concreteStorage.exists()) {
				concreteStorage.getParentFile().mkdirs();
				concreteStorage.createNewFile();
			}

			mChronicle = new IndexedChronicle(concreteStorage.getAbsolutePath());
			mByteHandler = checkNotNull(handler);
			mExcerpt = mChronicle.createExcerpt();
		} catch (final IOException e) {
			throw new SirixIOException(e);
		}
	}

	@Override
	public PageReference readFirstReference() throws SirixIOException {
		final PageReference uberPageReference = new PageReference();
		// Read primary beacon.
		final long lastIndex = mChronicle.size() - 1;
		uberPageReference.setKey(lastIndex);<commit_msg>[FIX] Another chronicle storage fix.<commit_after>package org.sirix.io.chronicle;

import static com.google.common.base.Preconditions.checkNotNull;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;

import javax.annotation.Nullable;

import org.sirix.api.PageReadTrx;
import org.sirix.exception.SirixIOException;
import org.sirix.io.Reader;
import org.sirix.io.bytepipe.ByteHandler;
import org.sirix.page.PagePersistenter;
import org.sirix.page.PageReference;
import org.sirix.page.UberPage;
import org.sirix.page.interfaces.Page;

import com.higherfrequencytrading.chronicle.Chronicle;
import com.higherfrequencytrading.chronicle.Excerpt;
import com.higherfrequencytrading.chronicle.impl.IndexedChronicle;

public final class ChronicleReader implements Reader {

	/** Beacon of the other references. */
	final static int OTHER_BEACON = 4;

	private final Chronicle mChronicle;
	final ByteHandler mByteHandler;

	private final Excerpt mExcerpt;

	public ChronicleReader(final File concreteStorage, final ByteHandler handler)
			throws SirixIOException {
		try {
			if (!concreteStorage.exists()) {
				concreteStorage.getParentFile().mkdirs();
				concreteStorage.createNewFile();
			}

			mChronicle = new IndexedChronicle(concreteStorage.getAbsolutePath());
			mByteHandler = checkNotNull(handler);
			mExcerpt = mChronicle.createExcerpt();
		} catch (final IOException e) {
			throw new SirixIOException(e);
		}
	}

	@Override
	public PageReference readFirstReference() throws SirixIOException {
		final PageReference uberPageReference = new PageReference();
		// Read primary beacon.
		final long lastIndex = mExcerpt.size() - 1;
//		mExcerpt.index(lastIndex);
		uberPageReference.setKey(lastIndex);
{'fraction_non_alphanumeric': 0.0924971363115693, 'fraction_numerical': 0.001145475372279496, 'mean_word_length': 5.468518518518518, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3635982', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1056, 'n_words': 228}