Examples of asIntBuffer()


Examples of java.nio.ByteBuffer.asIntBuffer()

                }
                if (spos < origpostings.length) {
                    System.arraycopy(origpostings, spos, newpostings, dpos, origpostings.length - spos);
                }
                ByteBuffer bb = ByteBuffer.allocate(newpostings.length * 4);
                bb.asIntBuffer().put(newpostings);
                redis.set(key, bb.array());
            }
        } catch (RedisException e) {
            throw new IOException(e);
        }
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

        ByteBuffer b = ByteBuffer.allocateDirect(100);
        assertTrue(b.isDirect());
        assertView("duplicate", b, b.duplicate(), 1);
        assertView("char view", b, b.asCharBuffer(), 2);
        assertView("short view", b, b.asShortBuffer(), 2);
        assertView("int view", b, b.asIntBuffer(), 4);
        assertView("float view", b, b.asFloatBuffer(), 4);
        assertView("double view", b, b.asDoubleBuffer(), 8);
        assertView("long view", b, b.asLongBuffer(), 8);
    }
}
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

   * @param data - the integer array with the data.
   * @return An equivalent byte array.
   */
  private static byte[] toByteArray(int[] data) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4);       
        IntBuffer intBuffer = byteBuffer.asIntBuffer();
       
        intBuffer.put(data);
        return byteBuffer.array();
  }
 
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

        }
    }
   
    public void testDirectIntBufferArgument() {
        ByteBuffer buf  = ByteBuffer.allocateDirect(1024*4).order(ByteOrder.nativeOrder());
        IntBuffer intBuf = buf.asIntBuffer();
        final int MAGIC = 0xABEDCF23;
        lib.fillInt32Buffer(intBuf, 1024, MAGIC);
        for (int i=0;i < intBuf.capacity();i++) {
            assertEquals("Bad value at index " + i, MAGIC, intBuf.get(i));
        }
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

    }
    public void testIntBufferPut() {
        final int MAGIC = 0xABEDCF23;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        IntBuffer ib = buf.asIntBuffer();
        ib.put(MAGIC).flip();
        assertEquals("Int not written to memory", MAGIC,
                m.getInt(0));
    }
    public void testLongBufferPut() {
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

    }
    public void testIntBufferGet() {
        final int MAGIC = 0xABEDCF23;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        IntBuffer ib = buf.asIntBuffer();
        m.setInt(0, MAGIC);
        assertEquals("Int not read from memory", MAGIC,
                ib.get(0));
    }
    public void testLongBufferGet() {
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

        assertEquals("ByteBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b));
        assertEquals("ShortBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asShortBuffer()));
        assertEquals("IntBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asIntBuffer()));
        assertEquals("LongBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asLongBuffer()));
        assertEquals("FloatBuffer Pointer does not match",
                     p, Native.getDirectBufferPointer(b.asFloatBuffer()));
        assertEquals("DoubleBuffer Pointer does not match",
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

      uima[1] = 73; // I
      uima[2] = 77; // M
      uima[3] = 65; // A

      ByteBuffer buf = ByteBuffer.wrap(uima);
      int key = buf.asIntBuffer().get();

      int version = 1;
      dos.writeInt(key);
      dos.writeInt(version);
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

    */
   public int readInt() throws IOException
   {
      ByteBuffer dst = ByteBuffer.allocate(4);
      readFully(dst);
      return dst.asIntBuffer().get();
   }

   /**
    * {@inheritDoc}
    */
 
View Full Code Here

Examples of java.nio.ByteBuffer.asIntBuffer()

    */
   public int readInt() throws IOException
   {
      ByteBuffer dst = ByteBuffer.allocate(4);
      readFully(dst);
      return dst.asIntBuffer().get();
   }

   /**
    * {@inheritDoc}
    */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.