io.github.vmzakharov.ecdataframe.dataframe.DfIndex Maven / Gradle / Ivy
package io.github.vmzakharov.ecdataframe.dataframe;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.list.ListIterable;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.IntList;
import org.eclipse.collections.api.list.primitive.MutableIntList;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.factory.Maps;
import org.eclipse.collections.impl.factory.primitive.IntLists;
public class DfIndex
{
static private final MutableIntList EMPTY_LIST = IntLists.mutable.empty().asUnmodifiable();
private final MutableMap, MutableIntList> rowIndexByKey = Maps.mutable.of();
private DataFrame dataFrame;
public DfIndex(DataFrame newIndexedDataFrame, ListIterable indexByColumnNames)
{
this.buildIndex(newIndexedDataFrame, indexByColumnNames);
}
private void buildIndex(DataFrame newDataFrame, ListIterable indexByColumnNames)
{
this.dataFrame = newDataFrame;
ListIterable indexByColumns = indexByColumnNames.collect(newDataFrame::getColumnNamed);
int rowCount = newDataFrame.rowCount();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
this.addRowIndex(
this.computeKeyFrom(indexByColumns, rowIndex),
rowIndex
);
}
}
public IntList getRowIndicesAtKey(Object... keyElements)
{
return this.getRowIndicesAtKey(Lists.immutable.of(keyElements));
}
public IntList getRowIndicesAtKey(ListIterable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy