@SuppressWarnings("unchecked") public boolean containsKey( Object o ) { final CharSequence s = (CharSequence)o; return checkSignature( s, function.getLong( s ) ); }
private boolean checkSignature( final CharSequence s, final long index ) { //System.err.println( s + ": " + signatures.getLong( index ) + " ?= " + signature( s ) ); return index >= 0 && index < function.size() && signatures.getLong( index ) == signature( s ); }
public int get(String s) { return intList.getInt((int) stringHash.getLong(s)); }
ShiftAddXorSignedStringMap dict = new ShiftAddXorSignedStringMap(stringList.iterator(), new TwoStepsLcpMonotoneMinimalPerfectHashFunction<CharSequence>(stringList, TransformationStrategies.prefixFreeUtf16()));
ShiftAddXorSignedStringMap dictionaryHash = new ShiftAddXorSignedStringMap( indexToWord.iterator(), new MinimalPerfectHashFunction.Builder<CharSequence>().keys( indexToWord ).transform( TransformationStrategies.utf16() ).build() ); int[] permutation = new int[ numWords ]; for( int i = 0; i < numWords; ++i ) { int newPos = dictionaryHash.get( indexToWord.get( i ) ).intValue(); permutation[ newPos ] = i;
ShiftAddXorSignedStringMap surfaceForm2Position = new ShiftAddXorSignedStringMap( surfaceForms.iterator(), new MWHCFunction.Builder<CharSequence>().keys( surfaceForms ).transform( TransformationStrategies.utf16() ) .build() ); f = surfaceForm2Position; numberOfPhrases = surfaceForm2Position.size();
final Logger logger = LoggerFactory.getLogger(ShiftAddXorSignedStringMap.class); logger.info("Signing..."); BinIO.storeObject(new ShiftAddXorSignedStringMap(iterator, function, width), mapName); if (stringFile != null) inputStream.close(); logger.info("Completed.");
ShiftAddXorSignedStringMap surfaceForm2Position = new ShiftAddXorSignedStringMap( surfaceForms.iterator(), new MWHCFunction.Builder<CharSequence>().keys( surfaceForms ).transform( TransformationStrategies.utf16() ).build() );
@SuppressWarnings("unchecked") public Long get( Object o ) { final CharSequence s = (CharSequence)o; final long index = function.getLong( s ); return checkSignature( s, index ) ? Long.valueOf( index ) : null; }
private boolean checkSignature( final CharSequence s, final long index ) { //System.err.println( s + ": " + signatures.getLong( index ) + " ?= " + signature( s ) ); return index >= 0 && index < function.size() && signatures.getLong( index ) == signature( s ); }
final Object2LongFunction<CharSequence> function = (Object2LongFunction<CharSequence>)BinIO.loadObject( functionName ); LOGGER.info( "Signing..." ); BinIO.storeObject( new ShiftAddXorSignedStringMap( iterator, function, width ), mapName ); LOGGER.info( "Completed." );
@Override public Long get(Object o) { final CharSequence s = (CharSequence)o; final long index = function.getLong(s); return checkSignature(s, index) ? Long.valueOf(index) : null; }
private boolean checkSignature(final CharSequence s, final long index) { //System.err.println(s + ": " + signatures.getLong(index) + " ?= " + signature(s)); return index >= 0 && index < function.size() && signatures.getLong(index) == signature(s); }
final Object2LongFunction<CharSequence> function = (Object2LongFunction<CharSequence>)BinIO.loadObject( functionName ); LOGGER.info( "Signing..." ); BinIO.storeObject( new ShiftAddXorSignedStringMap( iterator, function, width ), mapName ); LOGGER.info( "Completed." );
@SuppressWarnings("unchecked") public long getLong( Object o ) { final CharSequence s = (CharSequence)o; final long index = function.getLong( s ); return checkSignature( s, index ) ? index : defRetValue; }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap( final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth ) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : ( 1L << width ) - 1; final int n = map.size(); signatures = LongArrayBitVector.getInstance().asLongBigList( signatureWidth ).length( n ); for( int i = 0; i < n; i++ ) { s = iterator.next(); signatures.set( map.getLong( s ), signature( s ) ); } if ( iterator.hasNext() ) throw new IllegalStateException( "Iterator provides more than " + n + " elements" ); }
if ( jsapResult.getBoolean( "sorted" ) ) BinIO.storeObject( new URLMPHVirtualDocumentResolver( new ShiftAddXorSignedStringMap( collection.iterator(), new TwoStepsLcpMonotoneMinimalPerfectHashFunction<CharSequence>( collection, iso ? TransformationStrategies.prefixFreeIso() : TransformationStrategies.prefixFreeUtf16() ), width ) ), resolverName ); else BinIO.storeObject( new URLMPHVirtualDocumentResolver( new ShiftAddXorSignedStringMap( collection.iterator(), new MWHCFunction<CharSequence>( collection, iso ? TransformationStrategies.iso() : TransformationStrategies.utf16() ), width ) ), resolverName ); LOGGER.debug( " done." );
@SuppressWarnings("unchecked") public long getLong( Object o ) { final CharSequence s = (CharSequence)o; final long index = function.getLong( s ); return checkSignature( s, index ) ? index : defRetValue; }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap( final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth ) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : ( 1L << width ) - 1; final int n = map.size(); signatures = LongArrayBitVector.getInstance().asLongBigList( signatureWidth ).length( n ); for( int i = 0; i < n; i++ ) { s = iterator.next(); signatures.set( map.getLong( s ), signature( s ) ); } if ( iterator.hasNext() ) throw new IllegalStateException( "Iterator provides more than " + n + " elements" ); }
if (jsapResult.getBoolean("sorted")) BinIO.storeObject(new URLMPHVirtualDocumentResolver(new ShiftAddXorSignedStringMap(collection.iterator(), new TwoStepsLcpMonotoneMinimalPerfectHashFunction.Builder<CharSequence>().keys(collection).transform(iso ? TransformationStrategies.prefixFreeIso() : TransformationStrategies.prefixFreeUtf16()).build(), width)), resolverName); else BinIO.storeObject(new URLMPHVirtualDocumentResolver(new ShiftAddXorSignedStringMap(collection.iterator(), new GOV3Function.Builder<CharSequence>().keys(collection).transform(iso ? TransformationStrategies.prefixFreeIso() : TransformationStrategies.prefixFreeUtf16()).build(), width)), resolverName); LOGGER.debug( " done." );