List of usage examples for org.apache.commons.collections.primitives ArrayIntList ArrayIntList
public ArrayIntList()
From source file:com.martinkampjensen.thesis.barriers.neighborhood.AbstractNeighborhood.java
public static final int[][] calculateNeighbors(List<Model> models, Neighborhood neighborhood, double maxDistance, boolean allowDebugPrints) { final int nModels = models.size(); final IntList[] lists = new ArrayIntList[nModels]; final int[][] arrays = new int[nModels][]; for (int i = 0; i < nModels; i++) { lists[i] = new ArrayIntList(); }// w ww .j a v a 2 s . c om // For status. final long calculationsTotal = (long) nModels * (nModels - 1) / 2; final boolean performStatus = (calculationsTotal >= 2500000); final long calculationsTwentieth = Math.max(1, (long) Math.floor(calculationsTotal / 20d)); long calculationsMilestone = calculationsTwentieth; long calculationsDone = 0; if (performStatus) System.err.print("Neighbors calculated: [0%"); for (int i = 0; i < nModels; i++) { final IntList list = lists[i]; final Model first = models.get(i); for (int j = i + 1; j < nModels; j++) { final Model second = models.get(j); if (neighborhood.isNeighbors(first, second, maxDistance)) { list.add(j); lists[j].add(i); } } arrays[i] = list.toArray(); lists[i] = null; // For garbage collection. // For status. if (performStatus) { calculationsDone += nModels - 1 - i; if (calculationsDone >= calculationsMilestone && i != nModels - 1) { System.err.print("..." + (int) (100 * calculationsDone / (double) calculationsTotal) + "%"); if (calculationsDone == calculationsTotal) System.err.println("]"); while (calculationsDone >= calculationsMilestone) calculationsMilestone += calculationsTwentieth; calculationsMilestone = Math.min(calculationsMilestone, calculationsTotal); } } } if (allowDebugPrints) calculateNeighborMeasures(arrays); return arrays; }
From source file:de.walware.statet.r.internal.ui.editors.RArgumentListContextInformation.java
public RArgumentListContextInformation(final int offset, final IRMethod method) { fOffset = offset;//w w w .j av a 2 s .c om fArgs = method.getArgsDefinition(); final StringBuilder sb = new StringBuilder(); final IntList idxs = new ArrayIntList(); new RLabelProvider().appendArgumentInformation(sb, idxs, fArgs); fInformation = sb.toString(); fInformationIndexes = idxs.toArray(); }
From source file:dbs_project.storage.performance.MemoryEfficiencyTest.java
@Test(timeout = 300000) public void heapTest() throws Exception { Utils.getOut().println("Adding rows to a table to check memory efficency."); StorageLayer storage = DatabaseFactory.INSTANCE.createInstance().getStorageLayer(); List<SimpleColumn> columns = StorageTest.generateColumns(0); Table table = Utils.createEmptyTableForSimpleColumns("table", columns, storage); for (int i = 0; i < ITER; ++i) { columns = StorageTest.generateColumns(ROW_BASE_COUNT); SimpleRowCursor rows = new SimpleRowCursor(columns); IdCursor ids = table.addRows(rows.getMetaData(), rows); // delete some rows ArrayIntList deleteList = new ArrayIntList(); for (; ids.next();) { if (Utils.RANDOM.nextInt() % StorageTest.DELETE_ROW_FACTOR == 0) { deleteList.add(ids.getId()); }/*from w w w . j a v a 2 s.c o m*/ } table.deleteRows(IntIteratorWrapper.wrap(deleteList.iterator())); } int rows = table.getTableMetaData().getRowCount(); // compute the checksum computeCheckSum(table); // ensure the database contains all rows assertEquals("Checksum did not match", 5583047273391819253L, checksum); assertEquals("The row count of the database did not match the expected result", 8998681, rows); printMemory(); Utils.getOut().println("Rowcount: " + rows); Utils.getOut().println("Checksum: " + checksum); try { // stop garbage collection storage.getTables(); } catch (Exception e) { } }
From source file:dbs_project.util.Utils.java
public static ArrayIntList convertIdIteratorToList(IdCursor iter) { final ArrayIntList result = new ArrayIntList(); while (iter.next()) { result.add(iter.getId());//from ww w . j ava2 s . c o m } return result; }
From source file:dbs_project.index.performance.IndexTest.java
@Before public void setUp() throws Exception { this.scaleResults = new ArrayList<>(); Utils.RANDOM.setSeed(INDEX_SEED);/* ww w. j av a 2 s. c o m*/ layer = DatabaseFactory.INSTANCE.createInstance().getIndexLayer(); List<SimpleColumn> columns = TPCHData.createLineitemColumns(1, 1); Map<String, Type> schema = new HashMap<>(); for (Column col : columns) { schema.put(col.getMetaData().getName(), col.getMetaData().getType()); } int tid = layer.createTable(TABLE_NAME, schema); table = layer.getTable(tid); idList = new ArrayIntList(); }
From source file:dbs_project.storage.performance.StorageTest.java
private void evaluateAddRows() throws Exception { columns = generateColumns(0);/*from ww w. j av a 2 s . c o m*/ table = Utils.createEmptyTableForSimpleColumns(tableName, columns, storage); Utils.getOut().println(" (1) Inserting " + rowCount + " rows..."); IdCursor ids; long time = 0; idList = new ArrayIntList(); for (int i = 0; i < scaleFactor; ++i) { columns = generateColumns(ROW_BASE_COUNT); SimpleRowCursor rows = new SimpleRowCursor(columns); long startTime = System.nanoTime(); ids = table.addRows(rows.getMetaData(), rows); idList.addAll(Utils.convertIdIteratorToList(ids)); time += System.nanoTime() - startTime; } outputTime("addRows", scaleFactor, time); }
From source file:dbs_project.storage.performance.StorageTest.java
private void evaluateUpdateRows() throws Exception { Utils.getOut().println(" (2) Updating approximately " + rowCount / UPDATE_ROW_FACTOR + " rows..."); long time = 0; for (int s = 0; s < scaleFactor; ++s) { // choose rows to update updateList = new ArrayIntList(); for (int i = s * ROW_BASE_COUNT; i < s * ROW_BASE_COUNT + idList.size() / scaleFactor; ++i) { if (Utils.RANDOM.nextInt() % UPDATE_ROW_FACTOR == 0) { updateList.add(idList.get(i)); }/* w ww . j a v a2s .co m*/ } final List<SimpleColumn> updateColumns = new ArrayList<>(columns.size()); for (final SimpleColumn referenceColumn : columns) { final SimpleColumn generatedRandomUpdateColumn = new SimpleColumn(updateList.size(), referenceColumn.getId(), referenceColumn.getName(), referenceColumn.getType()); updateColumns.add(generatedRandomUpdateColumn); } SimpleRowCursor updateCursor = new SimpleRowCursor(updateColumns); long startTime = System.nanoTime(); table.updateRows(updateCursor.getMetaData(), IntIteratorWrapper.wrap(updateList.iterator()), updateCursor); time += System.nanoTime() - startTime; } outputTime("updateRows", scaleFactor, time); }
From source file:dbs_project.storage.performance.StorageTest.java
private void evaluateDeleteRows() throws Exception { // choose the rows to delete deleteList = new ArrayIntList(); // delete list backwards, so that indexes remain stable for (int i = idList.size(); --i >= 0;) { if (Utils.RANDOM.nextInt() % DELETE_ROW_FACTOR == 0) { deleteList.add(idList.get(i)); // idList.removeElementAt(i); // remove this (write full scan // after update) }/*from w w w . j a v a2 s .c o m*/ } Utils.getOut().println(" (4) Deleting " + deleteList.size() + " rows..."); // delete the selected rows long time = System.nanoTime(); table.deleteRows(IntIteratorWrapper.wrap(deleteList.iterator())); outputTime("deleteRows", scaleFactor, System.nanoTime() - time); }
From source file:dbs_project.index.performance.IndexTest.java
private void updateRowsTest() throws Exception { long time = 0; int count = 0; for (int i = 0; i < scaleFactor; ++i) { ArrayIntList updateList = new ArrayIntList(); SimpleRowCursor rc = new SimpleRowCursor(TPCHData.createLineitemColumns(scaleFactor, i)); for (int j = 0; j < rc.getRowCount(); ++j) { if (Utils.RANDOM.nextInt(UPDATE_ROW_FACTOR) == 0) { ++count;/* w ww . ja v a2s . co m*/ updateList.add(idList.get(j)); } } rc.setRowCount(updateList.size()); long start = System.nanoTime(); table.updateRows(rc.getMetaData(), new IntIteratorWrapper(updateList.iterator()), rc); time += System.nanoTime() - start; } outputTime("updateRowsTest", scaleFactor, indexType, time); }
From source file:dbs_project.storage.performance.StorageTest.java
private void evaluateDropColumns() throws Exception { final Map<String, SimpleColumn> nameToSimpleColumnMap = new HashMap<>(); for (SimpleColumn column : columns) { nameToSimpleColumnMap.put(column.getName(), column); }/*from w ww .java2 s. c o m*/ final List<ColumnMetaData> columnMetaDataWorkingCopy = new ArrayList<>( table.getTableMetaData().getTableSchema().values()); columnsToDropIndexes = new ArrayIntList(); for (int i = 0; i < columnMetaDataWorkingCopy.size(); ++i) { ColumnMetaData toDelete = columnMetaDataWorkingCopy.get(i); if (toDelete.getName().equals("Integer1") || toDelete.getName().equals("Double2")) { nameToSimpleColumnMap.remove(toDelete.getName()); columnsToDropIndexes.add(toDelete.getId()); } } Utils.getOut().println(" (6) Removing two columns..."); long time = System.nanoTime(); table.dropColumns(IntIteratorWrapper.wrap(columnsToDropIndexes.iterator())); outputTime("dropColumns", scaleFactor, System.nanoTime() - time); }