/** * Set column that should be used to search with the current options. * If columnsToSearch is empty, all columns will be used to search. * @param columnsToSearch It is safe to specify invalid columns, they will be ignored */ public void setColumnsToSearch(Column[] columnsToSearch) { this.columnsToSearch.clear(); if (columnsToSearch != null) { for (Column c : columnsToSearch) { this.columnsToSearch.add(c.getIndex()); } } }
void checkColumn(Column column) { if (column.getIndex() == ColumnStore.NULL_ID) { throw new IllegalArgumentException("The column does not exist"); } ColumnStore columnStore = getColumnStore(); if (columnStore != null && columnStore.getColumnByIndex(column.getIndex()) != column) { throw new IllegalArgumentException("The column does not belong to the right column store"); } }
void checkColumn(Column column) { if (column.getIndex() == ColumnStore.NULL_ID) { throw new IllegalArgumentException("The column does not exist"); } ColumnStore columnStore = getColumnStore(); if (columnStore != null && columnStore.getColumnByIndex(column.getIndex()) != column) { throw new IllegalArgumentException("The column does not belong to the right column store"); } }
private void writeDataTablesModel(XMLStreamWriter writer, DataTablesModel dataTablesModel) throws XMLStreamException { for (Column column : dataTablesModel.getNodeAvailableColumnsModel().getAvailableColumns()) { writer.writeStartElement(NODE_COLUMN); writer.writeAttribute("id", String.valueOf(column.getIndex())); writer.writeEndElement(); } for (Column column : dataTablesModel.getEdgeAvailableColumnsModel().getAvailableColumns()) { writer.writeStartElement(EDGE_COLUMN); writer.writeAttribute("id", String.valueOf(column.getIndex())); writer.writeEndElement(); } }
@Override public Object getAttribute(Column column) { checkColumn(column); int index = column.getIndex(); Object res = null; synchronized (this) { if (index < attributes.length) { res = attributes[index]; } } if (res == null) { return column.getDefaultValue(); } return res; }
@Override public Object getAttribute(Column column) { checkColumn(column); int index = column.getIndex(); Object res = null; synchronized (this) { if (index < attributes.length) { res = attributes[index]; } } if (res == null) { return column.getDefaultValue(); } return res; }
public void refreshSearchOptions() { refreshRegexPattern(); searchOptions.setOnlyMatchWholeAttributeValue(matchWholeValueCheckBox.isSelected()); searchOptions.setUseRegexReplaceMode(regexReplaceCheckBox.isEnabled() && regexReplaceCheckBox.isSelected()); if (columnsToSearchComboBox.getSelectedIndex() <= 0) { searchOptions.setColumnsToSearch(new int[0]); } else { searchOptions.setColumnsToSearch(new int[]{((ColumnWrapper) columnsToSearchComboBox.getSelectedItem()).column.getIndex()}); } refreshControls(); }
public void index(T element) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { ensureAttributeArrayLength(elementImpl, columnStore.length); final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; value = mainIndex.put(c, value, element); elementImpl.attributes[c.getIndex()] = value; } } } finally { unlock(); } }
public void index(T element) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { ensureAttributeArrayLength(elementImpl, columnStore.length); final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; value = mainIndex.put(c, value, element); elementImpl.attributes[c.getIndex()] = value; } } } finally { unlock(); } }
public void indexInView(T element, GraphView view) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { IndexImpl<T> index = viewIndexes.get(view); if (index != null) { final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; index.put(c, value, element); } } } } finally { unlock(); } }
public void clearInView(T element, GraphView view) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { IndexImpl<T> index = viewIndexes.get(view); if (index != null) { final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; index.remove(c, value, element); } } } } finally { unlock(); } }
public void clearInView(T element, GraphView view) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { IndexImpl<T> index = viewIndexes.get(view); if (index != null) { final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; index.remove(c, value, element); } } } } finally { unlock(); } }
public void indexInView(T element, GraphView view) { ElementImpl elementImpl = (ElementImpl) element; lock(); try { IndexImpl<T> index = viewIndexes.get(view); if (index != null) { final int length = columnStore.length; final ColumnImpl[] cols = columnStore.columns; for (int i = 0; i < length; i++) { Column c = cols[i]; if (c != null && c.isIndexed()) { Object value = elementImpl.attributes[c.getIndex()]; index.put(c, value, element); } } } } finally { unlock(); } }
@Override public Column medianNumberMerge(Table table, Column[] columnsToMerge, String newColumnTitle) { checkTableAndColumnsAreNumberOrNumberList(table, columnsToMerge); AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class); Column newColumn; newColumn = ac.addAttributeColumn(table, newColumnTitle, BigDecimal.class);//Create as BIGDECIMAL column by default. Then it can be duplicated to other type. if (newColumn == null) { return null; } final int newColumnIndex = newColumn.getIndex(); BigDecimal median; for (Element row : ac.getTableAttributeRows(table)) { median = StatisticsUtils.median(ac.getRowNumbers(row, columnsToMerge)); row.setAttribute(newColumn, median); } return newColumn; }
private Object getTimeAttribute(Column column, Object timeObject) { checkColumn(column); checkColumnDynamic(column); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null) { return dynamicValue.get(timeObject, column.getDefaultValue()); } } return null; }
private Object getTimeAttribute(Column column, Object timeObject) { checkColumn(column); checkColumnDynamic(column); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null) { return dynamicValue.get(timeObject, column.getDefaultValue()); } } return null; }
@Override public Iterable<Map.Entry> getAttributes(Column column) { checkColumn(column); checkColumnDynamic(column); int index = column.getIndex(); TimeMap dynamicValue = null; synchronized (this) { if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null) { Object[] values = dynamicValue.toValuesArray(); if (dynamicValue instanceof TimestampMap) { return new TimeAttributeIterable(((TimestampMap) dynamicValue).getTimestamps(), values); } else if (dynamicValue instanceof IntervalMap) { return new TimeAttributeIterable(((IntervalMap) dynamicValue).toKeysArray(), values); } } } return TimeAttributeIterable.EMPTY_ITERABLE; }
@Override public Iterable<Map.Entry> getAttributes(Column column) { checkColumn(column); checkColumnDynamic(column); int index = column.getIndex(); TimeMap dynamicValue = null; synchronized (this) { if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null) { Object[] values = dynamicValue.toValuesArray(); if (dynamicValue instanceof TimestampMap) { return new TimeAttributeIterable(((TimestampMap) dynamicValue).getTimestamps(), values); } else if (dynamicValue instanceof IntervalMap) { return new TimeAttributeIterable(((IntervalMap) dynamicValue).toKeysArray(), values); } } } return TimeAttributeIterable.EMPTY_ITERABLE; }
@Override public Object getAttribute(Column column, GraphView view) { checkColumn(column); if (!column.isDynamic()) { return getAttribute(column); } else { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null && !dynamicValue.isEmpty()) { Estimator estimator = column.getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } return dynamicValue.get(interval, estimator); } } } return null; }
private Object removeTimeAttribute(Column column, Object timeObject) { checkColumn(column); checkColumnDynamic(column); checkReadOnlyColumn(column); int index = column.getIndex(); Object oldValue = null; boolean res = false; synchronized (this) { TimeMap dynamicValue = (TimeMap) attributes[index]; if (dynamicValue != null) { oldValue = dynamicValue.get(timeObject, null); res = dynamicValue.remove(timeObject); } } if (res && isValid()) { TimeIndexStore timeIndexStore = getTimeIndexStore(); if (timeIndexStore != null) { timeIndexStore.remove(timeObject); } ((ColumnImpl) column).incrementVersion(this); } return oldValue; }