private void readObject( final ObjectInputStream s ) throws IOException, ClassNotFoundException { s.defaultReadObject(); final long size = s.readLong(); final ObjectBigArrayBigList<TRECDocumentDescriptor> descriptors = new ObjectBigArrayBigList<TRECDocumentDescriptor>(); descriptors.ensureCapacity( size ); for ( int i = 0; i < size; i++ ) descriptors.add( new TRECDocumentDescriptor( s.readInt(), s.readLong(), s.readInt(), s.readInt() ) ); this.descriptors = descriptors; }
@Override public CharSequence getEntityName( int id ) { return names.get( id ); }
public long size() { return descriptors.size64(); }
/** * Compares this type-specific big-array list to another one. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a type-specific big-array list. * @return true if the argument contains the same elements of this type-specific * big-array list. */ public boolean equals(final ObjectBigArrayBigList<K> l) { if (l == this) return true; long s = size64(); if (s != l.size64()) return false; final K[][] a1 = a; final K[][] a2 = l.a; while (s-- != 0) if (!valEquals(ObjectBigArrays.get(a1, s), ObjectBigArrays.get(a2, s))) return false; return true; } /**
@Override public ObjectBigArrayBigList<K> clone() { ObjectBigArrayBigList<K> c = new ObjectBigArrayBigList<>(size); ObjectBigArrays.copy(a, 0, c.a, 0, size); c.size = size; return c; } private boolean valEquals(final K a, final K b) {
@Override public void add(K k) { ObjectBigArrayBigList.this.add(pos++, k); last = -1; } @Override
/** * Merges a new collection in this one, by rebuilding the gzFile array and * appending the other object one, concatenating the descriptors while * rebuilding all. * <p> * It is supposed that the passed object contains no duplicates for the * local collection. */ public void merge( TRECDocumentCollection other ) { int oldLength = this.file.length; this.file = ObjectArrays.ensureCapacity( this.file, this.file.length + other.file.length ); System.arraycopy( other.file, 0, this.file, oldLength, other.file.length ); ObjectIterator<TRECDocumentDescriptor> iter = other.descriptors.iterator(); while ( iter.hasNext() ) { final TRECDocumentDescriptor tdd = (TRECDocumentDescriptor)iter.next().clone(); tdd.fileIndex += oldLength; this.descriptors.add( tdd ); } }
private final ObjectIterator<TRECDocumentDescriptor> descriptorIterator = descriptors.iterator();
/** Returns all lines of the file wrapped by this file-lines collection. * * @return all lines of the file wrapped by this file-lines collection. */ public ObjectBigList<byte[]> allLines() { final ObjectBigList<byte[]> result = new ObjectBigArrayBigList<>(); for(final Iterator<byte[]> i = iterator(); i.hasNext();) result.add(i.next()); return result; }
/** * Creates a new big-array big list and fills it with the elements returned by * an iterator.. * * @param i * an iterator whose returned elements will fill the array list. */ public ObjectBigArrayBigList(final Iterator<? extends K> i) { this(); while (i.hasNext()) this.add((i.next())); } /**
/** * Merges a new collection in this one, by rebuilding the gzFile array and * appending the other object one, concatenating the descriptors while * rebuilding all. * <p> * It is supposed that the passed object contains no duplicates for the * local collection. */ public void merge( TRECDocumentCollection other ) { int oldLength = this.file.length; this.file = ObjectArrays.ensureCapacity( this.file, this.file.length + other.file.length ); System.arraycopy( other.file, 0, this.file, oldLength, other.file.length ); ObjectIterator<TRECDocumentDescriptor> iter = other.descriptors.iterator(); while ( iter.hasNext() ) { final TRECDocumentDescriptor tdd = (TRECDocumentDescriptor)iter.next().clone(); tdd.fileIndex += oldLength; this.descriptors.add( tdd ); } }
private final ObjectIterator<TRECDocumentDescriptor> descriptorIterator = descriptors.iterator();
private void readObject( final ObjectInputStream s ) throws IOException, ClassNotFoundException { s.defaultReadObject(); final long size = s.readLong(); final ObjectBigArrayBigList<TRECDocumentDescriptor> descriptors = new ObjectBigArrayBigList<TRECDocumentDescriptor>(); descriptors.ensureCapacity( size ); for ( int i = 0; i < size; i++ ) descriptors.add( new TRECDocumentDescriptor( s.readInt(), s.readLong(), s.readInt(), s.readInt() ) ); this.descriptors = descriptors; }
/** Returns all lines of the file wrapped by this file-lines collection. * * @return all lines of the file wrapped by this file-lines collection. */ public ObjectBigList<MutableString> allLines() { final ObjectBigList<MutableString> result = new ObjectBigArrayBigList<>(); for(final Iterator<MutableString> i = iterator(); i.hasNext();) result.add(i.next().copy()); return result; }
/** * Creates a new big-array big list and fills it with the elements returned by a * type-specific iterator.. * * @param i * a type-specific iterator whose returned elements will fill the * array list. */ public ObjectBigArrayBigList(final ObjectIterator<? extends K> i) { this(); while (i.hasNext()) this.add(i.next()); } /**
public long size() { return descriptors.size64(); }
public InputStream stream( final long n ) throws IOException { // Creates a Segmented Input Stream with only one segment in (the requested one). ensureDocumentIndex( n ); IOUtils.closeQuietly( lastStream ); final TRECDocumentDescriptor descr = descriptors.get( n ); return lastStream = new SegmentedInputStream( openFileStream( file[ descr.fileIndex ] ), descr.toSegments() ); }
/** * Wraps a given big array into a big-array list of given size. * * @param a * a big array to wrap. * @param length * the length of the resulting big-array list. * @return a new big-array list of the given size, wrapping the given big array. */ public static <K> ObjectBigArrayBigList<K> wrap(final K a[][], final long length) { if (length > ObjectBigArrays.length(a)) throw new IllegalArgumentException("The specified length (" + length + ") is greater than the array size (" + ObjectBigArrays.length(a) + ")"); final ObjectBigArrayBigList<K> l = new ObjectBigArrayBigList<>(a, false); l.size = length; return l; } /**
/** * Creates a new big-array big list and fills it with a given type-specific * collection. * * @param c * a type-specific collection that will be used to fill the array * list. */ public ObjectBigArrayBigList(final ObjectCollection<? extends K> c) { this(c.size()); for (ObjectIterator<? extends K> i = c.iterator(); i.hasNext();) add(i.next()); } /**
private void writeObject(final ObjectOutputStream s) throws IOException { s.defaultWriteObject(); s.writeLong(descriptors.size64()); for (TRECDocumentDescriptor descriptor : descriptors) { s.writeInt(descriptor.fileIndex); s.writeLong(descriptor.startMarker); s.writeInt(descriptor.intermediateMarkerDiff); s.writeInt(descriptor.stopMarkerDiff); } }