java.nio.LongBuffer Java Examples

The following examples show how to use java.nio.LongBuffer. 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: ClearScreenDemo.java    From lwjgl3-swt with MIT License 6 votes vote down vote up
/**
 * This function sets up the debug callback which the validation layers will use to yell at us when we make mistakes.
 */
private static long setupDebugging(VkInstance instance, int flags, VkDebugReportCallbackEXT callback) {
    // Again, a struct to create something, in this case the debug report callback
    VkDebugReportCallbackCreateInfoEXT dbgCreateInfo = VkDebugReportCallbackCreateInfoEXT.calloc()
            .sType(VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT) // <- the struct type
            .pNext(NULL) // <- must be NULL
            .pfnCallback(callback) // <- the actual function pointer (in LWJGL a Closure)
            .pUserData(NULL) // <- any user data provided to the debug report callback function
            .flags(flags); // <- indicates which kind of messages we want to receive
    LongBuffer pCallback = memAllocLong(1); // <- allocate a LongBuffer (for a non-dispatchable handle)
    // Actually create the debug report callback
    int err = vkCreateDebugReportCallbackEXT(instance, dbgCreateInfo, null, pCallback);
    long callbackHandle = pCallback.get(0);
    memFree(pCallback); // <- and free the LongBuffer
    dbgCreateInfo.free(); // <- and also the create-info struct
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create VkInstance: " + translateVulkanResult(err));
    }
    return callbackHandle;
}
 
Example #2
Source File: LongBitPacking.java    From metrics with Apache License 2.0 6 votes vote down vote up
public void pack(
        LongBuffer src,
        LongOutputStream dst,
        int validBits,
        int len,
        LongFilter filter)
{
    switch (validBits) {
        case 0:
            pack0(src, dst, len);
            break;
        default:
            packAny(src, dst, validBits, len, filter);
            break;
    }
}
 
Example #3
Source File: VkSystemMonitor.java    From oreon-engine with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void init(VkImageView imageView, LongBuffer waitSemaphores) {
	super.init(imageView, waitSemaphores);
	bean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
	UIScreen screen0 = new UIScreen();
	screen0.getElements().add(new VkColorPanel(new Vec4f(0,0,0,0.5f), 0, 215, 325, 225,
			panelMeshBuffer, guiOverlayFbo));
	screen0.getElements().add(new VkStaticTextPanel("FPS:", 20, 45, 40, 40,
			fontsImageBundle.getImageView(), fontsImageBundle.getSampler(), guiOverlayFbo));
	screen0.getElements().add(new VkStaticTextPanel("CPU:", 20, 90, 40, 40,
			fontsImageBundle.getImageView(), fontsImageBundle.getSampler(), guiOverlayFbo));
	screen0.getElements().add(new VkDynamicTextPanel("000", 120, 45, 40, 40,
			fontsImageBundle.getImageView(), fontsImageBundle.getSampler(), guiOverlayFbo));
	screen0.getElements().add(new VkDynamicTextPanel("000", 120, 90, 40, 40,
			fontsImageBundle.getImageView(), fontsImageBundle.getSampler(), guiOverlayFbo));
	screen0.getElements().add(new VkTexturePanel("textures/logo/Vulkan_Logo.png", 0, 220, 310, 130,
			panelMeshBuffer, guiOverlayFbo));
	getScreens().add(screen0);
}
 
Example #4
Source File: ShaderModule.java    From oreon-engine with GNU General Public License v3.0 6 votes vote down vote up
private void createShaderModule(String filePath) {
	
	ByteBuffer shaderCode = null;
	try {
		shaderCode = ResourceLoader.ioResourceToByteBuffer(filePath, 1024);
	} catch (IOException e) {
		e.printStackTrace();
	}
	
    int err;
    VkShaderModuleCreateInfo moduleCreateInfo = VkShaderModuleCreateInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO)
            .pNext(0)
            .pCode(shaderCode)
            .flags(0);
    LongBuffer pShaderModule = memAllocLong(1);
    err = vkCreateShaderModule(device, moduleCreateInfo, null, pShaderModule);
    handle = pShaderModule.get(0);
   
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create shader module: " + VkUtil.translateVulkanResult(err));
    }
    
    memFree(pShaderModule);
    moduleCreateInfo.free();
}
 
