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


Java LongBuffer.get方法代碼示例

本文整理匯總了Java中java.nio.LongBuffer.get方法的典型用法代碼示例。如果您正苦於以下問題:Java LongBuffer.get方法的具體用法?Java LongBuffer.get怎麽用?Java LongBuffer.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.LongBuffer的用法示例。


在下文中一共展示了LongBuffer.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testLongGet

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Test(dataProvider = "longViewProvider")
public void testLongGet(String desc, IntFunction<ByteBuffer> fbb,
                        Function<ByteBuffer, LongBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    LongBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        long fromBytes = getLongFromBytes(bb, o + i * 8);
        long fromMethodView = bb.getLong(o + i * 8);
        assertValues(i, fromBytes, fromMethodView, bb);

        long fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        long v = getLongFromBytes(bb, o + i * 8);
        long a = bb.getLong();
        assertValues(i, v, a, bb);

        long b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ByteBufferViews.java

示例2: readLongArray

import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
 * ByteChannelからlong配列を読み込む
 * @param channel
 * @return
 * @throws IOException
 */
public static long[] readLongArray(@NonNull final ByteChannel channel)
	throws IOException {
	
	final int n = readInt(channel);
	final ByteBuffer buf = ByteBuffer.allocate(n * 8).order(ByteOrder.BIG_ENDIAN);
	final int readBytes = channel.read(buf);
	if (readBytes != n * 8) throw new IOException();
	buf.clear();
	final LongBuffer result = buf.asLongBuffer();
	if (result.hasArray()) {
		return result.array();
	}  else {
		final long[] b = new long[n];
		result.get(b);
		return b;
	}
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:24,代碼來源:ChannelHelper.java

示例3: setupDebugging

import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
 * 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.callocStack()
            .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 = stackMallocLong(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);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create VkInstance: " + translateVulkanResult(err));
    }
    return callbackHandle;
}
 
開發者ID:LWJGLX,項目名稱:autostack,代碼行數:21,代碼來源:ClearScreenDemoUseNewStack.java

示例4: createFramebuffers

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long[] createFramebuffers(VkDevice device, Swapchain swapchain, long renderPass, int width, int height) {
    LongBuffer attachments = stackMallocLong(1);
    VkFramebufferCreateInfo fci = VkFramebufferCreateInfo.callocStack()
            .sType(VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO)
            .pAttachments(attachments)
            .flags(VK_FLAGS_NONE)
            .height(height)
            .width(width)
            .layers(1)
            .pNext(NULL)
            .renderPass(renderPass);
    // Create a framebuffer for each swapchain image
    long[] framebuffers = new long[swapchain.images.length];
    LongBuffer pFramebuffer = stackMallocLong(1);
    for (int i = 0; i < swapchain.images.length; i++) {
        attachments.put(0, swapchain.imageViews[i]);
        int err = vkCreateFramebuffer(device, fci, null, pFramebuffer);
        long framebuffer = pFramebuffer.get(0);
        if (err != VK_SUCCESS) {
            throw new AssertionError("Failed to create framebuffer: " + translateVulkanResult(err));
        }
        framebuffers[i] = framebuffer;
    }
    return framebuffers;
}
 
開發者ID:LWJGLX,項目名稱:autostack,代碼行數:26,代碼來源:ClearScreenDemoUseNewStack.java

示例5: readAsLongBuffer

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Benchmark
public void readAsLongBuffer() throws IOException {
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(64 * 1024);
    LongBuffer longBuffer = byteBuffer.asLongBuffer();
    long readValueCount = 0;
    try (ReadableByteChannel byteChannel = _testFile.open();) {
        while (byteChannel.read(byteBuffer) > 0) {
            byteBuffer.flip();
            while (longBuffer.hasRemaining()) {
                long longValue = longBuffer.get();
                assertThat(longValue).isEqualTo(readValueCount);
                readValueCount++;
            }
            longBuffer.rewind();
        }
    }
    assertThat(readValueCount).isEqualTo(BinaryByteUnit.GIBIBYTES.toBytes(1) / 8);
}
 
