public Map getRowAsMap(int row) { if (row >= getRowCount()) return null; Map result = new HashMap(); fillMapWithRow(row, result); return result; }
protected void fillArrayWithRow(int row, Object[] array) { if (row >= getRowCount()) return; List[] matrix = getPropertyValues(); for (int i = 0; i < array.length; i++) array[i] = matrix[i].get(row); }
protected void fillMapWithRow(int row, Map m) { if (row >= getRowCount()) return; List[] matrix = getPropertyValues(); for (int i = 0; i < properties.length; i++) { m.put(properties[i].getPropertyId(), matrix[i].get(row)); } }
public Object getValueAt(int row, int column) { if (row >= getRowCount()) return null; if (column >= getProperties().length) return null; List values = getPropertyValues()[column]; if (row >= values.size()) return null; return values.get(row); }
public Object[] getRowAt(int row) { if (row >= getRowCount()) return null; Object[] result = new Object[getPropertyValues().length]; fillArrayWithRow(row, result); return result; }
public DataSet sort(Comparator comparator) { // Get the list of rows to sort. List sortedPropertyValues = new ArrayList(); for (int row = 0; row < getRowCount(); row++) { Object[] rowMap = getRowAt(row); sortedPropertyValues.add(rowMap); } // Sort the rows using a runtime constrained comparator. ProfilerHelper.addRuntimeConstraint(new DataSetSortConstraints(this)); RuntimeConstrainedComparator _comp = new RuntimeConstrainedComparator(comparator, 10000); Collections.sort(sortedPropertyValues, _comp); // Update the internal data set matrix. List[] propertyValues = getPropertyValues(); for (List propertyValue : propertyValues) { propertyValue.clear(); } Iterator it = sortedPropertyValues.iterator(); while (it.hasNext()) { Object[] valuesAtRow = (Object[]) it.next(); addRowValues(valuesAtRow); } return this; }
public int sizeOf() { int nrows = getRowCount(); if (nrows == 0) return 0; SizeEstimations sizeEstimator = SizeEstimations.lookup(); int ncells = nrows * getProperties().length; int result = ncells * 4; DataProperty[] props = getProperties(); for (int i = 0; i < props.length; i++) { Object firstRowValue = getValueAt(0, i); if (firstRowValue instanceof String) { for (int j = 0; j < nrows; j++) { String stringValue = (String) getValueAt(j, i); result += sizeEstimator.sizeOfString(stringValue); } } else { int singleValueSize = sizeEstimator.sizeOf(firstRowValue); result += nrows * singleValueSize; } } return result; }
protected DataSet _filterInMemory(DataFilter filter) throws Exception { if (getRowCount() == 0 || getProperties().length == 0 || filter == null) return null; String[] filterPropertyIds = filter.getPropertyIds(); if (filterPropertyIds.length == 0) return null; else _continue = _index < getRowCount();