Example #5
Source File: RandomAccessLongStreamTest.java    From succinct with Apache License 2.0 6 votes vote down vote up
public void testOffsetBeginning() throws Exception {
  LongBuffer buf = LongBuffer.allocate(20);
  for (int i = 0; i < 20; i++) {
    buf.put(i);
  }
  FSDataInputStream is = TestUtils.getStream(buf);
  RandomAccessLongStream bs = new RandomAccessLongStream(is, 80, 10);
  for (int i = 10; i < 20; i++) {
    assertEquals(i, bs.get());
  }
  bs.rewind();
  assertEquals(0, bs.position());
  for (int i = 0; i < 10; i++) {
    assertEquals((i + 10), bs.get(i));
  }

}
 
Example #6
Source File: BitVectorOps.java    From succinct with Apache License 2.0 6 votes vote down vote up
/**
 * Get the value at a particular offset into the BitVector.
 *
 * @param data LongBuffer representation of BitVector's data.
 * @param pos  The offset into the BitVector.
 * @param bits The bit-width of the value to get.
 * @return The value of specified bit-width at the specified offset into the BitVector.
 */
static long getValue(LongBuffer data, long pos, int bits) {
  if (bits == 0) {
    return 0;
  }

  int sOff = (int) (pos % 64);
  int sIdx = (int) (pos / 64);

  if (sOff + bits <= 64) {
    // Can be read from a single block
    return (data.get(sIdx) >>> sOff) & BitUtils.LOW_BITS_SET[bits];
  } else {
    // Must be read from two blocks
    return ((data.get(sIdx) >>> sOff) | (data.get(sIdx + 1) << (64 - sOff)))
      & BitUtils.LOW_BITS_SET[bits];
  }
}
 
Example #7
Source File: VkBuffer.java    From oreon-engine with GNU General Public License v3.0 6 votes vote down vote up
public VkBuffer(VkDevice device, int size, int usage){
	
	this.device = device;
	
	VkBufferCreateInfo bufInfo = VkBufferCreateInfo.calloc()
				.sType(VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO)
				.pNext(0)
				.size(size)
				.usage(usage)
				.sharingMode(VK_SHARING_MODE_EXCLUSIVE)
				.flags(0);

	LongBuffer pBuffer = memAllocLong(1);
    int err = vkCreateBuffer(this.device, bufInfo, null, pBuffer);
       handle = pBuffer.get(0);
   
       memFree(pBuffer);
       bufInfo.free();
       
       if (err != VK_SUCCESS) {
           throw new AssertionError("Failed to create buffer: " + VkUtil.translateVulkanResult(err));
       }
}
 
Example #8
Source File: BitVectorOpsTest.java    From succinct with Apache License 2.0 6 votes vote down vote up
public void testGetValue() throws Exception {
  long pos = 0;
  BitVector bitVector = new BitVector(testSizeInBits);
  for (int i = 0; i < 10000; i++) {
    bitVector.setValue(pos, i, BitUtils.bitWidth(i));
    pos += BitUtils.bitWidth(i);
  }

  ByteBuffer buf = ByteBuffer.allocate(bitVector.serializedSize());
  bitVector.writeToBuffer(buf);
  buf.rewind();

  int bufBlocks = buf.getInt();
  pos = 0;
  LongBuffer data = (LongBuffer) buf.slice().asLongBuffer().limit(bufBlocks);

  for (int i = 0; i < 10000; i++) {
    long value = BitVectorOps.getValue(data, pos, BitUtils.bitWidth(i));
    assertEquals(i, value);
    pos += BitUtils.bitWidth(i);
  }
}
 