開發者ID:jzillmann,項目名稱:gradle-jmh-report,代碼行數:19,代碼來源:ReadBenchmark.java

示例6: computeHashForChunk

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long computeHashForChunk(ByteBuffer buffer) {

        LongBuffer longBuffer = buffer.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer();
        long hash = 0;

        while (longBuffer.hasRemaining()) {
            hash += longBuffer.get();
        }

        return hash;
    }
 
開發者ID:atulgpt,項目名稱:SubtitleDownloader,代碼行數:12,代碼來源:OpenSubtitlesHasher.java

示例7: deserialize

import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
 * Read the inflights file and return a
 * {@link com.google.common.collect.SetMultimap}
 * of transactionIDs to events that were inflight.
 *
 * @return - map of inflight events per txnID.
 */
public SetMultimap<Long, Long> deserialize()
    throws IOException, BadCheckpointException {
  SetMultimap<Long, Long> inflights = HashMultimap.create();
  if (!fileChannel.isOpen()) {
    file = new RandomAccessFile(inflightEventsFile, "rw");
    fileChannel = file.getChannel();
  }
  if (file.length() == 0) {
    return inflights;
  }
  file.seek(0);
  byte[] checksum = new byte[16];
  file.read(checksum);
  ByteBuffer buffer = ByteBuffer.allocate(
      (int) (file.length() - file.getFilePointer()));
  fileChannel.read(buffer);
  byte[] fileChecksum = digest.digest(buffer.array());
  if (!Arrays.equals(checksum, fileChecksum)) {
    throw new BadCheckpointException("Checksum of inflights file differs"
        + " from the checksum expected.");
  }
  buffer.position(0);
  LongBuffer longBuffer = buffer.asLongBuffer();
  try {
    while (true) {
      long txnID = longBuffer.get();
      int numEvents = (int) (longBuffer.get());
      for (int i = 0; i < numEvents; i++) {
        long val = longBuffer.get();
        inflights.put(txnID, val);
      }
    }
  } catch (BufferUnderflowException ex) {
    LOG.debug("Reached end of inflights buffer. Long buffer position ="
        + String.valueOf(longBuffer.position()));
  }
  return inflights;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:46,代碼來源:FlumeEventQueue.java

示例8: computeHashForChunk

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long computeHashForChunk(ByteBuffer buffer) {
        
        LongBuffer longBuffer = buffer.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer();
        long hash = 0;
        while (longBuffer.hasRemaining()) {
                hash += longBuffer.get();
        }
        
        return hash;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:11,代碼來源:OpenSubtitlesHasher.java

示例9: getCompressedCounts

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Override
public long[] getCompressedCounts() {
    LongBuffer buf = LongBuffer.allocate(200);
    Simple64.compress(buf, counts, 0, counts.length);
    long[] r = new long[buf.position()];
    buf.flip();
    buf.get(r);
    return r;
}
 
開發者ID:tdunning,項目名稱:latency-histograms,代碼行數:10,代碼來源:ExpHistogram.java

示例10: getCompressedCounts

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Override
public long[] getCompressedCounts() {
    LongBuffer buf = LongBuffer.allocate(counts.length);
    Simple64.compress(buf, counts, 0, counts.length);
    long[] r = new long[buf.position()];
    buf.flip();
    buf.get(r);
    return r;
}
 
開發者ID:tdunning,項目名稱:latency-histograms,代碼行數:10,代碼來源:FloatHistogram.java

示例11: computeHashForChunk

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long computeHashForChunk(ByteBuffer buffer) {
	LongBuffer longBuffer = buffer.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer();
	long hash = 0;

	while (longBuffer.hasRemaining()) {
		hash += longBuffer.get();
	}

	return hash;
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:11,代碼來源:OpenSubtitle.java

示例12: valueOf

import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
 * Returns a {@code BitSet} corresponding to {@code longBuffer}, interpreted as a little-endian
 * sequence of bits. This method does not alter the {@code LongBuffer}.
 * @since 1.7
 */
public static BitSet valueOf(LongBuffer longBuffer) {
    // The bulk get would mutate LongBuffer (even if we reset position later), and it's not
    // clear that's allowed. My assumption is that it's the long[] variant that's the common
    // case anyway, so copy the buffer into a long[].
    long[] longs = new long[longBuffer.remaining()];
    for (int i = 0; i < longs.length; ++i) {
        longs[i] = longBuffer.get(longBuffer.position() + i);
    }
    return BitSet.valueOf(longs);
}
 
開發者ID:jtransc,項目名稱:jtransc,代碼行數:16,代碼來源:BitSet.java

示例13: createCommandPool

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long createCommandPool(VkDevice device, int queueNodeIndex) {
    VkCommandPoolCreateInfo cmdPoolInfo = VkCommandPoolCreateInfo.callocStack()
            .sType(VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
            .queueFamilyIndex(queueNodeIndex)
            .flags(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
    LongBuffer pCmdPool = stackMallocLong(1);
    int err = vkCreateCommandPool(device, cmdPoolInfo, null, pCmdPool);
    long commandPool = pCmdPool.get(0);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create command pool: " + translateVulkanResult(err));
    }
    return commandPool;
}
 
開發者ID:LWJGLX,項目名稱:autostack,代碼行數:14,代碼來源:ClearScreenDemoUseNewStack.java

示例14: byteArray2IntArray

import java.nio.LongBuffer; //導入方法依賴的package包/類
public int[] byteArray2IntArray(byte[] byteArray){
    ByteBuffer bb=
            ByteBuffer.wrap(byteArray)
                    .order(ByteOrder.BIG_ENDIAN);
    bb.rewind();
    LongBuffer lb = bb.asLongBuffer();
    lb.rewind();
    long[] larray = new long[lb.remaining()];
    lb.get(larray);
    int[] iarray=new int[larray.length/3*4];
    for (int idx=0;idx<larray.length;idx++){
        iarray[idx] = (int)larray[idx];
    }
    return iarray;
}
 
開發者ID:cmusatyalab,項目名稱:faceswap,代碼行數:16,代碼來源:Face.java

示例15: createClearRenderPass

import java.nio.LongBuffer; //導入方法依賴的package包/類
private static long createClearRenderPass(VkDevice device, int colorFormat) {
    VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.callocStack(1)
            .format(colorFormat)
            .samples(VK_SAMPLE_COUNT_1_BIT)
            .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR)
            .storeOp(VK_ATTACHMENT_STORE_OP_STORE)
            .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE)
            .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE)
            .initialLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
            .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);

    VkAttachmentReference.Buffer colorReference = VkAttachmentReference.callocStack(1)
            .attachment(0)
            .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);

    VkSubpassDescription.Buffer subpass = VkSubpassDescription.callocStack(1)
            .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS)
            .flags(VK_FLAGS_NONE)
            .pInputAttachments(null)
            .colorAttachmentCount(colorReference.remaining())
            .pColorAttachments(colorReference)
            .pResolveAttachments(null)
            .pDepthStencilAttachment(null)
            .pPreserveAttachments(null);

    VkRenderPassCreateInfo renderPassInfo = VkRenderPassCreateInfo.callocStack()
            .sType(VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO)
            .pNext(NULL)
            .pAttachments(attachments)
            .pSubpasses(subpass)
            .pDependencies(null);

    LongBuffer pRenderPass = stackMallocLong(1);
    int err = vkCreateRenderPass(device, renderPassInfo, null, pRenderPass);
    long renderPass = pRenderPass.get(0);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create clear render pass: " + translateVulkanResult(err));
    }
    return renderPass;
}
 
開發者ID:LWJGLX,項目名稱:autostack,代碼行數:41,代碼來源:ClearScreenDemoUseCallerStack.java


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