org.kitesdk.data.crunch.KeyConverter Maven / Gradle / Ivy
/**
* Copyright 2014 Cloudera Inc.
*
* 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 org.kitesdk.data.crunch;
import org.apache.crunch.types.Converter;
import org.apache.crunch.types.avro.AvroType;
class KeyConverter implements Converter> {
private static final long serialVersionUID = 0;
private AvroType ptype;
public KeyConverter(AvroType ptype) {
this.ptype = ptype;
}
@Override
public E convertInput(E entity, Void value) {
return entity;
}
@Override
public Iterable convertIterableInput(E entity, Iterable values) {
throw new UnsupportedOperationException("Should not be possible");
}
@Override
public E outputKey(E entity) {
return entity;
}
@Override
public Void outputValue(E entity) {
return null;
}
@Override
public Class getKeyClass() {
return ptype.getTypeClass();
}
@Override
public Class getValueClass() {
return Void.class;
}
@Override
public boolean applyPTypeTransforms() {
return true;
}
}