Example #9
Source File: DeepLab.java    From cineast with MIT License 6 votes vote down vote up
public synchronized int[][] processImage(Tensor<UInt8> input) {

    Tensor<Long> result = session.runner().feed("ImageTensor", input)
        .fetch("SemanticPredictions").run().get(0).expect(Long.class);

    int len = result.numElements();
    LongBuffer buf = LongBuffer.allocate(len);
    result.writeTo(buf);
    result.close();

    long[] resultShape = result.shape();
    long[] resultArray = buf.array();

    int w = (int) resultShape[2];
    int h = (int) resultShape[1];

    int[][] resultMatrix = new int[w][h];

    for (int i = 0; i < resultArray.length; ++i) {
      resultMatrix[i % w][i / w] = (int) resultArray[i];
    }

    return resultMatrix;
  }
 
Example #10
Source File: BitMapOpsTest.java    From succinct with Apache License 2.0 6 votes vote down vote up
/**
 * Test method: long getValPos(LongBuffer bitmap, int pos, int bits)
 *
 * @throws Exception
 */
public void testGetValPos() throws Exception {

  int pos = 60;
  int bits = 10;
  BitMap instance = new BitMap(1000L);
  instance.setValPos(pos, 1000, bits);

  LongBuffer bBuf = instance.getLongBuffer();
  FSDataInputStream is = TestUtils.getStream(bBuf);
  RandomAccessLongStream ls = new RandomAccessLongStream(is, 0, bBuf.limit());

  long expResult = 1000L;
  long result = BitMapOps.getValPos(ls, pos, bits);
  assertEquals(expResult, result);
  is.close();
}
 
Example #11
Source File: LongBitPacking.java    From metrics with Apache License 2.0 6 votes vote down vote up
public void compressChunk(
        LongBuffer src,
        LongOutputStream dst,
        LongFilter filter)
{
    src.mark();
    filter.saveContext();
    long head = 0;
    for (int i = 0; i < this.blockNum; ++i) {
        long n = this.maxBits[i] = countMaxBits(src, this.blockLen, filter);
        head = (head << 8) | n;
    }
    filter.restoreContext();
    src.reset();

    dst.write(head);
    for (int i = 0; i < this.blockNum; ++i) {
        pack(src, dst, this.maxBits[i], this.blockLen, filter);
    }
}
 
Example #12
Source File: StorageUtilities.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void controlInfoToByteArray(final byte[] data, final int offset,
                                          final byte controlByte, final long position) {

   data[offset] = controlByte;
   final ByteBuffer bBuffer = ByteBuffer.wrap(data, offset + 1, 8);
   final LongBuffer lBuffer = bBuffer.asLongBuffer();
   lBuffer.put(0, position);
}
 
Example #13
Source File: LongArrayStreamTest.java    From succinct with Apache License 2.0 5 votes vote down vote up
/**
 * Test method: long get(int i)
 *
 * @throws Exception
 */
public void testGet() throws Exception {
  LongBuffer buf = LongBuffer.allocate(10);
  for (int i = 0; i < 10; i++) {
    buf.put(i);
  }
  FSDataInputStream is = TestUtils.getStream(buf);
  LongArrayStream bs = new LongArrayStream(is, 0, 80);
  for (int i = 0; i < 10; i++) {
    assertEquals(i, bs.get(i));
  }
}
 
Example #14
Source File: NormalRenderer.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public void setWaitSemaphores(LongBuffer waitSemaphore){
	
	IntBuffer pWaitDstStageMask = memAllocInt(1);
       pWaitDstStageMask.put(0, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
       submitInfo.setWaitDstStageMask(pWaitDstStageMask);
       submitInfo.setWaitSemaphores(waitSemaphore);
}
 
Example #15
Source File: TestMappeableBitmapContainer.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Test
public void numberOfRuns2() {
  LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64);
  buffer.put(~8L);
  MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64);
  assertEquals(2, bc.numberOfRuns());
}
 
Example #16
Source File: BufferTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testElementSizeShifts() {
    // Element size shifts are the log base 2 of the element size
    // of this buffer.
    assertEquals(1, 1 << ByteBuffer.allocate(0).getElementSizeShift());

    assertEquals(SizeOf.CHAR, 1 << CharBuffer.allocate(0).getElementSizeShift());
    assertEquals(SizeOf.SHORT, 1 << ShortBuffer.allocate(0).getElementSizeShift());

    assertEquals(SizeOf.INT, 1 << IntBuffer.allocate(0).getElementSizeShift());
    assertEquals(SizeOf.FLOAT, 1 << FloatBuffer.allocate(0).getElementSizeShift());

    assertEquals(SizeOf.LONG, 1 << LongBuffer.allocate(0).getElementSizeShift());
    assertEquals(SizeOf.DOUBLE, 1 << DoubleBuffer.allocate(0).getElementSizeShift());
}
 
Example #17
Source File: VkImage.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public VkImage(VkDevice device, int width, int height, int depth,
		int format, int usage, int samples, int mipLevels){
	
	this.device = device;
	this.format = format;
	
	VkExtent3D extent = VkExtent3D.calloc()
			.width(width)
			.height(height)
			.depth(depth);
	
	VkImageCreateInfo createInfo = VkImageCreateInfo.calloc()
			.sType(VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
			.imageType(VK_IMAGE_TYPE_2D)
			.extent(extent)
			.mipLevels(mipLevels)
			.arrayLayers(1)
			.format(format)
			.tiling(VK_IMAGE_TILING_OPTIMAL)
			.initialLayout(VK_IMAGE_LAYOUT_UNDEFINED)
			.usage(usage)
			.sharingMode(VK_SHARING_MODE_EXCLUSIVE)
			.samples(VkUtil.getSampleCountBit(samples))
			.flags(0);
	
	LongBuffer pBuffer = memAllocLong(1);
    int err = vkCreateImage(device, createInfo, null, pBuffer);
       handle = pBuffer.get(0);
   
       memFree(pBuffer);
       createInfo.free();
       
       if (err != VK_SUCCESS) {
           throw new AssertionError("Failed to create image: " + VkUtil.translateVulkanResult(err));
       }
}
 
Example #18
Source File: MxNDArray.java    From djl with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void set(Buffer data) {
    int size = data.remaining();
    // int8, uint8, boolean use ByteBuffer, so need to explicitly input DataType
    DataType inputType = DataType.fromBuffer(data);
    validate(inputType, size);

    if (data.isDirect()) {
        JnaUtils.syncCopyFromCPU(getHandle(), data, size);
        return;
    }

    int numOfBytes = inputType.getNumOfBytes();
    ByteBuffer buf = manager.allocateDirect(size * numOfBytes);

    switch (inputType) {
        case FLOAT32:
            buf.asFloatBuffer().put((FloatBuffer) data);
            break;
        case FLOAT64:
            buf.asDoubleBuffer().put((DoubleBuffer) data);
            break;
        case UINT8:
        case INT8:
        case BOOLEAN:
            buf.put((ByteBuffer) data);
            break;
        case INT32:
            buf.asIntBuffer().put((IntBuffer) data);
            break;
        case INT64:
            buf.asLongBuffer().put((LongBuffer) data);
            break;
        case FLOAT16:
        default:
            throw new AssertionError("Show never happen");
    }
    JnaUtils.syncCopyFromCPU(getHandle(), buf, size);
}
 
Example #19
Source File: ImmutableBitSetTest.java    From Quicksql with MIT License 5 votes vote down vote up
@Test public void testCreateLongBuffer() {
  assertThat(ImmutableBitSet.valueOf(LongBuffer.wrap(new long[] {})),
      equalTo(ImmutableBitSet.of()));
  assertThat(ImmutableBitSet.valueOf(LongBuffer.wrap(new long[] {0xAL})),
      equalTo(ImmutableBitSet.of(1, 3)));
  assertThat(
      ImmutableBitSet.valueOf(LongBuffer.wrap(new long[] {0, 0, 0xAL, 0})),
      equalTo(ImmutableBitSet.of(129, 131)));
}
 
Example #20
Source File: CodecUtils.java    From metrics with Apache License 2.0 5 votes vote down vote up
public static void decodeBlockPack(
        LongBuffer src,
        LongFilterFactory filterFactory,
        LongBitPacking packer,
        LongOutputStream dst)
{
    // Fetch length of original array.
    if (!src.hasRemaining()) {
        return;
    }
    final int outLen = (int)src.get() - 1;

    // Fetch and output first int, and set it as delta's initial context.
    final long first = src.get();
    dst.write(first);
    LongFilter filter = filterFactory.newFilter(first);

    // Decompress intermediate blocks.
    final int chunkSize = packer.getBlockSize();
    final int chunkNum = outLen / chunkSize;
    if (chunkNum > 0) {
        packer.decompress(src, dst, filter, chunkNum);
    }

    // Decompress last block.
    final int chunkRemain = outLen % chunkSize;
    if (chunkRemain > 0) {
        long[] last = new long[chunkSize];
        LongBuffer buf = LongBuffer.wrap(last);
        packer.decompress(src, new LongBufferOutputStream(buf),
                filter, 1);
        dst.write(last, 0, chunkRemain);
    }
}
 
Example #21
Source File: TestMappeableBitmapContainer.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Test
public void andNotArray() {
  LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64);
  buffer.put(~0L);
  MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64);
  MappeableContainer ac = new MappeableArrayContainer();
  ac = ac.add(32, 64);
  bc = bc.andNot(ac);
  assertEquals(32, bc.getCardinality());
  for (char i = 0; i < 32; i++) {
    assertTrue(bc.contains(i));
  }
}
 
Example #22
Source File: TestMappeableBitmapContainer.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Test
public void xorBitmap() {
  LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64);
  buffer.put(~0L);
  MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64);
  MappeableContainer bc2 = new MappeableBitmapContainer();
  bc2 = bc2.add(10, 64);
  bc = bc.xor(bc2);
  assertEquals(10, bc.getCardinality());
  for (char i = 0; i < 10; i++) {
    assertTrue(bc.contains(i));
  }
}
 
Example #23
Source File: TestMappeableBitmapContainer.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Test
public void testFirstLast_SlicedBuffer() {
  LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64)
                                .put(0, 1L << 62)
                                .put(1, 1L << 2 | 1L << 32)
                                .slice()
                                .asReadOnlyBuffer();
  assertFalse(BufferUtil.isBackedBySimpleArray(buffer), "Sanity check - aiming to test non array backed branch");
  MappeableBitmapContainer mbc = new MappeableBitmapContainer(buffer, 3);
  assertEquals(62, mbc.first());
  assertEquals(96, mbc.last());
}
 
Example #24
Source File: BGZFBlockIndexer.java    From Hadoop-BAM with MIT License 5 votes vote down vote up
private void index(final File file) throws IOException {
       try (final InputStream in = new FileInputStream(file);
            final OutputStream out = new BufferedOutputStream(new FileOutputStream(file.getPath() + ".bgzfi"))) {

           final LongBuffer lb =
               byteBuffer.order(ByteOrder.BIG_ENDIAN).asLongBuffer();

           long prevPrint = 0;
           pos = 0;

           for (int i = 0;;) {
               if (!skipBlock(in))
                   break;

               if (++i == granularity) {
                   i = 0;
                   lb.put(0, pos);
                   out.write(byteBuffer.array(), 2, 6);

                   if (pos - prevPrint >= PRINT_EVERY) {
                       System.out.print("-");
                       prevPrint = pos;
                   }
               }
           }
           lb.put(0, file.length());
           out.write(byteBuffer.array(), 2, 6);
       }
}
 
Example #25
Source File: LongJustCopy.java    From metrics with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] compress(long[] src) {
    ByteBuffer outbuf = ByteBuffer.allocate(src.length * 8);
    LongBuffer midbuf = outbuf.asLongBuffer();
    midbuf.put(src);
    return outbuf.array();
}
 
