当前位置: 首页>>代码示例>>Java>>正文


Java BinIO.loadObject方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.io.BinIO.loadObject方法的典型用法代码示例。如果您正苦于以下问题:Java BinIO.loadObject方法的具体用法?Java BinIO.loadObject怎么用?Java BinIO.loadObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.io.BinIO的用法示例。


在下文中一共展示了BinIO.loadObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
/**
 * Use with [hash] [queries]
 *
 * @param args input files
 * @throws Exception
 */
public static void main( String args[] ) throws Exception {
    double threshold = 0.001;
    QuasiSuccinctEntityHash hash = ( QuasiSuccinctEntityHash ) BinIO.loadObject( args[ 0 ] );
    BufferedReader lines = new BufferedReader( new FileReader( args[ 1 ] ) );
    FastEntityLinker fel = new FastEntityLinker( hash, new EmptyContext() );
    String q;
    int numberOfQueries = 0;
    long acumTime = 0;
    while( ( q = lines.readLine() ) != null ) {
        numberOfQueries++;
        if( q.length() == 0 ) continue;
        long time = -System.currentTimeMillis();
        try {
            fel.getResults( q, threshold );
        } catch( Exception e ) {

        }
        time += System.currentTimeMillis();
        acumTime += time;
        if( numberOfQueries % 10000 == 0 ) System.out.println( " #q = " + numberOfQueries + " " + ( ( double ) acumTime / numberOfQueries ) + " ms/q, time=" + acumTime );
    }
    lines.close();
    System.out.println( " #q = " + numberOfQueries + " " + ( ( double ) acumTime / numberOfQueries ) + " ms/q, time=" + acumTime );
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:31,代码来源:MeasureSpeed.java

示例2: testSingleton

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testSingleton() throws IOException, ClassNotFoundException {
	final String[] s = { "a" };
	ZFastTrie<String> zft = new ZFastTrie<>(Arrays.asList(s), TransformationStrategies.prefixFreeIso());
	for (int i = s.length; i-- != 0;)
		assertTrue(s[i], zft.contains(s[i]));
	final File temp = File.createTempFile(getClass().getSimpleName(), "test");
	temp.deleteOnExit();
	BinIO.storeObject(zft, temp);
	zft = (ZFastTrie<String>)BinIO.loadObject(temp);
	for (int i = s.length; i-- != 0;)
		assertTrue(zft.contains(s[i]));

	zft.remove("a");
	assertFalse(zft.contains("a"));

	final ObjectBidirectionalIterator<String> iterator = zft.iterator();
	assertFalse(iterator.hasNext());
	assertFalse(iterator.hasPrevious());
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:22,代码来源:ZFastTrieTest.java

示例3: testTriple

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testTriple() throws IOException, ClassNotFoundException {
	final String[] s = { "a", "b", "c" };
	ZFastTrie<String> zft = new ZFastTrie<>(Arrays.asList(s), TransformationStrategies.prefixFreeIso());
	for (int i = s.length; i-- != 0;)
		assertTrue(s[i], zft.contains(s[i]));
	final File temp = File.createTempFile(getClass().getSimpleName(), "test");
	temp.deleteOnExit();
	BinIO.storeObject(zft, temp);
	zft = (ZFastTrie<String>)BinIO.loadObject(temp);
	for (int i = s.length; i-- != 0;)
		assertTrue(zft.contains(s[i]));

	for (int i = s.length; i-- != 0;) {
		assertTrue(zft.remove(s[i]));
		assertFalse(zft.contains(s[i]));
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:20,代码来源:ZFastTrieTest.java

示例4: testUniformNumbers

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUniformNumbers() throws IOException, ClassNotFoundException {
	// TODO: restore working codec for size 1
	for (final int maxLength : new int[] { 2, 3, 4, 8, 16, 32, 64 }) {
		for (final int size : new int[] { 0, 1000, 10000 }) {
			final String[] s = new String[size];

			for (int i = s.length; i-- != 0;) s[i] = Integer.toString(i);
			final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
			final long[] v = new long[size];
			for (int i = 0; i < size; i++) v[i] = r.nextInt(maxLength);
			final Codec codec = new Codec.Huffman();
			GV4CompressedFunction<CharSequence> mph = new GV4CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(codec).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(v)).build();
			check(size, s, mph, v);
			final File temp = File.createTempFile(getClass().getSimpleName(), "test");
			temp.deleteOnExit();
			BinIO.storeObject(mph, temp);
			mph = (GV4CompressedFunction<CharSequence>) BinIO.loadObject(temp);

			check(size, s, mph, v);

		}
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:26,代码来源:GV4CompressedFunctionTest.java

示例5: testGeometricValuesLengthLimitedHuffman

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGeometricValuesLengthLimitedHuffman() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;)
			s[i] = Integer.toString(i);
		final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
		final long[] values = new long[size];
		for (int i = 0; i < size; i++) {
			values[i] = Integer.numberOfTrailingZeros(r.nextInt());
		}
		System.err.println(Arrays.toString(values));
		final Codec.Huffman cdc = new Codec.Huffman(5);
		GV4CompressedFunction<CharSequence> mph = new GV4CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(cdc).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV4CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}

}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:25,代码来源:GV4CompressedFunctionTest.java

示例6: testGeometricValuesUnary

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGeometricValuesUnary() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;)
			s[i] = Integer.toString(i);
		final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
		final long[] values = new long[size];
		for (int i = 0; i < size; i++) {
			values[i] = Integer.numberOfTrailingZeros(r.nextInt());
		}
		final Codec.Unary cdc = new Codec.Unary();
		GV4CompressedFunction<CharSequence> mph = new GV4CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(cdc).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV4CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}

}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:24,代码来源:GV4CompressedFunctionTest.java

