This commit is contained in:
Sebastiano Vigna 2022-02-10 12:42:42 +01:00
parent 0e65edc6e6
commit b6a27dd875
14 changed files with 190 additions and 69 deletions

View file

@ -16,33 +16,122 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=12
org.eclipse.jdt.core.compiler.compliance=12
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=warning
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=12
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL
org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX

View file

@ -1,3 +1,12 @@
8.5.8
- Fixed erroneous switch to Java 9.
- BinIO has been restructured to use java.nio whenever possible, and all
load/store methods now accept a byte order. The performance improvements
are very significant, in particular when handling data in native byte
order.
8.5.7
- Memory-mapped big lists.

View file

@ -358,7 +358,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC extends ABSTRACT_FUNCTION K
}
/** {@inheritDoc} */
@SuppressWarnings({"unchecked","deprecation"})
@SuppressWarnings({"deprecation"})
@Override
public void putAll(final Map<? extends KEY_GENERIC_CLASS,? extends VALUE_GENERIC_CLASS> m) {
if (m instanceof MAP) {

View file

@ -441,7 +441,6 @@ public final class BIG_ARRAYS {
* @deprecated Please use the version in {@link it.unimi.dsi.fastutil.BigArrays}.
*/
@Deprecated
SUPPRESS_WARNINGS_KEY_UNCHECKED
public static KEY_GENERIC KEY_GENERIC_TYPE[][] ensureCapacity(final KEY_GENERIC_TYPE[][] array, final long length, final long preserve) {
return length > length(array) ? forceCapacity(array, length, preserve) : array;
}

View file

@ -444,7 +444,6 @@
* a big array with {@code length} entries whose first {@code preserve}
* entries are the same as those of {@code array}.
*/
SUPPRESS_WARNINGS_KEY_UNCHECKED
public static KEY_GENERIC KEY_GENERIC_TYPE[][] ensureCapacity(final KEY_GENERIC_TYPE[][] array, final long length, final long preserve) {
return length > length(array) ? forceCapacity(array, length, preserve) : array;
}

View file

@ -56,10 +56,17 @@ import it.unimi.dsi.fastutil.floats.*;
* resulting files from other languages.
*
* <p>For each primitive type, this class provides methods that read elements
* from a {@link DataInput} or from a filename into an array. Analogously, there are
* methods that store the content of an array (fragment) or the elements
* returned by an iterator to a {@link DataOutput} or to a given filename. Files
* are buffered using {@link FastBufferedInputStream} and {@link FastBufferedOutputStream}.
* from a {@link DataInput}, an {@link InputStream} or from a file into an array
* or a {@linkplain it.unimi.dsi.fastutil.BigArrays big array}, or expose those elements as a type-specific {@link Iterator iterator}.
* There are also methods that let you choose a {@linkplain ByteOrder byte order} and
* that work with {@link ReadableByteChannel byte channels}.
* Analogously, there are
* methods that store the content of a (big) array (fragment) or the elements
* returned by an iterator to a {@link DataOutput}, to an {@link OutputStream},
* to a {@link WritableByteChannel}, or to a given file. Files
* are buffered using {@link FastBufferedInputStream} and {@link FastBufferedOutputStream},
* or, when possible, with a {@linkplain ByteBuffer byte buffer} allocated with
* {@linkplain ByteBuffer#allocateDirect(int)}.
*
* <p>Since bytes can be read from or written to any stream, additional methods
* makes it possible to {@linkplain #loadBytes(InputStream,byte[]) load bytes from} and
@ -67,9 +74,6 @@ import it.unimi.dsi.fastutil.floats.*;
* use the bulk-read methods of {@link InputStream} and {@link OutputStream}, but they
* also include a workaround for <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6478546">bug #6478546</a>.
*
* <p>Finally, there are useful wrapper methods that {@linkplain #asIntIterator(CharSequence)
* exhibit a file as a type-specific iterator}.
*
* @since 4.4
*/
@ -91,7 +95,7 @@ public class BinIO {
oos.close();
}
/** Stores an object in a file given by a pathname.
/** Stores an object in a file given by a filename.
*
* @param o an object.
* @param filename a filename.
@ -115,7 +119,7 @@ public class BinIO {
return result;
}
/** Loads an object from a file given by a pathname.
/** Loads an object from a file given by a filename.
*
* @param filename a filename.
* @return the object stored under the given filename.

View file

@ -84,7 +84,7 @@ public static int loadBytes(final InputStream inputStream, final byte[] array) t
/** Stores an array fragment to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[],int,int,DataOutput)}
* as it uses {@link OutputStream}'s bulk-read methods.
* as it uses {@link OutputStream}'s bulk-write methods.
*
* @param array an array whose elements will be written to {@code outputStream}.
* @param offset the index of the first element of {@code array} to be written.
@ -98,7 +98,7 @@ public static void storeBytes(final byte array[], final int offset, final int le
/** Stores an array to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[],DataOutput)}
* as it uses {@link OutputStream}'s bulk-read methods.
* as it uses {@link OutputStream}'s bulk-write methods.
*
* @param array an array whose elements will be written to {@code outputStream}.
* @param outputStream an output stream.
@ -199,7 +199,7 @@ public static long loadBytes(final InputStream inputStream, final byte[][] array
/** Stores a big-array fragment to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[][],long,long,DataOutput)}
* as it uses {@link OutputStream}'s bulk-read methods.
* as it uses {@link OutputStream}'s bulk-write methods.
*
* @param array a big array whose elements will be written to {@code outputStream}.
* @param offset the index of the first element of {@code array} to be written.
@ -213,7 +213,7 @@ public static void storeBytes(final byte array[][], final long offset, final lon
/** Stores a big array to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[][],DataOutput)}
* as it uses {@link OutputStream}'s bulk-read methods.
* as it uses {@link OutputStream}'s bulk-write methods.
*
* @param array a big array whose elements will be written to {@code outputStream}.
* @param outputStream an output stream.
@ -228,7 +228,7 @@ public static void storeBytes(final byte array[][], final OutputStream outputStr
/** Loads bytes from a given readable channel, storing them in a given array fragment.
*
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link channel}'s bulk-read methods.
* as it uses {@link ReadableByteChannel}'s bulk-read methods.
*
* @param channel a readable channel.
* @param array an array which will be filled with data from {@code channel}.
@ -255,8 +255,8 @@ public static int loadBytes(final ReadableByteChannel channel, final byte[] arra
/** Loads bytes from a given readable channel, storing them in a given array.
*
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[])}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link ReadableByteChannel}'s bulk-read methods.
*
* @param channel a readable channel.
* @param array an array which will be filled with data from {@code channel}.
@ -268,8 +268,8 @@ public static int loadBytes(final ReadableByteChannel channel, final byte[] arra
/** Stores an array fragment to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[],int,int,DataOutput)}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link WritableByteChannel}'s bulk-write methods.
*
* @param array an array whose elements will be written to {@code channel}.
* @param offset the index of the first element of {@code array} to be written.
@ -294,8 +294,8 @@ public static void storeBytes(final byte array[], int offset, int length, final
/** Stores an array to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[],DataOutput)}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link WritableByteChannel}'s bulk-write methods.
*
* @param array an array whose elements will be written to {@code channel}.
* @param channel a writable channel.
@ -306,8 +306,8 @@ public static void storeBytes(final byte array[], final WritableByteChannel chan
/** Loads bytes from a given readable channel, storing them in a given big-array fragment.
*
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[][],long,long)}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link ReadableByteChannel}'s bulk-read methods.
*
* @param channel a readable channel.
* @param array a big array which will be filled with data from {@code channel}.
@ -331,8 +331,8 @@ public static long loadBytes(final ReadableByteChannel channel, final byte[][] a
/** Loads bytes from a given readable channel, storing them in a given big array.
*
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[][])}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link ReadableByteChannel}'s bulk-read methods.
*
* @param channel a readable channel.
* @param array a big array which will be filled with data from {@code channel}.
@ -344,8 +344,8 @@ public static long loadBytes(final ReadableByteChannel channel, final byte[][] a
/** Stores a big-array fragment to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[][],long,long,DataOutput)}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link WritableByteChannel}'s bulk-write methods.
*
* @param array a big array whose elements will be written to {@code channel}.
* @param offset the index of the first element of {@code array} to be written.
@ -362,8 +362,8 @@ public static void storeBytes(final byte array[][], final long offset, final lon
/** Stores a big array to a given writable channel.
*
* <p>Note that this method is going to be significantly faster than {@link #storeBytes(byte[][],DataOutput)}
* as it uses {@link channel}'s bulk-read methods.
* <p>Note that this method is going to be significantly faster than {@link #loadBytes(DataInput,byte[],int,int)}
* as it uses {@link WritableByteChannel}'s bulk-write methods.
*
* @param array a big array whose elements will be written to {@code channel}.
* @param channel a writable channel.
@ -843,7 +843,8 @@ private static final class KEY_DATA_NIO_INPUT_WRAPPER implements KEY_ITERATOR {
public KEY_DATA_NIO_INPUT_WRAPPER(final ReadableByteChannel channel, final ByteOrder byteOrder) {
this.channel = channel;
byteBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(byteOrder);
buffer = byteBuffer.AS_KEY_BUFFER().clear().flip();
buffer = byteBuffer.AS_KEY_BUFFER();
buffer.clear().flip();
}
@Override

View file

@ -21,6 +21,7 @@ import java.io.DataOutput;
import java.io.IOException;
import java.nio.KEY_BUFFER;
import java.nio.ByteOrder;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
@ -59,11 +60,11 @@ public class MAPPED_BIG_LIST extends ABSTRACT_BIG_LIST {
/** The mask used to compute the offset in the chunk in longs. */
private static final long CHUNK_MASK = CHUNK_SIZE - 1;
/** The underlying byte buffers. */
private final KEY_BUFFER[] KEY_BUFFER;
/** The underlying buffers. */
private final KEY_BUFFER[] buffer;
/** An array parallel to {@link #KEY_BUFFER} specifying which buffers do not need to be
* {@linkplain KEY_BUFFER#duplicate() duplicated} before being used. */
/** An array parallel to {@link #buffer} specifying which buffers do not need to be
* duplicated before being used. */
private final boolean[] readyToUse;
/** The number of byte buffers. */
@ -74,27 +75,28 @@ public class MAPPED_BIG_LIST extends ABSTRACT_BIG_LIST {
/** Creates a new mapped big list.
*
* @param KEY_BUFFER the underlying byte buffers.
* @param size the overall number of elements in the underlying byte buffers (i.e., the
* sum of the {@linkplain KEY_BUFFER#capacity() capacities} of the byte buffers divided by the size of an element in bytes).
* @param readyToUse an array parallel to <code>KEY_BUFFER</code> specifying which buffers do not need to be
* {@linkplain KEY_BUFFER#duplicate() duplicated} before being used (the process will happen lazily); the array
* @param buffer the underlying buffers.
* @param size the overall number of elements in the underlying buffers (i.e., the
* sum of the capacities of the byte buffers divided by the size of an element in bytes).
* @param readyToUse an array parallel to {@code buffer} specifying which buffers do not need to be
* {@linkplain ByteBuffer#duplicate() duplicated} before being used (the process will happen lazily); the array
* will be used internally by the newly created mapped big list.
*/
protected MAPPED_BIG_LIST(final KEY_BUFFER[] KEY_BUFFER, final long size, final boolean[] readyToUse) {
this.KEY_BUFFER = KEY_BUFFER;
this.n = KEY_BUFFER.length;
protected MAPPED_BIG_LIST(final KEY_BUFFER[] buffer, final long size, final boolean[] readyToUse) {
this.buffer = buffer;
this.n = buffer.length;
this.size = size;
this.readyToUse = readyToUse;
for(int i = 0; i < n; i++) if (i < n - 1 && KEY_BUFFER[i].capacity() != CHUNK_SIZE) throw new IllegalArgumentException();
for(int i = 0; i < n; i++) if (i < n - 1 && buffer[i].capacity() != CHUNK_SIZE) throw new IllegalArgumentException();
}
/** Creates a new mapped big list by read-only mapping a given file channel using the standard Java (i.e., {@link DataOutput}) byte order ({@link ByteOrder#BIG_ENDIAN}).
/** Creates a new mapped big list by read-only mapping a given file channel using the
* standard Java (i.e., {@link DataOutput}) byte order ({@link ByteOrder#BIG_ENDIAN}).
*
* @param fileChannel the file channel that will be mapped.
* @return a new read-only mapped big list over the contents of <code>fileChannel</code>.
* @return a new read-only mapped big list over the contents of {@code fileChannel}.
*
* @see #map(FileChannel, ByteOrder, MapMode)
*/
@ -107,7 +109,7 @@ public class MAPPED_BIG_LIST extends ABSTRACT_BIG_LIST {
*
* @param fileChannel the file channel that will be mapped.
* @param byteOrder a prescribed byte order.
* @return a new read-only mapped big list over the contents of <code>fileChannel</code>.
* @return a new read-only mapped big list over the contents of {@code fileChannel}.
*
* @see #map(FileChannel, ByteOrder, MapMode)
*/
@ -122,36 +124,36 @@ public class MAPPED_BIG_LIST extends ABSTRACT_BIG_LIST {
* @param byteOrder a prescribed byte order.
* @param mapMode the mapping mode: usually {@link MapMode#READ_ONLY}, but if intend to make the list
* {@linkplain #set mutable}, you have to pass {@link MapMode#READ_WRITE}.
* @return a new mapped big list over the contents of <code>fileChannel</code>.
* @return a new mapped big list over the contents of {@code fileChannel}.
*/
public static MAPPED_BIG_LIST map(final FileChannel fileChannel, final ByteOrder byteOrder, final MapMode mapMode) throws IOException {
final long size = fileChannel.size() / KEY_CLASS.BYTES;
final int chunks = (int)((size + (CHUNK_SIZE - 1)) / CHUNK_SIZE);
final KEY_BUFFER[] KEY_BUFFER = new KEY_BUFFER[chunks];
final KEY_BUFFER[] buffer = new KEY_BUFFER[chunks];
#if KEY_CLASS_Byte
for(int i = 0; i < chunks; i++) KEY_BUFFER[i] = fileChannel.map(mapMode, i * CHUNK_SIZE * KEY_CLASS.BYTES, Math.min(CHUNK_SIZE, size - i * CHUNK_SIZE) * KEY_CLASS.BYTES);
for(int i = 0; i < chunks; i++) buffer[i] = fileChannel.map(mapMode, i * CHUNK_SIZE * KEY_CLASS.BYTES, Math.min(CHUNK_SIZE, size - i * CHUNK_SIZE) * KEY_CLASS.BYTES);
#else
for(int i = 0; i < chunks; i++) KEY_BUFFER[i] = fileChannel.map(mapMode, i * CHUNK_SIZE * KEY_CLASS.BYTES, Math.min(CHUNK_SIZE, size - i * CHUNK_SIZE) * KEY_CLASS.BYTES).order(byteOrder).AS_KEY_BUFFER();
for(int i = 0; i < chunks; i++) buffer[i] = fileChannel.map(mapMode, i * CHUNK_SIZE * KEY_CLASS.BYTES, Math.min(CHUNK_SIZE, size - i * CHUNK_SIZE) * KEY_CLASS.BYTES).order(byteOrder).AS_KEY_BUFFER();
#endif
final boolean[] readyToUse = new boolean[chunks];
Arrays.fill(readyToUse, true);
return new MAPPED_BIG_LIST(KEY_BUFFER, size, readyToUse);
return new MAPPED_BIG_LIST(buffer, size, readyToUse);
}
private KEY_BUFFER KEY_BUFFER(final int n) {
if (readyToUse[n]) return KEY_BUFFER[n];
if (readyToUse[n]) return buffer[n];
readyToUse[n] = true;
return KEY_BUFFER[n] = KEY_BUFFER[n].duplicate();
return buffer[n] = buffer[n].duplicate();
}
/** Returns a lightweight duplicate that can be read independently by another thread.
*
* <p>Only chunks that are actually used will be {@linkplain KEY_BUFFER#duplicate() duplicated} lazily.
* <p>Only chunks that are actually used will be {@linkplain ByteBuffer#duplicate() duplicated} lazily.
* @return a lightweight duplicate that can be read independently by another thread.
*/
public MAPPED_BIG_LIST copy() {
return new MAPPED_BIG_LIST(KEY_BUFFER.clone(), size, new boolean[n]);
return new MAPPED_BIG_LIST(buffer.clone(), size, new boolean[n]);
}
@Override

View file

@ -61,8 +61,7 @@ public class Int2IntOpenHashMapGuavaTest extends TestCase {
@Override
public Map<Integer, Integer> create(final Object... entries) {
@SuppressWarnings("unchecked")
final var map = factory.get();
Map<Integer, Integer> map = factory.get();
for (final Object o : entries) {
@SuppressWarnings("unchecked")
final Entry<Integer, Integer> e = (Entry<Integer, Integer>)o;

View file

@ -53,8 +53,8 @@ public class Object2ObjectOpenHashMapGuavaTest extends TestCase {
@Override
protected Map<String, String> create(final Map.Entry<String, String>[] entries) {
final var map = factory.get();
for (final var entry : entries) {
final Map<String, String> map = factory.get();
for (final Map.Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;

View file

@ -54,8 +54,8 @@ public class Object2ObjectRBTreeMapGuavaTest extends TestCase {
@Override
protected SortedMap<String, String> create(final Map.Entry<String, String>[] entries) {
final var map = factory.get();
for (final var entry : entries) {
final Map<String, String> map = factory.get();
for (final Map.Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return (SortedMap<String, String>)map;

View file

@ -49,7 +49,7 @@ public class ObjectOpenHashSetGuavaTest extends TestCase {
@Override
protected Set<String> create(final String[] elements) {
final Set<String> set = factory.get();
for (final var e : elements) {
for (final String e : elements) {
set.add(e);
}
return set;

View file

@ -10,7 +10,6 @@ import it.unimi.dsi.fastutil.ints.IntIntPair;
public class IntIntPairTest {
@SuppressWarnings("boxing")
@Test
public void test() {
final Comparator<IntIntPair> comparator = IntIntPair.lexComparator();

View file

@ -448,11 +448,23 @@ public class BinIOTest {
assertArrayEquals(d, e);
dis.close();
dis = new DataInputStream(new FileInputStream(file));
assertEquals(size, BinIO.loadBooleans(dis, new boolean[size * 2]));
dis.close();
DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
BinIO.storeBooleans(d, size2, size34 - size2, dos);
assertArrayEquals(Arrays.copyOfRange(d, size2, size34), BinIO.loadBooleans(file));
dos.close();
BinIO.storeBooleans(d, file);
dis = new DataInputStream(new FileInputStream(file));
assertEquals(size, BinIO.loadBooleans(dis, new boolean[size * 3], size, 2 * size));
dis.close();
assertEquals(size, BinIO.loadBooleans(file, new boolean[size * 3], size, 2 * size));
dos = new DataOutputStream(new FileOutputStream(file));
BinIO.storeBooleans(BooleanIterators.wrap(d), dos);
assertArrayEquals(d, BinIO.loadBooleans(file));
@ -570,6 +582,14 @@ public class BinIOTest {
assertTrue(BigArrays.equals(dd, ee));
dis.close();
dis = new DataInputStream(new FileInputStream(file));
assertEquals(size, BinIO.loadBooleans(dis, BooleanBigArrays.newBigArray(size * 3)));
dis.close();
dis = new DataInputStream(new FileInputStream(file));
assertEquals(size, BinIO.loadBooleans(dis, BooleanBigArrays.newBigArray(size * 3), size, 2 * size));
dis.close();
dis = new DataInputStream(new FileInputStream(file));
assertEquals(size2, BinIO.loadBooleans(dis, hh));
for (int i = 0; i < size2; i++) assertEquals(h[i], get(hh, i));