本文整理汇总了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);
}
示例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());
}
示例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 );
}
}
示例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);
}
示例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 );
}
}