Java Code Examples for java.nio.IntBuffer#allocate()
The following examples show how to use
java.nio.IntBuffer#allocate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestBufferDirectSequentialNumberCellIndexByte.java From multiple-dimension-spread with Apache License 2.0 | 6 votes |
@Test public void T_byte_filter_6() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ByteObj( (byte) 10 ) ); dic.add( new ByteObj( (byte) 20 ) ); dic.add( new ByteObj( (byte) 30 ) ); dic.add( new ByteObj( (byte) 40 ) ); dic.add( new ByteObj( (byte) 50 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.GE , new ByteObj( (byte) 40 ) ); FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) ); assertEquals( result.size() , 40 ); for( int i = 0,n=0 ; n < 100 ; i+=2,n+=5 ){ assertEquals( result.get(i) , n+3 ); assertEquals( result.get(i+1) , n+4 ); } }
Example 2
Source File: DwGLSLShader.java From PixelFlow with MIT License | 6 votes |
public static void getShaderInfoLog(GL2ES2 gl, int shader_id, String info) { if(shader_id==-1) return; IntBuffer log_len = IntBuffer.allocate(1); gl.glGetShaderiv(shader_id, GL2ES2.GL_INFO_LOG_LENGTH, log_len); ByteBuffer buffer = ByteBuffer.allocate(log_len.get(0)); gl.glGetShaderInfoLog(shader_id, log_len.get(0), null, buffer); String log = Charset.forName("US-ASCII").decode(buffer).toString(); if( log.length() > 1 && log.charAt(0) != 0){ System.out.println(info); System.out.println(log); } }
Example 3
Source File: TestBufferDirectSequentialNumberCellIndexShort.java From yosegi with Apache License 2.0 | 6 votes |
@Test public void T_short_filter_7() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ShortObj( (short) 1000 ) ); dic.add( new ShortObj( (short) 2000 ) ); dic.add( new ShortObj( (short) 3000 ) ); dic.add( new ShortObj( (short) 4000 ) ); dic.add( new ShortObj( (short) 5000 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.SHORT , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.GE , new LongObj( Long.valueOf( Short.MAX_VALUE ) + (long)1 ) ); assertEquals( null , index.filter( filter , new boolean[100] ) ); }
Example 4
Source File: TestBufferDirectSequentialNumberCellIndexByte.java From yosegi with Apache License 2.0 | 6 votes |
@Test public void T_byte_filter_6() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ByteObj( (byte) 10 ) ); dic.add( new ByteObj( (byte) 20 ) ); dic.add( new ByteObj( (byte) 30 ) ); dic.add( new ByteObj( (byte) 40 ) ); dic.add( new ByteObj( (byte) 50 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.GE , new ByteObj( (byte) 40 ) ); FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) ); assertEquals( result.size() , 40 ); for( int i = 0,n=0 ; n < 100 ; i+=2,n+=5 ){ assertEquals( result.get(i) , n+3 ); assertEquals( result.get(i+1) , n+4 ); } }
Example 5
Source File: TestBufferDirectSequentialNumberCellIndexByte.java From multiple-dimension-spread with Apache License 2.0 | 6 votes |
@Test public void T_byte_filter_1() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ByteObj( (byte) 10 ) ); dic.add( new ByteObj( (byte) 20 ) ); dic.add( new ByteObj( (byte) 30 ) ); dic.add( new ByteObj( (byte) 40 ) ); dic.add( new ByteObj( (byte) 50 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.EQUAL , new ByteObj( (byte) 10 ) ); FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) ); assertEquals( result.size() , 20 ); for( int i = 0,n=0 ; n < 100 ; i++,n+=5 ){ assertEquals( result.get(i) , n ); } }
Example 6
Source File: TestBufferDirectSequentialNumberCellIndexShort.java From yosegi with Apache License 2.0 | 6 votes |
@Test public void T_short_filter_6() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ShortObj( (short) 1000 ) ); dic.add( new ShortObj( (short) 2000 ) ); dic.add( new ShortObj( (short) 3000 ) ); dic.add( new ShortObj( (short) 4000 ) ); dic.add( new ShortObj( (short) 5000 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.SHORT , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.GE , new ShortObj( (short) 4000 ) ); FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) ); assertEquals( result.size() , 40 ); for( int i = 0,n=0 ; n < 100 ; i+=2,n+=5 ){ assertEquals( result.get(i) , n+3 ); assertEquals( result.get(i+1) , n+4 ); } }
Example 7
Source File: TestBufferDirectSequentialNumberCellIndexByte.java From yosegi with Apache License 2.0 | 6 votes |
@Test public void T_byte_filter_1() throws IOException{ List<PrimitiveObject> dic = new ArrayList<PrimitiveObject>(); dic.add( new ByteObj( (byte) 10 ) ); dic.add( new ByteObj( (byte) 20 ) ); dic.add( new ByteObj( (byte) 30 ) ); dic.add( new ByteObj( (byte) 40 ) ); dic.add( new ByteObj( (byte) 50 ) ); IntBuffer buffer = IntBuffer.allocate( 100 ); for( int i = 0 ; i < 100 ; i++ ){ buffer.put( i % 5 ); } ICellIndex index = new BufferDirectSequentialNumberCellIndex( ColumnType.BYTE , new TestDicManager( dic ) , buffer ); IFilter filter = new NumberFilter( NumberFilterType.EQUAL , new ByteObj( (byte) 10 ) ); FilterdExpressionIndex result = new FilterdExpressionIndex( index.filter( filter , new boolean[100] ) ); assertEquals( result.size() , 20 ); for( int i = 0,n=0 ; n < 100 ; i++,n+=5 ){ assertEquals( result.get(i) , n ); } }
Example 8
Source File: UnsafeOptimizeDoubleColumnBinaryMaker.java From yosegi with Apache License 2.0 | 6 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length , ByteOrder order ) throws IOException { int size = length / Integer.BYTES; IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for ( int i = 0 ; i < size ; i++ ) { result.put( wrapBuffer.getInt() ); } result.position( 0 ); return result; }
Example 9
Source File: DoubleArrayTrie.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * Construct double array trie which is equivalent to input trie * * @param trie normal trie, which contains all dictionary words */ public void build(Trie trie) { ProgressLog.begin("building " + (compact ? "compact" : "sparse") + " trie"); baseBuffer = IntBuffer.allocate(BASE_CHECK_INITIAL_SIZE); baseBuffer.put(0, 1); checkBuffer = IntBuffer.allocate(BASE_CHECK_INITIAL_SIZE); tailBuffer = CharBuffer.allocate(TAIL_INITIAL_SIZE); add(-1, 0, trie.getRoot()); reportUtilizationRate(); ProgressLog.end(); }
Example 10
Source File: UnsafeOptimizeFloatColumnBinaryMaker.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Override public IntBuffer getIndexIntBuffer( final byte[] buffer , final int start , final int length , final ByteOrder order ) throws IOException{ int size = length / Byte.BYTES; IReadSupporter wrapBuffer = ByteBufferSupporterFactory.createReadSupporter( buffer , start , length , order ); IntBuffer result = IntBuffer.allocate( size ); for( int i = 0 ; i < size ; i++ ){ result.put( NumberToBinaryUtils.getUnsignedByteToInt( wrapBuffer.getByte() ) ); } result.position( 0 ); return result; }
Example 11
Source File: JnaUtils.java From djl with Apache License 2.0 | 5 votes |
public static String[] listSymbolNames(Pointer symbol) { IntBuffer size = IntBuffer.allocate(1); PointerByReference ref = new PointerByReference(); checkCall(LIB.NNSymbolListInputNames(symbol, 0, size, ref)); return toStringArray(ref, size.get()); }
Example 12
Source File: PointCloud.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
protected static IntBuffer allocateIntBuffer(int size) { if (USE_DIRECT_BUFFERS) { return allocateDirectIntBuffer(size); } else { return IntBuffer.allocate(size); } }
Example 13
Source File: OpusDecoder.java From ts3j with Apache License 2.0 | 5 votes |
public OpusDecoder(int sampleRate, int frameSize, int channels) { this.channels = channels; this.sampleRate = sampleRate; this.frameSize = frameSize; IntBuffer errorBuffer = IntBuffer.allocate(1); decoder = Opus.INSTANCE.opus_decoder_create( sampleRate, channels, errorBuffer ); OpusUtil.checkError("opus_decoder_create", errorBuffer.get()); }
Example 14
Source File: DwGLSLProgram.java From PixelFlow with MIT License | 5 votes |
public static void getProgramValidateStatus(GL2ES2 gl, int program_id) { if(program_id==-1) return; IntBuffer log_len = IntBuffer.allocate(1); gl.glGetProgramiv(program_id, GL2ES2.GL_VALIDATE_STATUS, log_len); ByteBuffer buffer = ByteBuffer.allocate(log_len.get(0)); gl.glGetProgramInfoLog(program_id, log_len.get(0), null, buffer); String log = Charset.forName("US-ASCII").decode(buffer).toString(); if( log.length() > 1 && log.charAt(0) != 0){ System.out.println(log); } }
Example 15
Source File: GeoPathFinding.java From L2jBrasil with GNU General Public License v3.0 | 5 votes |
private void LoadPathNodeFile(byte rx,byte ry) { String fname = "./data/pathnode/"+rx+"_"+ry+".pn"; short regionoffset = getRegionOffset(rx,ry); _log.info("PathFinding Engine: - Loading: "+fname+" -> region offset: "+regionoffset+"X: "+rx+" Y: "+ry); File Pn = new File(fname); int node = 0,size, index = 0; try { // Create a read-only memory-mapped file FileChannel roChannel = new RandomAccessFile(Pn, "r").getChannel(); size = (int)roChannel.size(); MappedByteBuffer nodes; if (Config.FORCE_GEODATA) //Force O/S to Loads this buffer's content into physical memory. //it is not guarantee, because the underlying operating system may have paged out some of the buffer's data nodes = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size).load(); else nodes = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size); // Indexing pathnode files, so we will know where each block starts IntBuffer indexs = IntBuffer.allocate(65536); while(node < 65536) { byte layer = nodes.get(index); indexs.put(node, index); node++; index += layer*10+1; } _pathNodesIndex.put(regionoffset, indexs); _pathNodes.put(regionoffset, nodes); } catch (Exception e) { e.printStackTrace(); _log.warning("Failed to Load PathNode File: "+fname+"\n"); } }
Example 16
Source File: AndroidGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public int glGetQueryObjectiv(int query, int pname) { IntBuffer buff = IntBuffer.allocate(1); GLES30.glGetQueryiv(query, pname, buff); return buff.get(0); }
Example 17
Source File: PluggableJSObjectTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public BufferObject(final int size) { buf = IntBuffer.allocate(size); }
Example 18
Source File: IntTensorTypeSupport.java From datacollector with Apache License 2.0 | 4 votes |
@Override public IntBuffer allocateBuffer(long[] shape) { return IntBuffer.allocate(calculateCapacityForShape(shape)); }
Example 19
Source File: GPU.java From DeviceInfo with Apache License 2.0 | 4 votes |
public synchronized static int[] glGetIntegerv(int value, int size) { final IntBuffer buffer = IntBuffer.allocate(size); GLES10.glGetIntegerv(value, buffer); return buffer.array(); }
Example 20
Source File: PluggableJSObjectTest.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
public BufferObject(final int size) { buf = IntBuffer.allocate(size); }