eu.stratosphere.pact.runtime.hash.BuildFirstReOpenableHashMatchIterator Maven / Gradle / Ivy
/***********************************************************************************************************************
* Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
*
* Licensed 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 eu.stratosphere.pact.runtime.hash;
import java.io.IOException;
import java.util.List;
import eu.stratosphere.api.common.typeutils.TypeComparator;
import eu.stratosphere.api.common.typeutils.TypePairComparator;
import eu.stratosphere.api.common.typeutils.TypeSerializer;
import eu.stratosphere.core.memory.MemorySegment;
import eu.stratosphere.nephele.services.iomanager.IOManager;
import eu.stratosphere.nephele.services.memorymanager.MemoryAllocationException;
import eu.stratosphere.nephele.services.memorymanager.MemoryManager;
import eu.stratosphere.nephele.template.AbstractInvokable;
import eu.stratosphere.util.MutableObjectIterator;
public class BuildFirstReOpenableHashMatchIterator extends BuildFirstHashMatchIterator {
private final ReOpenableMutableHashTable reopenHashTable;
public BuildFirstReOpenableHashMatchIterator(
MutableObjectIterator firstInput,
MutableObjectIterator secondInput,
TypeSerializer serializer1, TypeComparator comparator1,
TypeSerializer serializer2, TypeComparator comparator2,
TypePairComparator pairComparator,
MemoryManager memManager, IOManager ioManager,
AbstractInvokable ownerTask, long totalMemory)
throws MemoryAllocationException {
super(firstInput, secondInput, serializer1, comparator1, serializer2,
comparator2, pairComparator, memManager, ioManager, ownerTask,
totalMemory);
reopenHashTable = (ReOpenableMutableHashTable) hashJoin;
}
public MutableHashTable getHashJoin(TypeSerializer buildSideSerializer, TypeComparator buildSideComparator,
TypeSerializer probeSideSerializer, TypeComparator probeSideComparator,
TypePairComparator pairComparator,
MemoryManager memManager, IOManager ioManager, AbstractInvokable ownerTask, long totalMemory)
throws MemoryAllocationException
{
final int numPages = memManager.computeNumberOfPages(totalMemory);
final List memorySegments = memManager.allocatePages(ownerTask, numPages);
return new ReOpenableMutableHashTable(buildSideSerializer, probeSideSerializer, buildSideComparator, probeSideComparator, pairComparator, memorySegments, ioManager);
}
/**
* Set new input for probe side
* @throws IOException
*/
public void reopenProbe(MutableObjectIterator probeInput) throws IOException {
reopenHashTable.reopenProbe(probeInput);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy