uk.gov.gchq.gaffer.spark.operation.dataframe.ConvertElementToRow Maven / Gradle / Ivy
/*
* Copyright 2016-2020 Crown Copyright
*
* 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 uk.gov.gchq.gaffer.spark.operation.dataframe;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.Row$;
import scala.collection.mutable.MutableList;
import scala.runtime.AbstractFunction1;
import uk.gov.gchq.gaffer.data.element.Edge;
import uk.gov.gchq.gaffer.data.element.Element;
import uk.gov.gchq.gaffer.data.element.Entity;
import uk.gov.gchq.gaffer.data.element.ReservedPropertyNames;
import uk.gov.gchq.gaffer.data.element.id.EdgeId;
import uk.gov.gchq.gaffer.spark.operation.dataframe.converter.exception.ConversionException;
import uk.gov.gchq.gaffer.spark.operation.dataframe.converter.property.Converter;
import uk.gov.gchq.gaffer.spark.operation.dataframe.converter.schema.SchemaToStructTypeConverter;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Map;
/**
* Class to convert a {@link Element} into a {@link Row} object for use in a Spark
* SQL dataframe.
*/
public class ConvertElementToRow extends AbstractFunction1
implements Serializable {
private static final long serialVersionUID = -361239524365928808L;
private final LinkedHashSet properties;
private final Map propertyNeedsConversion;
private final Map convertersByProperty;
public ConvertElementToRow(final LinkedHashSet properties,
final Map propertyNeedsConversion,
final Map convertersByProperty) {
this.properties = properties;
this.propertyNeedsConversion = propertyNeedsConversion;
this.convertersByProperty = convertersByProperty;
}
@Override
public Row apply(final Element element) {
final MutableList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy