
org.aksw.sparqlify.database.IndexMetaNode Maven / Gradle / Ivy
package org.aksw.sparqlify.database;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Datastructure for metadata about indexes (hierarchical and non-hierarchical).
*
* Important: Do not modify this structure after attaching it to a table, or
* behavior is undefined.
*
*
* @author Claus Stadler
*
* @param
*/
public class IndexMetaNode {
private IndexMetaNode parent;
private Table table;
private List columnNames;
// NOTE: The store factory provides the supported constraint classes
private MapStoreAccessor factory;
//private MetaIndexFactory factory;
private Map, List> subIndexes = new HashMap, List>();
private List children = new ArrayList();
public List getChildren() {
return children;
}
public Map, List> getSubIndexes() {
return subIndexes;
}
public IndexMetaNode(Table table, List columnNames, MapStoreAccessor factory) {
this.parent = null;
this.table = table;
this.columnNames = columnNames;
this.factory = factory;
}
public IndexMetaNode(IndexMetaNode parent, List columnNames, MapStoreAccessor factory) {
this.parent = parent;
this.table = parent.getTable();
this.columnNames = columnNames;
this.factory = factory;
List list = parent.subIndexes.get(columnNames);
if(list == null) {
list = new ArrayList();
parent.subIndexes.put(columnNames, list);
}
list.add(this);
parent.children.add(this);
}
public IndexMetaNode getParent() {
return parent;
}
public Table getTable() {
return table;
}
public List getColumnNames() {
return columnNames;
}
public MapStoreAccessor getFactory() {
return factory;
}
/*
public Map, List> getSubIndexes() {
return subIndexes;
}*/
public void addSubIndex(IndexMetaNode subIndex) {
//subIndexes.put(subIndex.getColumnNames());
}
public static IndexMetaNode create(Table table, MetaIndexFactory factory, String ... columns)
{
MapStoreAccessor f = factory.create(table, Arrays.asList(columns));
return new IndexMetaNode(table, Arrays.asList(columns), f);
}
public static IndexMetaNode create(IndexMetaNode parent, MetaIndexFactory factory, String ... columns) {
MapStoreAccessor f = factory.create(parent.getTable(), Arrays.asList(columns));
return new IndexMetaNode(parent, Arrays.asList(columns), f);
}
@Override
public String toString() {
return "IndexMetaNode [columnNames=" + columnNames + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy