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


Java FastBufferedInputStream类代码示例

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


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

示例1: readMetadata

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public void readMetadata() throws IOException, ClassNotFoundException {
	final ObjectInputStream ois = new ObjectInputStream(new FastBufferedInputStream(new FileInputStream(new File(directory, "metadata"))));
	byteArrayDiskQueues.size = ois.readLong();
	byteArrayDiskQueues.appendPointer = ois.readLong();
	byteArrayDiskQueues.used = ois.readLong();
	byteArrayDiskQueues.allocated = ois.readLong();
	final int n = ois.readInt();
	byteArrayDiskQueues.buffers.size(n);
	byteArrayDiskQueues.files.size(n);
	final VisitStateSet schemeAuthority2VisitState = frontier.distributor.schemeAuthority2VisitState;
	byte[] schemeAuthority = new byte[1024];
	for(int i = ois.readInt(); i-- != 0;) {
		final int length = Util.readVByte(ois);
		if (schemeAuthority.length < length) schemeAuthority = new byte[length];
		ois.readFully(schemeAuthority, 0, length);
		final VisitState visitState = schemeAuthority2VisitState.get(schemeAuthority, 0, length);
		// This can happen if the serialization of the visit states has not been completed.
		if (visitState != null) byteArrayDiskQueues.key2QueueData.put(visitState, (QueueData)ois.readObject());
		else LOGGER.error("No visit state found for " + Util.toString(schemeAuthority));
	}

	ois.close();
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:24,代码来源:WorkbenchVirtualizer.java

示例2: main

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public static void main(String[] arg) throws IOException, JSAPException {
	final SimpleJSAP jsap = new SimpleJSAP(GZIPIndexer.class.getName(), "Computes and stores a quasi-succinct index for a compressed archive.",
			new Parameter[] {
				new UnflaggedOption("archive", JSAP.STRING_PARSER, JSAP.REQUIRED, "The name a GZIP's archive."),
				new UnflaggedOption("index", JSAP.STRING_PARSER, JSAP.REQUIRED, "The output (a serialized LongBigList of pointers to the records in the archive) filename."),
			}
	);

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

	final FastBufferedInputStream input = new FastBufferedInputStream(new FileInputStream(jsapResult.getString("archive")));
	ProgressLogger pl = new ProgressLogger(LOGGER, 1, TimeUnit.MINUTES, "records");
	pl.start("Scanning...");
	final EliasFanoMonotoneLongBigList list = new EliasFanoMonotoneLongBigList(index(input, pl));
	pl.done();
	BinIO.storeObject(list, jsapResult.getString("index"));
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:19,代码来源:GZIPIndexer.java

示例3: reverseGetEntry

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Test
   public void reverseGetEntry() throws IOException {
final LongBigArrayBigList pos = GZIPIndexer.index(new FileInputStream(ARCHIVE_PATH));
GZIPArchive.ReadEntry re;
FastBufferedInputStream fis = new FastBufferedInputStream(new FileInputStream(ARCHIVE_PATH));
GZIPArchiveReader gzar = new GZIPArchiveReader(fis);
byte[] actualMagic = new byte[EXPECTED_MAGIC.length];
for (int i = (int) pos.size64() - 1; i >= 0; i--) {
    gzar.position(pos.getLong(i));
    re = gzar.getEntry();
    if (re == null) break;
    LazyInflater lin = re.lazyInflater;
    InputStream in = lin.get();
    in.read(actualMagic);
    assertArrayEquals(EXPECTED_MAGIC, actualMagic);
    for (int j = 0; j < (i + 1) * 512; j++) in.read();
    lin.consume();

}
fis.close();
   }
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:22,代码来源:GZIPArchiveReaderTest.java

示例4: SequentialHyperBall

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的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

示例5: skip

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Override
public void skip(final FastBufferedInputStream is) throws IOException {
	int length = 0, b;

	while((b = is.read()) >= 0x80) {
		length |= b & 0x7F;
		length <<= 7;
	}
	if (b == -1) throw new EOFException();
	length |= b;

	final long actual = is.skip(length);
	if (actual != length) throw new IOException("Asked for " + length + " but got " + actual);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:15,代码来源:ByteSerializerDeserializer.java

示例6: skip

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Override
public void skip(final FastBufferedInputStream is) throws IOException {
	// Borrowed from it.unimi.dsi.lang.MutableString.
	int length = 0, b;

	for(;;) {
		if ((b = is.read()) < 0) throw new EOFException();
		if ((b & 0x80) == 0) break;
		length |= b & 0x7F;
		length <<= 7;
	}
	length |= b;

	for(int i = 0; i < length; i++) {
		b = is.read() & 0xFF;
		switch (b >> 4) {
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
			break;
		case 12:
		case 13:
			is.skip(1);
			break;
		case 14:
			is.skip(2);
			break;
		default:
			throw new UTFDataFormatException();
		}
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:38,代码来源:CharSequenceByteSerializerDeserializer.java

示例7: get

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public MutableString get(final int index, final FastBufferedInputStream fastBufferedInputStream, final ByteBuffer byteBuffer, final CharBuffer charBuffer, final CharsetDecoder decoder) {
	try {
		fastBufferedInputStream.position(borders.getLong(index));
		byteBuffer.clear();
		byteBuffer.limit(fastBufferedInputStream.readLine(byteBuffer.array(), terminators));
		charBuffer.clear();
		decoder.decode(byteBuffer, charBuffer, true);
		return new MutableString(charBuffer.array(), 0, charBuffer.position());
	}
	catch (final IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:14,代码来源:FileLinesList.java

示例8: FileLinesIterator

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
protected FileLinesIterator(final FileLinesList fileLinesList, final int index, final FastBufferedInputStream inputStream, final CharsetDecoder decoder, final ByteBuffer byteBuffer, final CharBuffer charBuffer) {
	this.inputStream = inputStream;
	this.decoder = decoder;
	this.byteBuffer = byteBuffer;
	this.charBuffer = charBuffer;
	this.fileLinesList = fileLinesList;
	pos = index;
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:9,代码来源:FileLinesList.java

示例9: listIterator

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Override
public FileLinesIterator listIterator(final int index) {
	try {
		return new FileLinesIterator(this, index, new FastBufferedInputStream(new FileInputStream(filename), bufferSize), charset.newDecoder(), ByteBuffer.wrap(new byte[byteBuffer.array().length]), CharBuffer.wrap(new char[charBuffer.array().length]));
	}
	catch (final FileNotFoundException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:10,代码来源:FileLinesList.java

示例10: get

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public MutableString get(final long index, final FastBufferedInputStream fastBufferedInputStream, final ByteBuffer byteBuffer, final CharBuffer charBuffer, final CharsetDecoder decoder) {
	try {
		fastBufferedInputStream.position(borders.getLong(index));
		byteBuffer.clear();
		byteBuffer.limit(fastBufferedInputStream.readLine(byteBuffer.array(), terminators));
		charBuffer.clear();
		decoder.decode(byteBuffer, charBuffer, true);
		return new MutableString(charBuffer.array(), 0, charBuffer.position());
	}
	catch (final IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:14,代码来源:FileLinesBigList.java

示例11: FileLinesIterator

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
protected FileLinesIterator(final FileLinesBigList fileLinesList, final long index, final FastBufferedInputStream inputStream, final CharsetDecoder decoder, final ByteBuffer byteBuffer, final CharBuffer charBuffer) {
	this.inputStream = inputStream;
	this.decoder = decoder;
	this.byteBuffer = byteBuffer;
	this.charBuffer = charBuffer;
	this.fileLinesList = fileLinesList;
	pos = index;
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:9,代码来源:FileLinesBigList.java

示例12: listIterator

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Override
public FileLinesIterator listIterator(final long index) {
	try {
		return new FileLinesIterator(this, index, new FastBufferedInputStream(new FileInputStream(filename), bufferSize), charset.newDecoder(), ByteBuffer.wrap(new byte[byteBuffer.array().length]), CharBuffer.wrap(new char[charBuffer.array().length]));
	}
	catch (final FileNotFoundException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:10,代码来源:FileLinesBigList.java

示例13: process

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public void process() throws IOException {
    try (FastBufferedInputStream stream = new FastBufferedInputStream(inputStreamFactory.get())) {
        Preconditions.checkArgument(phaser.getRegisteredParties() == 0);
        phaser.register();
        disruptor.start();
        RingBuffer<? extends TwoPhaseEvent> ringBuffer = disruptor.getRingBuffer();
        long cursor = ringBuffer.next();
        LineBytesBuffer buffer = ringBuffer.get(cursor).input();
        long lineNo = 0;
        ringBuffer.get(cursor).lineNo(lineNo);
        boolean needToSkipNext = skipFirst;
        while (buffer.readLineFrom(stream)) {
            if (needToSkipNext) {
                needToSkipNext = false;
                continue;
            }
            lineNo++;
            ringBuffer.publish(cursor);
            cursor = ringBuffer.next();
            buffer = ringBuffer.get(cursor).input();
            ringBuffer.get(cursor).lineNo(lineNo);
        }
        disruptor.shutdown();
        phaser.arriveAndAwaitAdvance();
        phaser.arriveAndDeregister();
    } finally {
        afterDisruptorProcessed();
    }
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:30,代码来源:BaseDisruptorRunner.java

示例14: readLineFrom

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
public boolean readLineFrom(FastBufferedInputStream stream) throws IOException {
    int start = 0, len;
    while ((len = stream.readLine(bytes, start, bytes.length - start)) == bytes.length - start) {
        start += len;
        bytes = ByteArrays.grow(bytes, bytes.length + 1024);
    }
    size = start + Math.max(len, 0);
    return !(size == 0 && len < 0);
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:10,代码来源:LineBytesBuffer.java

示例15: testReadLine

import it.unimi.dsi.fastutil.io.FastBufferedInputStream; //导入依赖的package包/类
@Test
public void testReadLine() throws Exception {
    Path fileExpected = Paths.get(tempDirectory.toString(), "expected");
    try (BufferedWriter writer = Files.newBufferedWriter(fileExpected, Charsets.US_ASCII)) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 2000; i++) {
            for (int j = 0; j < i; j++) {
                sb.append(j);
                sb.append(' ');
            }
            sb.append('\n');
        }
        for (int i = 2000; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                sb.append(j);
                sb.append(' ');
            }
            sb.append('\n');
            writer.write(sb.toString());
            sb.setLength(0);
        }
    }
    Path fileActual = Paths.get(tempDirectory.toString(), "actual");
    try (FastBufferedInputStream stream = new FastBufferedInputStream(Files.newInputStream(fileExpected))) {
        try (BufferedWriter writer = Files.newBufferedWriter(fileActual, Charsets.US_ASCII)) {
            LineBytesBuffer buffer = new LineBytesBuffer();
            LineBytesBuffer line = new LineBytesBuffer();
            while (buffer.readLineFrom(stream)) {
                buffer.drainTo(line);
                writer.write(line.toAsciiString());
                writer.newLine();
            }
        }
    }
    assertTrue(Files.readAllLines(fileExpected, Charsets.US_ASCII).equals(Files.readAllLines(fileActual, Charsets.US_ASCII)));
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:37,代码来源:LineBytesBufferTest.java


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