package com.hughes.android.dictionary.engine;
import java.io.DataInput;
-import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.File;
import java.io.IOException;
-import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
-import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
-import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.hughes.util.DataInputBuffer;
import com.hughes.util.raf.RAFList;
import com.hughes.util.raf.RAFListSerializer;
-import com.hughes.util.raf.RAFSerializable;
-public class Dictionary implements RAFSerializable<Dictionary> {
+public class Dictionary {
private static final int CACHE_SIZE = 5000;
public final List<DataInputBuffer> htmlData;
public final List<EntrySource> sources;
public final List<Index> indices;
+ // Could be a local variable in constructor, but
+ // this way avoids a native-image VM bug.
+ private final MappedByteBuffer wholefile;
/**
* dictFileVersion 1 adds: <li>links to sources? dictFileVersion 2 adds: <li>
htmlData = null;
sources = new ArrayList<>();
indices = new ArrayList<>();
+ wholefile = null;
}
public Dictionary(final FileChannel ch) throws IOException {
- MappedByteBuffer wholefile = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size());
+ wholefile = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size());
DataInputBuffer in = new DataInputBuffer(wholefile, 0);
dictFileVersion = in.readInt();
if (dictFileVersion < 0 || dictFileVersion > CURRENT_DICT_VERSION) {
}
}
- @Override
public void write(DataOutput out) throws IOException {
RandomAccessFile raf = (RandomAccessFile)out;
if (dictFileVersion < 7) throw new RuntimeException("write function cannot write formats older than v7!");