當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBigArrays類代碼示例

本文整理匯總了Java中it.unimi.dsi.fastutil.bytes.ByteBigArrays的典型用法代碼示例。如果您正苦於以下問題:Java ByteBigArrays類的具體用法?Java ByteBigArrays怎麽用?Java ByteBigArrays使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ByteBigArrays類屬於it.unimi.dsi.fastutil.bytes包,在下文中一共展示了ByteBigArrays類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: putRevision

import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入依賴的package包/類
@Override
public void putRevision(DbRevision dbRevision) {
	TagDownloaderRevisionData data =
			new TagDownloaderRevisionData(dbRevision, tagFactory);
	
	
	byte[] bytes = data.getByteArray();
	ByteBigArrays.copyToBig(bytes, 0, bigByteArray,
			dbRevision.getRevisionId() * (long) TagDownloaderRevisionData.ELEMENT_SIZE,
			bytes.length);
	
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:13,代碼來源:TagDownloaderMemoryDataStore.java

示例2: getRevision

import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入依賴的package包/類
@Override
public DbRevision getRevision(long revisionId) {
	byte[] bytes = new byte[TagDownloaderRevisionData.ELEMENT_SIZE];
	if (bigByteArray != null) {
		ByteBigArrays.copyFromBig(bigByteArray,
				(long) revisionId * (long) TagDownloaderRevisionData.ELEMENT_SIZE,
				bytes, 0, bytes.length);
	}
	
	TagDownloaderRevisionData data =
			new TagDownloaderRevisionData(bytes, tagFactory);
	
	return new DbRevisionImpl(revisionId, data.getSha1(), data.getTags());
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:15,代碼來源:TagDownloaderMemoryDataStore.java

示例3: testBigBytes

import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入依賴的package包/類
public void testBigBytes( byte[][] a ) throws IOException {
	final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
	file.deleteOnExit();
	final long length = ByteBigArrays.length( a );
	final byte[][] aShifted = ByteBigArrays.newBigArray( length + 1 );
	ByteBigArrays.copy( a, 0, aShifted, 1, length );
	
	for( int i = 0; i < 4; i++ ) {
		file.delete();
		switch(i) {
		case 0: TextIO.storeBytes( a, file ); break;
		case 1: TextIO.storeBytes( a, new PrintStream( file ) ); break;
		case 2: TextIO.storeBytes( aShifted, 1, length, file ); break;
		case 3: TextIO.storeBytes( aShifted, 1, length, new PrintStream( file ) ); break;
		}

		byte[][] b = ByteBigArrays.newBigArray( length );
		assertEquals( length, TextIO.loadBytes( file, b ) );
		assertArrayEquals( a, b );
		assertEquals( length, TextIO.loadBytes( file, b, 0, length ) );
		assertArrayEquals( a, b );

		assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), b ) );
		assertArrayEquals( a, b );
		assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), b, 0, length ) );
		assertArrayEquals( a, b );

		byte[][] c = ByteBigArrays.newBigArray( length + 1 );
		assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), c ) );
		assertEquals( 0, ByteBigArrays.get( c, length ) );
		ByteBigArrays.copy( c, 0, b, 0, b.length );
		assertArrayEquals( a, b );
		assertEquals( length, TextIO.loadBytes( new BufferedReader( new FileReader( file ) ), c, 1, length ) );
		assertEquals( 0, ByteBigArrays.get( c, 0 ) );
		ByteBigArrays.copy( c, 1, b, 0, b.length );
		assertArrayEquals( a, b );
	}

}
 
開發者ID:phishman3579,項目名稱:fastutil,代碼行數:40,代碼來源:TestIOTest.java

示例4: clear

import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入依賴的package包/類
@Override
public void clear() throws Exception {
	bigByteArray = null;
	bigByteArray = ByteBigArrays.ensureCapacity(new byte[0][0],
			(long) TagDownloaderRevisionData.ELEMENT_SIZE * (long) maxRevisionId);		
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:7,代碼來源:TagDownloaderMemoryDataStore.java

示例5: testBigBytes

import it.unimi.dsi.fastutil.bytes.ByteBigArrays; //導入依賴的package包/類
public void testBigBytes( byte[][] a ) throws IOException {
	final File file = File.createTempFile( getClass().getSimpleName(), "dump" );
	file.deleteOnExit();
	final long length = ByteBigArrays.length( a );
	final byte[][] aShifted = ByteBigArrays.newBigArray( length + 1 );
	ByteBigArrays.copy( a, 0, aShifted, 1, length );
	
	for( int i = 0; i < 6; i++ ) {
		file.delete();
		switch(i) {
		case 0: BinIO.storeBytes( a, file ); break;
		case 1: BinIO.storeBytes( a, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
		case 2: BinIO.storeBytes( a, new FileOutputStream( file ) ); break;
		case 3: BinIO.storeBytes( aShifted, 1, length, file ); break;
		case 4: BinIO.storeBytes( aShifted, 1, length, (DataOutput)new DataOutputStream( new FileOutputStream( file ) ) ); break;
		case 5: BinIO.storeBytes( aShifted, 1, length, new FileOutputStream( file ) ); break;
		}
		assertArrayEquals( a, BinIO.loadBytesBig( file ) );

		byte[][] b = ByteBigArrays.newBigArray( length );
		assertEquals( length, BinIO.loadBytes( file, b ) );
		assertArrayEquals( a, b );
		assertEquals( length, BinIO.loadBytes( file, b, 0, length ) );
		assertArrayEquals( a, b );

		assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b ) );
		assertArrayEquals( a, b );
		assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), b, 0, length ) );
		assertArrayEquals( a, b );

		byte[][] c = ByteBigArrays.newBigArray( length + 1 );
		assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c ) );
		assertEquals( 0, ByteBigArrays.get( c, length ) );
		ByteBigArrays.copy( c, 0, b, 0, b.length );
		assertArrayEquals( a, b );
		assertEquals( length, BinIO.loadBytes( new FileInputStream( file ), c, 1, length ) );
		assertEquals( 0, ByteBigArrays.get( c, 0 ) );
		ByteBigArrays.copy( c, 1, b, 0, b.length );
		assertArrayEquals( a, b );

		ByteBigArrays.set( c, length, (byte)0 );
		assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c ) );
		assertEquals( 0, ByteBigArrays.get( c, length ) );
		ByteBigArrays.copy( c, 0, b, 0, b.length );
		assertArrayEquals( a, b );
		
		assertEquals( length, BinIO.loadBytes( (DataInput)new DataInputStream( new FileInputStream( file ) ), c, 1, length ) );
		assertEquals( 0, ByteBigArrays.get( c, 0 ) );
		ByteBigArrays.copy( c, 1, b, 0, b.length );
		assertArrayEquals( a, b );
	}

}
 
開發者ID:phishman3579,項目名稱:fastutil,代碼行數:54,代碼來源:BinIOTest.java


注:本文中的it.unimi.dsi.fastutil.bytes.ByteBigArrays類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。