Example #26
Source File: PlatformWin32VKCanvas.java    From lwjgl3-swt with MIT License 5 votes vote down vote up
@Override
public long create(Composite composite, VKData data) {
    VkWin32SurfaceCreateInfoKHR sci = VkWin32SurfaceCreateInfoKHR.callocStack()
      .sType(VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR)
      .hinstance(OS.GetModuleHandle(null))
      .hwnd(composite.handle);
    LongBuffer pSurface = stackMallocLong(1);
    int err = vkCreateWin32SurfaceKHR(data.instance, sci, null, pSurface);
    long surface = pSurface.get(0);
    if (err != VK_SUCCESS) {
        throw new SWTException("Calling vkCreateWin32SurfaceKHR failed with error: " + err);
    }
    return surface;
}
 
Example #27
Source File: LongDZBP.java    From metrics with Apache License 2.0 5 votes vote down vote up
public void compress(LongBuffer src, LongOutputStream dst) {
    // Output length of original array.  When input array is empty, make
    // empty output for memory efficiency.
    final int srcLen = src.remaining();
    if (srcLen == 0) {
        return;
    }
    dst.write(srcLen);

    // Output first int, and set it as delta's initial context.
    final long first = src.get();
    dst.write(first);
    DZEncodeFilter filter = new DZEncodeFilter(first);

    // Compress intermediate blocks.
    final int chunkSize = this.bitPack.getBlockSize();
    final int chunkRemain = src.remaining() % chunkSize;
    LongBuffer window = src.slice();
    window.limit(window.limit() - chunkRemain);
    this.bitPack.compress(window, dst, filter);
    src.position(src.position() + window.position());

    // Compress last block.
    if (chunkRemain > 0) {
        long[] last = new long[chunkSize];
        src.get(last, 0, chunkRemain);
        // Padding extended area by last value.  It make delta zigzag
        // efficient.
        Arrays.fill(last, chunkRemain, last.length,
                last[chunkRemain - 1]);
        this.bitPack.compress(LongBuffer.wrap(last), dst, filter);
    }
}
 
Example #28
Source File: NameGenerator.java    From yawp with MIT License 5 votes vote down vote up
private static byte[] toByteArray(UUID uuid) {
    byte[] byteArray = new byte[(Long.SIZE / Byte.SIZE) * 2];
    ByteBuffer buffer = ByteBuffer.wrap(byteArray);
    LongBuffer longBuffer = buffer.asLongBuffer();
    longBuffer.put(new long[]{uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()});
    return byteArray;
}
 
Example #29
Source File: LongTensorTypeSupport.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
public void writeField(LongBuffer buffer, Field field) {
  Utils.checkState(
      field.getType() == Field.Type.LONG,
      Utils.format("Not a Long scalar, it is {}", field.getType())
  );
  buffer.put(field.getValueAsLong());
}
 
Example #30
Source File: NotesOriginatorIdStruct.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a new universal id stored by this OID
 * 
 * @param unid new universal id
 */
public void setUNID(String unid) {
	if (unid.length()!=32) {
		throw new IllegalArgumentException("Invalid unid: "+unid);
	}
	
	for (int i=0; i<32; i++) {
		char c = unid.charAt(i);
		if ((c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f')) {
			
		}
		else {
			throw new IllegalArgumentException("Invalid unid: "+unid);
		}
	}
	
	write();
	
	Pointer oidPtr = getPointer();
	ByteBuffer data = oidPtr.getByteBuffer(0, 16).order(ByteOrder.LITTLE_ENDIAN);
	LongBuffer longBuffer = data.asLongBuffer();
	
	String firstPart = unid.substring(0, 16);
	long firstPartAsLong = new BigInteger(firstPart, 16).longValue();
	longBuffer.put(0, firstPartAsLong);
	
	String secondPart = unid.substring(16);
	long secondPartAsLong = new BigInteger(secondPart, 16).longValue();
	longBuffer.put(1, secondPartAsLong);
	
	read();
	
	String newWrittenUnid = getUNIDAsString();
	if (!unid.equalsIgnoreCase(newWrittenUnid)) {
		//should not happen ;-)
		throw new IllegalStateException("Error setting new UNID in OID structure. Probably wrong memory alignment. Please contact dev.");
	}
}