• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FastBufferedOutputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FastBufferedOutputStream类属于it.unimi.dsi.fastutil.io包,在下文中一共展示了FastBufferedOutputStream类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public void run() {
    while (isRunning) {
        try {
            if (sock == null || !sock.isBound()) {
                System.out.println("Creating new server socket...");
                sock = new ServerSocket(masterToSlavePort);
            }

            Socket s = sock.accept();
            OutputStream os = new FastBufferedOutputStream(s.getOutputStream());

            while(isRunning) {
                ServiceMessage m = queue.take();

                os.write(m.serializedTransaction);
            }
        } catch(Exception e) {
            System.err.println(e);
        }
    }
}
 
开发者ID:kriskalish,项目名称:hologram,代码行数:22,代码来源:TcpSenderConnector.java


示例2: sendToMaster

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
protected void sendToMaster(Transaction t) throws Exception {
    if(sock == null || !sock.isConnected()) {
        sock = new Socket(serverHost, serverPort);
        //oos = new ObjectOutputStream(sock.getOutputStream());
        //o = new Output(new BufferedOutputStream(sock.getOutputStream()));

        p = mp.createPacker(new FastBufferedOutputStream(sock.getOutputStream()));
    }


    p.write(t);
    //oos.writeObject(t);
    //k.writeObject(o, t);
    p.
    p.write(t);
}
 
开发者ID:kriskalish,项目名称:hologram,代码行数:17,代码来源:TcpConnector.java


示例3: SequentialHyperBall

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
/** Creates a new approximator for the neighbourhood function.
 * 
 * @param g the graph whosee neighbourhood function you want to compute.
 * @param log2m the logarithm of the number of registers per counter.
 * @param pl a progress logger, or <code>null</code>.
 */
public SequentialHyperBall( final ImmutableGraph g, final int log2m, final ProgressLogger pl, final long seed ) throws IOException {
	super( g.numNodes(), g.numNodes(), ensureEnoughRegisters( log2m ), seed );
	
	if ( pl != null ) pl.logger().info( "Precision: " + Util.format( 100 * HyperLogLogCounterArray.relativeStandardDeviation( log2m ) ) + "% (" + m  + " registers/counter, " + registerSize + " bits/counter)" );

	this.g = g;
	this.pl = pl;
	
	numNodes = g.numNodes();
	squareNumNodes = (double)numNodes * numNodes;

	tempFile = File.createTempFile( SequentialHyperBall.class.getName(), "temp" );
	tempFile.deleteOnExit();
	dos = new DataOutputStream( new FastBufferedOutputStream( fos = new FileOutputStream( tempFile ) ) );
	fbis = new FastBufferedInputStream( new FileInputStream( tempFile ) );
	
	accumulator = new long[ counterLongwords ];
	mask = new long[ counterLongwords ];
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:26,代码来源:SequentialHyperBall.java


示例4: Bucket

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
/** Creates a bucket.
 *
 * @param bucketSize the size (in items) of the bucket.
 * @param bufferSize the size (in bytes) of the buffer to be used for the output stream.
 * @param sieveDir the directory where the auxiliary file should be opened.
 * @param serializer the serializer to be used for storing the keys.
 * @throws IOException
 */
public Bucket(final int bucketSize, final int bufferSize, final File sieveDir, final ByteSerializerDeserializer<K> serializer) throws IOException {
	this.serializer = serializer;
	this.ioBuffer = new byte[bufferSize];
	// buffer
	items = 0;
	size = bucketSize;
	buffer = new long[bucketSize];
	// aux
	auxFile = new File(sieveDir, "aux");
	aux = new FastBufferedOutputStream(new FileOutputStream(auxFile), ioBuffer);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:20,代码来源:MercatorSieve.java


示例5: writeRecords

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@SuppressWarnings("resource")
public static int[] writeRecords(final String path, final int numRecords, final WarcRecord[] randomRecords, final int parallel) throws IOException, InterruptedException {
	final ProgressLogger pl = new ProgressLogger(LOGGER, "records");
	if (parallel <= 1) pl.expectedUpdates = numRecords;
	final ProgressLogger plb = new ProgressLogger(LOGGER, "KB");
	final CountingOutputStream cos = new CountingOutputStream(new FastBufferedOutputStream(new FileOutputStream (path)));
	final WarcWriter ww;
	if (parallel == 0) {
		ww = new UncompressedWarcWriter(cos);
		pl.start("Writing records…");
	} else if (parallel == 1) {
		ww = new CompressedWarcWriter(cos);
		pl.start("Writing records (compressed)…");
	} else {
		ww = null;
		pl.start("SHOULD NOT HAPPEN");
		throw new IllegalStateException();
	}
	plb.start();
	long written = 0;
	final int[] position = new int[numRecords];
	for (int i = 0; i < numRecords; i++) {
		final int pos = RandomTestMocks.RNG.nextInt(randomRecords.length);
		position[i] = pos;
		ww.write(randomRecords[pos]);
		if (parallel <= 0) {
			pl.lightUpdate();
			plb.update((cos.getCount() - written) / 1024);
		}
		written = cos.getCount();
	}
	ww.close();
	pl.done(numRecords);
	plb.done(cos.getCount());
	return position;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:37,代码来源:RandomReadWritesTest.java


示例6: delegateOutputFormat

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@Provides
@Named("delegate")
@Singleton
OutputFormat delegateOutputFormat() throws IOException {
    if (options.predictions() == null) {
        return new NullOutputFormat();
    } else if (options.predictions().equals("/dev/stdout")) {
        return new PrintStreamOutputFormat().outputStream(System.out);
    }
    return new PrintStreamOutputFormat()
            .outputStream(new PrintStream(new FastBufferedOutputStream(
                    Files.newOutputStream(Paths.get(options.predictions())))));
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:14,代码来源:AbstractParallelModule.java


示例7: onStart

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@Override
public void onStart()
{
    System.out.println("starting...");


    try {
        if (sock == null || !sock.isBound()) {
            System.out.println("Creating new server socket...");
            sock = new ServerSocket(masterToSlavePort);
        }

        Socket s = sock.accept();
        os = new FastBufferedOutputStream(s.getOutputStream());
        mp = new MessagePack();

    } catch (Exception e ) {
        e.printStackTrace();
    }

}
 
开发者ID:kriskalish,项目名称:hologram,代码行数:22,代码来源:TransactionLog2.java


示例8: store

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
/** Stores an arc-list ASCII graph with a given shift.
 * 
 * @param graph a graph to be stored.
 * @param basename the name of the output file.
 * @param shift a shift that will be added to each node; note that is the <em>opposite</em> of the shift that will
 * have to be used to load the generated file.
 */
	
public static void store( final ImmutableGraph graph, final CharSequence basename, final int shift ) throws IOException {
	final PrintStream ps = new PrintStream( new FastBufferedOutputStream( new FileOutputStream( basename.toString() ) ), false, Charsets.US_ASCII.toString() );
	int d, s;
	int[] successor;
	for ( NodeIterator nodeIterator = graph.nodeIterator(); nodeIterator.hasNext(); ) {
		s = nodeIterator.nextInt();
		d = nodeIterator.outdegree();
		successor = nodeIterator.successorArray();
		for( int i = 0; i < d; i++ ) ps.println( ( s + shift ) + "\t" + ( successor[ i ] + shift ) );
	}
	ps.close();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:21,代码来源:ArcListASCIIGraph.java


示例9: store

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public static void store( ImmutableGraph graph, final int shift, CharSequence basename ) throws IOException {
	final PrintStream ps = new PrintStream( new FastBufferedOutputStream( new FileOutputStream( basename + ASCII_GRAPH_EXTENSION ) ), false, Charsets.US_ASCII.toString() );
	int n = graph.numNodes();
	LazyIntIterator successors;

	ps.println( n );
	for ( NodeIterator nodeIterator = graph.nodeIterator(); nodeIterator.hasNext(); ) {
		nodeIterator.nextInt();
		int d = nodeIterator.outdegree();
		successors = nodeIterator.successors();
		while ( d-- != 0 ) ps.print( ( successors.nextInt() + shift ) + " " );
		ps.println();
	}
	ps.close();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:16,代码来源:ASCIIGraph.java


示例10: createFile

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
protected String createFile(final File file) throws IOException {
	close();
    this.f = file;
    FileOutputStream fos = new FileOutputStream(this.f);
    this.countOut = new MiserOutputStream(new FastBufferedOutputStream(fos),settings.getFrequentFlushes());
    this.out = this.countOut; 
    logger.fine("Opened " + this.f.getAbsolutePath());
    return this.f.getName();
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:10,代码来源:WriterPoolMember.java


示例11: ensureDiskStream

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
protected OutputStream ensureDiskStream() throws FileNotFoundException {
    if (this.diskStream == null) {
        FileOutputStream fis = new FileOutputStream(this.backingFilename);
        this.diskStream = new FastBufferedOutputStream(fis);
    }
    return this.diskStream;
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:8,代码来源:RecordingOutputStream.java


示例12: close

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@Override
public void close() throws IOException {
	final ObjectOutputStream oos = new ObjectOutputStream(new FastBufferedOutputStream(new FileOutputStream(new File(directory, "metadata"))));
	byteArrayDiskQueues.close();
	writeMetadata(oos);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:7,代码来源:WorkbenchVirtualizer.java


示例13: prepareToAppend

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@Override
public synchronized void prepareToAppend() throws IOException {
	if (closed) throw new IllegalStateException();
	appendSize = 0;
	output = new DataOutputStream(new FastBufferedOutputStream(new FileOutputStream(new File(baseName + outputIndex))));
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:7,代码来源:AbstractSieve.java


示例14: main

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public static void main(String arg[]) throws IOException, InterruptedException, JSAPException {

	SimpleJSAP jsap = new SimpleJSAP(WarcCompressor.class.getName(),
		"Given a store uncompressed, write a compressed store.",
		new Parameter[] { new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o', "output", "The output filename  (- for stdout)."),
		new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."),
	});

	JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in;

	final WarcReader reader = new UncompressedWarcReader(in);
	final ProgressLogger pl = new ProgressLogger(LOGGER, 1, TimeUnit.MINUTES, "records");
	final String output = jsapResult.getString("output");

	PrintStream out = "-".equals(output) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output)), false, "UTF-8");
	final WarcWriter writer = new CompressedWarcWriter(out);

	pl.itemsName = "records";
	pl.displayFreeMemory = true;
	pl.displayLocalSpeed = true;
	pl.start("Scanning...");

	for (long storePosition = 0;; storePosition++) {
	    LOGGER.trace("STOREPOSITION " + storePosition);
	    WarcRecord record = null;
	    try {
		record = reader.read();
	    } catch (Exception e) {
		LOGGER.error("Exception while reading record " + storePosition + " ");
		LOGGER.error(e.getMessage());
		e.printStackTrace();
		continue;
	    }
	    if (record == null)
		break;
	    writer.write(record);
	    pl.lightUpdate();
	}
	pl.done();
	writer.close();
    }
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:45,代码来源:WarcCompressor.java


示例15: main

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public static void main(final String[] arg) throws Exception {
	final SimpleJSAP jsap = new SimpleJSAP(ParallelFilteredProcessorRunner.class.getName(), "Processes a store.",
			new Parameter[] {
			new FlaggedOption("filter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A WarcRecord filter that recods must pass in order to be processed."),
	 		new FlaggedOption("processor", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'p', "processor", "A processor to be applied to data.").setAllowMultipleDeclarations(true),
		 	new FlaggedOption("writer", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'w', "writer", "A writer to be applied to the results.").setAllowMultipleDeclarations(true),
			new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output", "The output filename  (- for stdout).").setAllowMultipleDeclarations(true),
			new FlaggedOption("threads", JSAP.INTSIZE_PARSER, Integer.toString(Runtime.getRuntime().availableProcessors()), JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used."),
			new Switch("sequential", 'S', "sequential"),
			new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."),
	});

	final JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final String filterSpec = jsapResult.getString("filter");
	final Filter<WarcRecord> filter;
	if (filterSpec != null) {
		final FilterParser<WarcRecord> parser = new FilterParser<>(WarcRecord.class);
		filter = parser.parse(filterSpec);
	} else
		filter = null;
	final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in;
	final ParallelFilteredProcessorRunner parallelFilteredProcessorRunner = new ParallelFilteredProcessorRunner(in, filter);

	final String[] processor =  jsapResult.getStringArray("processor");
	final String[] writer =  jsapResult.getStringArray("writer");
	final String[] output =  jsapResult.getStringArray("output");
	if (processor.length != writer.length) throw new IllegalArgumentException("You must specify the same number or processors and writers");
	if (output.length != writer.length) throw new IllegalArgumentException("You must specify the same number or output specifications and writers");

	final String[] packages = new String[] { ParallelFilteredProcessorRunner.class.getPackage().getName() };
	final PrintStream[] ops = new PrintStream[processor.length];
	for (int i = 0; i < processor.length; i++) {
		ops[i] = "-".equals(output[i]) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output[i])), false, "UTF-8");
		// TODO: these casts to SOMETHING<Object> are necessary for compilation under Eclipse. Check in the future.
		parallelFilteredProcessorRunner.add((Processor<Object>)ObjectParser.fromSpec(processor[i], Processor.class, packages, new String[] { "getInstance" }),
				(Writer<Object>)ObjectParser.fromSpec(writer[i], Writer.class,  packages, new String[] { "getInstance" }),
				ops[i]);
	}

	if (jsapResult.userSpecified("sequential")) parallelFilteredProcessorRunner.runSequentially();
	else parallelFilteredProcessorRunner.run(jsapResult.getInt("threads"));

	for (int i = 0; i < processor.length; i++) ops[i].close();

}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:48,代码来源:ParallelFilteredProcessorRunner.java


示例16: main

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public static void main(final String[] arg) throws JSAPException, IOException {

		final SimpleJSAP jsap = new SimpleJSAP(GenerateRandom32BitStrings.class.getName(), "Generates a list of sorted 32-bit random strings using only characters in the ISO-8859-1 printable range [32..256).",
				new Parameter[] {
					new FlaggedOption("gap", JSAP.INTSIZE_PARSER, "1", JSAP.NOT_REQUIRED, 'g', "gap", "Impose a minimum gap."),
					new UnflaggedOption("n", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The number of strings (too small values might cause overflow)."),
					new UnflaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The output file.")
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final int n = jsapResult.getInt("n");
		final String output = jsapResult.getString("output");
		final int gap = jsapResult.getInt("gap");

		final RandomGenerator r = new XoRoShiRo128PlusRandomGenerator();

		final ProgressLogger pl = new ProgressLogger(LOGGER);
		pl.expectedUpdates = n;
		pl.start("Generating... ");

		double l = 0, t;
		final double limit = Math.pow(224, 4);
		final int incr = (int)Math.floor(1.99 * (limit / n)) - 1;

		LOGGER.info("Increment: " + incr);

		@SuppressWarnings("resource")
		final FastBufferedOutputStream fbs = new FastBufferedOutputStream(new FileOutputStream(output));
		final int[] b = new int[4];

		for(int i = 0; i < n; i++) {
			t = (l += (r.nextInt(incr) + gap));
			if (l >= limit) throw new AssertionError(Integer.toString(i));
			for(int j = 4; j-- != 0;) {
				b[j] = (int)(t % 224 + 32);
				t = Math.floor(t / 224);
			}

			for(int j = 0; j < 4; j++) fbs.write(b[j]);
			fbs.write(10);

			pl.lightUpdate();
		}


		pl.done();
		fbs.close();

		LOGGER.info("Last/limit: " + (l / limit));
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:53,代码来源:GenerateRandom32BitStrings.java


示例17: saveModel

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
public static void saveModel(FtrlProximalModel model, Path output) throws IOException {
    try (ObjectOutputStream os = new ObjectOutputStream(new FastBufferedOutputStream(Files.newOutputStream(output)))) {
        os.writeObject(model);
    }
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:6,代码来源:FtrlProximalModel.java


示例18: configure

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; //导入依赖的package包/类
@Override
protected void configure() {
    ThrowingProviderBinder.forModule(this);
    bindConstant().annotatedWith(Names.named("testOnly")).to(options.testOnly());
    bindConstant().annotatedWith(Names.named("skipFirst")).to(options.skipFirst());
    bindConstant().annotatedWith(Names.named("percentsBinningStep")).to(0.01);
    switch (options.format()) {
        case vw:
            bind(InputFormat.class).to(VowpalWabbitFormat.class);
            break;
        case csv:
            ColumnsMask columnsMask = new ColumnsMask(options.csvMask());
            bindConstant().annotatedWith(Names.named("csvDelimiter")).to(options.csvDelimiter());
            bind(new TypeLiteral<ColumnsMask>() {
            }).annotatedWith(Names.named("csvMask")).toInstance(columnsMask);
            bind(InputFormat.class).to(CSVFormat.class);
            break;
        case binary:
            bind(InputFormat.class).to(BinaryInputFormat.class);
            break;
        default:
            throw new IllegalArgumentException(options.format().toString());
    }
    bind(FirstPassRunner.class);
    bind(SecondPassRunner.class);
    bind(FeatureEngineeringRunner.class);
    bind(Phaser.class).asEagerSingleton();
    bind(FeaturesProcessor.class);
    try {
        bind(new TypeLiteral<Supplier<InputStream>>() {}).toInstance(this::openInputFile);
        bind(FastBufferedOutputStream.class).toInstance(new FastBufferedOutputStream(
                Files.newOutputStream(Paths.get(options.predictions()))));

    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
    bind(NumericalFeaturesStatistics.class).asEagerSingleton();
    bind(new TypeLiteral<WorkHandler<TwoPhaseEvent<Void>>>() {
    })
            .to(StatisticsWorkHandler.class);
    bind(new TypeLiteral<WorkHandler<TwoPhaseEvent<SparseItem>>>() {
    })
            .to(BinningWorkHandler.class);
    bind(new TypeLiteral<EventHandler<TwoPhaseEvent<SparseItem>>>() {})
            .to(OutputWriterEventHandler.class);
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:47,代码来源:FeatureEngineeringModule.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Startup类代码示例发布时间:2022-05-22
下一篇:
Java RepositorySettings类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap