All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.runtime.operators.hash.NonReusingBuildSecondReOpenableHashJoinIterator Maven / Gradle / Ivy

There is a newer version: 1.13.6
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.apache.flink.runtime.operators.hash;

import org.apache.flink.api.common.typeutils.TypeComparator;
import org.apache.flink.api.common.typeutils.TypePairComparator;
import org.apache.flink.api.common.typeutils.TypeSerializer;
import org.apache.flink.core.memory.MemorySegment;
import org.apache.flink.runtime.io.disk.iomanager.IOManager;
import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
import org.apache.flink.runtime.memory.MemoryAllocationException;
import org.apache.flink.runtime.memory.MemoryManager;
import org.apache.flink.util.MutableObjectIterator;

import java.io.IOException;
import java.util.List;

public class NonReusingBuildSecondReOpenableHashJoinIterator extends NonReusingBuildSecondHashJoinIterator {


	private final ReOpenableMutableHashTable reopenHashTable;

	public NonReusingBuildSecondReOpenableHashJoinIterator(
			MutableObjectIterator firstInput,
			MutableObjectIterator secondInput,
			TypeSerializer serializer1,
			TypeComparator comparator1,
			TypeSerializer serializer2,
			TypeComparator comparator2,
			TypePairComparator pairComparator,
			MemoryManager memManager,
			IOManager ioManager,
			AbstractInvokable ownerTask,
			double memoryFraction,
			boolean probeSideOuterJoin,
			boolean buildSideOuterJoin,
			boolean useBitmapFilters) throws MemoryAllocationException {
		
		super(firstInput, secondInput, serializer1, comparator1, serializer2,
				comparator2, pairComparator, memManager, ioManager, ownerTask,
				memoryFraction, probeSideOuterJoin, buildSideOuterJoin, useBitmapFilters);
		
		reopenHashTable = (ReOpenableMutableHashTable) hashJoin;
	}

	@Override
	public  MutableHashTable getHashJoin(
			TypeSerializer buildSideSerializer,
			TypeComparator buildSideComparator,
			TypeSerializer probeSideSerializer, TypeComparator probeSideComparator,
			TypePairComparator pairComparator,
			MemoryManager memManager, IOManager ioManager,
			AbstractInvokable ownerTask,
			double memoryFraction,
			boolean useBitmapFilters) throws MemoryAllocationException {
		
		final int numPages = memManager.computeNumberOfPages(memoryFraction);
		final List memorySegments = memManager.allocatePages(ownerTask, numPages);
		
		return new ReOpenableMutableHashTable(buildSideSerializer, probeSideSerializer,
				buildSideComparator, probeSideComparator, pairComparator,
				memorySegments, ioManager, useBitmapFilters);
	}

	/**
	 * Set new input for probe side
	 * @throws java.io.IOException
	 */
	public void reopenProbe(MutableObjectIterator probeInput) throws IOException {
		reopenHashTable.reopenProbe(probeInput);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy