Package java.nio

Examples of java.nio.ByteBuffer.duplicate()


        int start = b.position();
        int length = b.remaining();
        key.set(b.array(), offset + start, offset + start + length);
      } else {
        byte[] bytes = new byte[b.remaining()];
        b.duplicate().get(bytes);
        key.set(bytes);
      }
    } else {
      key.set(GenericData.get().toString(datum));
    }
View Full Code Here


            } else {
              bb = ByteBuffer.allocate(_numberOfBlocksPerSlab * _blockSize);
            }
            _slabs[slabId] = bb;
          }
          byteBuffer = bb.duplicate();
        }
        byteBuffers[slabId] = byteBuffer;
      }
      return byteBuffer;
    }
View Full Code Here

          ByteBuffer cachedBuf = cache.getBlock(name + "meta" + block);
          if (cachedBuf != null) {
            // Return a distinct 'shallow copy' of the block,
            // so pos doesnt get messed by the scanner
            cacheHits++;
            return cachedBuf.duplicate();
          }
          // Cache Miss, please load.
        }

        ByteBuffer buf = decompress(metaIndex.blockOffsets[block],
View Full Code Here

        readTime += System.currentTimeMillis() - now;
        readOps++;

        // Cache the block
        if(cacheBlock && cache != null) {
          cache.cacheBlock(name + "meta" + block, buf.duplicate(), inMemory);
        }

        return buf;
      }
    }
View Full Code Here

          ByteBuffer cachedBuf = cache.getBlock(name + block);
          if (cachedBuf != null) {
            // Return a distinct 'shallow copy' of the block,
            // so pos doesnt get messed by the scanner
            cacheHits++;
            return cachedBuf.duplicate();
          }
          // Carry on, please load.
        }

        // Load block from filesystem.
View Full Code Here

        readTime += System.currentTimeMillis() - now;
        readOps++;

        // Cache the block
        if(cacheBlock && cache != null) {
          cache.cacheBlock(name + block, buf.duplicate(), inMemory);
        }

        return buf;
      }
    }
View Full Code Here

        } else {
            final ByteBuffer buf = ByteBuffer.wrap((byte[]) bytecode);
            if (VmUtils.isRunningVm()) {
                this.bytecode = buf;
            }
            return buf.duplicate();
        }
    }

    /**
     * Gets the length of the bytecode
View Full Code Here

        ByteBuffer value = data.get(i);
        if (value == null)
            return null;

        return value.duplicate();
    }

    /**
     * Returns the value of column {@code name} has a ByteBuffer.
     *
 
View Full Code Here

      Split serSplit = serializeMon.start();
      byte[] src = serialize(obj);
      serSplit.stop();
      Split split = setupMon.start();
      entry.size = src.length;
      entry.buffer = buffer.duplicate();
      entry.position = memoryUsed;
      entry.buffer.position(memoryUsed);
     
     
      try {
View Full Code Here

          ByteBuffer cachedBuf = cache.getBlock(name + block);
          if (cachedBuf != null) {
            // Return a distinct 'copy' of the block, so pos doesnt get messed by
            // the scanner
            cacheHits++;
            return cachedBuf.duplicate();
          }
          // Carry on, please load.
        }

        // Load block from filesystem.
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.