本文整理匯總了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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}