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

com.dataartisans.flink.cascading.runtime.spilling.SpillingTupleCollectionFactory Maven / Gradle / Ivy

/*
 * Copyright 2015 data Artisans GmbH
 *
 * 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 com.dataartisans.flink.cascading.runtime.spilling;

import cascading.flow.FlowProcess;
import cascading.tuple.Tuple;
import cascading.tuple.collect.SpillableTupleList;
import cascading.tuple.collect.TupleCollectionFactory;
import cascading.tuple.hadoop.TupleSerialization;
import cascading.tuple.hadoop.collect.HadoopSpillableTupleList;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.io.compress.GzipCodec;

import java.util.Collection;

public class SpillingTupleCollectionFactory implements TupleCollectionFactory {

	private int spillThreshold;
	private CompressionCodec codec;
	private TupleSerialization tupleSerialization;

	public SpillingTupleCollectionFactory() {
	}

	public void initialize(FlowProcess flowProcess) {
		this.spillThreshold = SpillableTupleList.getThreshold(flowProcess, 10000);
		this.codec = new GzipCodec();
		this.tupleSerialization = new TupleSerialization(flowProcess);
	}

	public Collection create(FlowProcess flowProcess) {

		return new HadoopSpillableTupleList(this.spillThreshold, this.tupleSerialization, this.codec);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy