org.opensearch.ml.common.dataframe.DataFrameBuilder Maven / Gradle / Ivy
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
package org.opensearch.ml.common.dataframe;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.opensearch.core.common.io.stream.StreamInput;
import lombok.experimental.UtilityClass;
@UtilityClass
public class DataFrameBuilder {
/**
* Build empty data frame without any real data.
* @param columnMetas column metas
* @return empty data frame
*/
public DataFrame emptyDataFrame(final ColumnMeta[] columnMetas) {
if (columnMetas == null || columnMetas.length == 0) {
throw new IllegalArgumentException("columnMetas array is null or empty");
}
return new DefaultDataFrame(columnMetas);
}
/**
* Load data frame based on list of map objects. It will use the first object to build the ColumnMeta, and all of the
* map objects should have same key set, other wise it will throw exception.
* @param input input list of map objects
* @return data frame
*/
public DataFrame load(final List