public int getRowCountNonTrimmed() { if (rowCountNonTrimmed == -1) return getRowCount(); return rowCountNonTrimmed; }
public int getRowCountNonTrimmed() { if (rowCountNonTrimmed == -1) return getRowCount(); return rowCountNonTrimmed; }
public boolean isEmpty() { return getRowCount() == 0; }
public boolean isEmpty() { return getRowCount() == 0; }
protected Object getValueAt(int row, DataColumn column) { if (row >= getRowCount()) { throw new IllegalArgumentException("The row index " + row + " is out of bounds: " + (getRowCount()-1)); } return column.getValues().get(row); }
protected Object getValueAt(int row, DataColumn column) { if (row >= getRowCount()) { throw new IllegalArgumentException("The row index " + row + " is out of bounds: " + (getRowCount()-1)); } return column.getValues().get(row); }
public DataSet trim(int offset, int rows) { if (offset < 0) { throw new IllegalArgumentException("Offset can't be negative: " + offset); } if (offset == 0 && (rows <= 0 || rows >= this.getRowCount())) { this.rowCountNonTrimmed = -1; return this; } if (offset >= getRowCount()) { throw new IllegalArgumentException("Offset can't be greater than the number of rows: " + offset); } DataSetImpl other = cloneEmpty(); other.rowCountNonTrimmed = getRowCount(); for (int i=0; i<columns.size(); i++) { DataColumn column = columns.get(i); DataColumn colOther = other.getColumns().get(i); List values = column.getValues(); List valOther = colOther.getValues(); for (int j=offset; j<values.size() && j<( offset+rows ); j++) { Object value = values.get(j); valOther.add(value); } } return other; }
public DataSet trim(int offset, int rows) { if (offset < 0) { throw new IllegalArgumentException("Offset can't be negative: " + offset); } if (offset == 0 && (rows <= 0 || rows >= this.getRowCount())) { this.rowCountNonTrimmed = -1; return this; } if (offset > getRowCount()) { throw new IllegalArgumentException("Offset can't be greater than the number of rows: " + offset); } DataSetImpl other = cloneEmpty(); other.rowCountNonTrimmed = getRowCount(); for (int i=0; i<columns.size(); i++) { DataColumn column = columns.get(i); DataColumn colOther = other.getColumns().get(i); List values = column.getValues(); List valOther = colOther.getValues(); for (int j=offset; j<values.size() && j<( offset+rows ); j++) { Object value = values.get(j); valOther.add(value); } } return other; }
public DataSet trim(List<Integer> rows) { if (rows == null) { return this; } DataSetImpl other = cloneEmpty(); other.rowCountNonTrimmed = getRowCount(); if (rows.isEmpty()) return other; for (int i=0; i<columns.size(); i++) { List values = columns.get(i).getValues(); List valOther = other.getColumns().get(i).getValues(); for (Integer row : rows) { if (row >= values.size()) { throw new IllegalArgumentException("Row number is out of bounds: " + row); } Object value = values.get(row); valOther.add(value); } } return other; }
public DataSet trim(List<Integer> rows) { if (rows == null) { return this; } DataSetImpl other = cloneEmpty(); other.rowCountNonTrimmed = getRowCount(); if (rows.isEmpty()) return other; for (int i=0; i<columns.size(); i++) { List values = columns.get(i).getValues(); List valOther = other.getColumns().get(i).getValues(); for (Integer row : rows) { if (row >= values.size()) { throw new IllegalArgumentException("Row number is out of bounds: " + row); } Object value = values.get(row); valOther.add(value); } } return other; }
public DataSetMetadataImpl(DataSetImpl dataSet) { this.definition = dataSet.getDefinition(); this.uuid = dataSet.uuid; this.numberOfRows = dataSet.getRowCount(); this.estimatedSize = (int) dataSet.getEstimatedSize(); this.numberOfColumns = dataSet.getColumns().size(); for (DataColumn column : dataSet.getColumns()) { columnIds.add(column.getId()); columnTypes.add(column.getColumnType()); } }
public DataSetMetadataImpl(DataSetImpl dataSet) { this.definition = dataSet.getDefinition(); this.uuid = dataSet.uuid; this.numberOfRows = dataSet.getRowCount(); this.estimatedSize = (int) dataSet.getEstimatedSize(); this.numberOfColumns = dataSet.getColumns().size(); for (DataColumn column : dataSet.getColumns()) { columnIds.add(column.getId()); columnTypes.add(column.getColumnType()); } }
public long getEstimatedSize() { int nrows = getRowCount(); if (nrows == 0) return 0; List<DataColumn> columns = getColumns(); int ncells = nrows * columns.size(); int result = ncells * 4; for (int i = 0; i < columns.size(); i++) { Object firstRowValue = getValueAt(0, i); if (firstRowValue instanceof String) { for (int j = 0; j < nrows; j++) { String stringValue = (String) getValueAt(j, i); result += MemSizeEstimator.sizeOfString(stringValue); } } else { int singleValueSize = MemSizeEstimator.sizeOf(firstRowValue); result += nrows * singleValueSize; } } return result; } }
public long getEstimatedSize() { int nrows = getRowCount(); if (nrows == 0) return 0; List<DataColumn> columns = getColumns(); int ncells = nrows * columns.size(); int result = ncells * 4; for (int i = 0; i < columns.size(); i++) { Object firstRowValue = getValueAt(0, i); if (firstRowValue instanceof String) { for (int j = 0; j < nrows; j++) { String stringValue = (String) getValueAt(j, i); result += MemSizeEstimator.sizeOfString(stringValue); } } else { int singleValueSize = MemSizeEstimator.sizeOf(firstRowValue); result += nrows * singleValueSize; } } return result; } }