示例7: testGeometricValuesLengthLimitedHuffman

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGeometricValuesLengthLimitedHuffman() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;)
			s[i] = Integer.toString(i);
		final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
		final long[] values = new long[size];
		for (int i = 0; i < size; i++) {
			values[i] = Integer.numberOfTrailingZeros(r.nextInt());
		}
		final Codec.Huffman cdc = new Codec.Huffman(5);
		GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(cdc).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}

}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:24,代码来源:GV3CompressedFunctionTest.java

示例8: testZipfianValuesGamma

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testZipfianValuesGamma() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;)
			s[i] = Integer.toString(i);
		final XoRoShiRo128PlusRandomGenerator r = new XoRoShiRo128PlusRandomGenerator(0);
		final long[] values = new long[size];
		final ZipfDistribution z = new org.apache.commons.math3.distribution.ZipfDistribution(r, 100000, 2);
		for (int i = 0; i < size; i++) {
			values[i] = z.sample();
		}
		final Codec.Gamma cdc = new Codec.Gamma();
		GV4CompressedFunction<CharSequence> mph = new GV4CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(cdc).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV4CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}

}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:25,代码来源:GV4CompressedFunctionTest.java

示例9: testExitNodeIsLeaf

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExitNodeIsLeaf() throws IOException, ClassNotFoundException {
	final String[] s = { "a", "aa", "aaa" };
	ZFastTrie<String> zft = new ZFastTrie<>(Arrays.asList(s), TransformationStrategies.prefixFreeIso());
	for (int i = s.length; i-- != 0;)
		assertTrue(s[i], zft.contains(s[i]));
	final File temp = File.createTempFile(getClass().getSimpleName(), "test");
	temp.deleteOnExit();
	BinIO.storeObject(zft, temp);
	zft = (ZFastTrie<String>)BinIO.loadObject(temp);
	for (int i = s.length; i-- != 0;)
		assertTrue(zft.contains(s[i]));

	for (int i = s.length; i-- != 0;) {
		assertTrue(zft.remove(s[i]));
		assertFalse(zft.contains(s[i]));
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:20,代码来源:ZFastTrieTest.java

示例10: testZipfianValuesGamma

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testZipfianValuesGamma() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;)
			s[i] = Integer.toString(i);
		final XoRoShiRo128PlusRandomGenerator r = new XoRoShiRo128PlusRandomGenerator(0);
		final long[] values = new long[size];
		final ZipfDistribution z = new org.apache.commons.math3.distribution.ZipfDistribution(r, 100000, 2);
		for (int i = 0; i < size; i++) {
			values[i] = z.sample();
		}
		final Codec.Gamma cdc = new Codec.Gamma();
		GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(cdc).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}

}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:25,代码来源:GV3CompressedFunctionTest.java

示例11: testGammaValues

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGammaValues() throws IOException, ClassNotFoundException {
	for (final int size : new int[] { 100, 1000, 10000 }) {
		final String[] s = new String[size];
		for (int i = s.length; i-- != 0;) s[i] = Integer.toString(i);
		final long[] values = new long[size];
		generateGamma(values);
		GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(new Codec.Huffman(20)).transform(TransformationStrategies.utf16()).values(LongArrayList.wrap(values)).build();
		check(size, s, mph, values);
		final File temp = File.createTempFile(getClass().getSimpleName(), "test");
		temp.deleteOnExit();
		BinIO.storeObject(mph, temp);
		mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);
		check(size, s, mph, values);
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:18,代码来源:GV3CompressedFunctionTest.java

示例12: dequeue

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
/** Dequeues an object from the queue in FIFO fashion. */
@SuppressWarnings("unchecked")
public synchronized T dequeue() throws IOException {
	final int length = byteDiskQueue.dequeueInt();
	fbaos.array = ByteArrays.grow(fbaos.array, length);
	byteDiskQueue.dequeue(fbaos.array, 0, length);
	size--;
	try {
		return (T)BinIO.loadObject(new FastByteArrayInputStream(fbaos.array, 0, length));
	}
	catch (final ClassNotFoundException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:15,代码来源:ObjectDiskQueue.java

示例13: setup

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
public void setup( Context context ) throws IOException {
    try {
        hash = ( QuasiSuccinctEntityHash ) BinIO.loadObject( "hash" );
        fel = new FastEntityLinker( hash, new EmptyContext() );
        entity2Id = EntityContextFastEntityLinker.readTypeMapping( "mapping" );

    } catch( ClassNotFoundException e ) {
        e.printStackTrace();
        System.exit( -1 );
    }
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:12,代码来源:RunFELOntheGrid.java

示例14: main

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
/**
 * Main method providing a simple command-line input linker
 *
 * @param args command line args
 * @throws Exception
 */
public static void main( String args[] ) throws Exception {
    double threshold = -30;
    QuasiSuccinctEntityHash hash = ( QuasiSuccinctEntityHash ) BinIO.loadObject( args[ 0 ] );
    final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
    String q;
    FastEntityLinker fel = new FastEntityLinker( hash, new EmptyContext() );
    for( ; ; ) {
        System.out.print( ">" );
        q = br.readLine();
        if( q == null ) {
            System.err.println();
            break; // CTRL-D
        }
        if( q.length() == 0 ) continue;
        String[] parts = q.split( "\t" );
        q = parts[ 0 ];
        String loc = "";
        if( parts.length > 1 ) {
            q = parts[ 0 ];
            loc = parts[ 1 ];
        }

        long time = -System.nanoTime();
        try {
            List<EntityResult> results = fel.getResultsGreedy( q, 50 );
            //List<EntityResult> results = fel.getResults( q, threshold );
            for( EntityResult er : results ) {
                System.out.println( q + "\t" + loc + "\t" + er.text + "\t" + er.score + "\t" + er.id );
            }
            time += System.nanoTime();
            System.out.println( "Time to rank and print the candidates:" + time / 1000000. + " ms" );
        } catch( Exception e ) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:43,代码来源:FastEntityLinker.java

示例15: testUniformBinary

import it.unimi.dsi.fastutil.io.BinIO; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUniformBinary() throws IOException, ClassNotFoundException {
	// TODO: restore working codec for size 1
	for (final int maxLength : new int[] { 2, 3, 4, 8, 16, 32, 64 }) {
		for (final int size : new int[] { 0, 1000, 10000 }) {
			final String[] s = new String[size];

			for (int i = s.length; i-- != 0;)
				s[i] = Integer.toString(i);
			final XoRoShiRo128PlusRandom r = new XoRoShiRo128PlusRandom(0);
			final long[] v = new long[size];
			for (int i = 0; i < size; i++) v[i] = r.nextInt(maxLength);
			final Codec codec = new Codec.Binary();
			final LongArrayList values = LongArrayList.wrap(v);
			GV3CompressedFunction<CharSequence> mph = new GV3CompressedFunction.Builder<CharSequence>().keys(Arrays.asList(s)).codec(codec).transform(TransformationStrategies.utf16()).values(values).build();
			check(size, s, mph, v);
			final File temp = File.createTempFile(getClass().getSimpleName(), "test");
			temp.deleteOnExit();
			BinIO.storeObject(mph, temp);
			mph = (GV3CompressedFunction<CharSequence>) BinIO.loadObject(temp);

			check(size, s, mph, v);

		}
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:28,代码来源:GV3CompressedFunctionTest.java


注:本文中的it.unimi.dsi.fastutil.io.BinIO.loadObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。