Package org.apache.flink.core.memory

Examples of org.apache.flink.core.memory.MemorySegment


    @Override
    protected MemorySegment nextSegment(MemorySegment current, int bytesUsed) throws IOException
    {
      finalizeSegment(current, bytesUsed);
     
      final MemorySegment next;
      if (this.writer == null) {
        this.targetList.add(current);
        next = this.memSource.nextSegment();
      } else {
        this.writer.writeBlock(current);
View Full Code Here


    this.writer.close();
   
    // re-collect all memory segments
    ArrayList<MemorySegment> list = new ArrayList<MemorySegment>(this.numSegments)
    for (int i = 0; i < this.numSegments; i++) {
      final MemorySegment m = queue.poll();
      if (m == null) {
        // we get null if the queue is empty. that should not be the case if the reader was properly closed.
        throw new RuntimeException("ChannelWriterOutputView: MemorySegments have been taken from return queue by different actor.");
      }
      list.add(m);
View Full Code Here

  {
    if (current != null) {
      writeSegment(current, posInSegment, false);
    }
   
    final MemorySegment next = this.writer.getNextReturnedSegment();
    this.blockCount++;
    return next;
  }
View Full Code Here

      return numSegments;
    }
   
    MemorySegment[] close() throws IOException
    {
      final MemorySegment current = getCurrentSegment();
      if (current == null) {
        throw new IllegalStateException("Illegal State in HashPartition: No current buffer when finilizing build side.");
      }
      finalizeSegment(current, getCurrentPositionInSegment());
      clear();
View Full Code Here

   */
  public MemorySegment getNextReturnedSegment() throws IOException
  {
    try {
      while (true) {
        final MemorySegment next = this.returnBuffers.poll(2000, TimeUnit.MILLISECONDS);
        if (next != null) {
          return next;
        } else {
          if (this.closed) {
            throw new IOException("The writer has been closed.");
View Full Code Here

            final int posHashCode = hashCode % initialBucketCount;
            final long pointer = pIter.getPointer();
            // get the bucket for the given hash code
            final int bucketArrayPos = posHashCode >> this.bucketsPerSegmentBits;
            final int bucketInSegmentPos = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
            final MemorySegment bucket = this.buckets[bucketArrayPos];
            insertBucketEntry(part, bucket, bucketInSegmentPos, hashCode, pointer);
          }
        } else {
          this.writeBehindBuffersAvailable--; // we are not in-memory, thus the probe side buffer will grab one wbb.
          if (this.writeBehindBuffers.size() == 0) { // prepareProbePhase always requires one buffer in the writeBehindBuffers-Queue.
View Full Code Here

 
  @SuppressWarnings("unchecked")
  private <T extends Comparable<T>> void assertNormalizableKey(NormalizableKey<T> key1, NormalizableKey<T> key2, int len) {
   
    byte[] normalizedKeys = new byte[2*len];
    MemorySegment wrapper = new MemorySegment(normalizedKeys);
   
    key1.copyNormalizedKey(wrapper, 0, len);
    key2.copyNormalizedKey(wrapper, len, len);
   
    for (int i = 0; i < len; i++) {
View Full Code Here

      final int posHashCode = hash % this.numBuckets;
     
      // get the bucket for the given hash code
      final int bucketArrayPos = posHashCode >> this.bucketsPerSegmentBits;
      final int bucketInSegmentOffset = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
      final MemorySegment bucket = this.buckets[bucketArrayPos];
     
      // get the basic characteristics of the bucket
      final int partitionNumber = bucket.get(bucketInSegmentOffset + HEADER_PARTITION_OFFSET);
      final HashPartition<BT, PT> p = this.partitionsBeingBuilt.get(partitionNumber);
     
      // for an in-memory partition, process set the return iterators, else spill the probe records
      if (p.isInMemory()) {
        this.recordComparator.setReference(next);
View Full Code Here

    final int posHashCode = hash % this.numBuckets;
   
    // get the bucket for the given hash code
    final int bucketArrayPos = posHashCode >> this.bucketsPerSegmentBits;
    final int bucketInSegmentOffset = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
    final MemorySegment bucket = this.buckets[bucketArrayPos];
   
    // get the basic characteristics of the bucket
    final int partitionNumber = bucket.get(bucketInSegmentOffset + HEADER_PARTITION_OFFSET);
    final HashPartition<BT, PT> p = this.partitionsBeingBuilt.get(partitionNumber);
   
    // for an in-memory partition, process set the return iterators, else spill the probe records
    if (p.isInMemory()) {
      this.recordComparator.setReference(record);
View Full Code Here

        final long pointer = pIter.getPointer();
       
        // get the bucket for the given hash code
        final int bucketArrayPos = posHashCode >> this.bucketsPerSegmentBits;
        final int bucketInSegmentPos = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
        final MemorySegment bucket = this.buckets[bucketArrayPos];
       
        insertBucketEntry(newPart, bucket, bucketInSegmentPos, hashCode, pointer);
      }
    }
    else {
View Full Code Here

TOP

Related Classes of org.apache.flink.core.memory.MemorySegment

Copyright © 2018 www.massapicom. 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.