/** * Adds the values in the array <tt>vals</tt> to the end of the * list, in order. * * @param vals an <code>float[]</code> value */ public void add(float[] vals) { add(vals, 0, vals.length); }
/** * Creates a new <code>TFloatArrayList</code> instance whose * capacity is the greater of the length of <tt>values</tt> and * DEFAULT_CAPACITY and whose initial contents are the specified * values. * * @param values an <code>float[]</code> value */ public TFloatArrayList(float[] values) { this(Math.max(values.length, DEFAULT_CAPACITY)); add(values); }
/** * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All * values including and to the right of <tt>offset</tt> are shifted * to the right. * * @param offset an <code>int</code> value * @param value an <code>float</code> value */ public void insert(int offset, float value) { if (offset == _pos) { add(value); return; } ensureCapacity(_pos + 1); // shift right System.arraycopy(_data, offset, _data, offset + 1, _pos - offset); // insert _data[offset] = value; _pos++; }
/** * Inserts a slice of the array of <tt>values</tt> into the list * at <tt>offset</tt>. All values including and to the right of * <tt>offset</tt> are shifted to the right. * * @param offset an <code>int</code> value * @param values an <code>float[]</code> value * @param valOffset the offset in the values array at which to * start copying. * @param len the number of values to copy from the values array */ public void insert(int offset, float[] values, int valOffset, int len) { if (offset == _pos) { add(values, valOffset, len); return; } ensureCapacity(_pos + len); // shift right System.arraycopy(_data, offset, _data, offset + len, _pos - offset); // insert System.arraycopy(values, valOffset, _data, offset, len); _pos += len; }
/** * Searches the list for values which do <b>not</b> satisfy * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>. * * @param condition a condition to apply to each element in the list * @return a list of values which do not match the condition. */ public TFloatArrayList inverseGrep(TFloatProcedure condition) { TFloatArrayList list = new TFloatArrayList(); for (int i = 0; i < _pos; i++) { if (! condition.execute(_data[i])) { list.add(_data[i]); } } return list; }
/** * Searches the list for values satisfying <tt>condition</tt> in * the manner of the *nix <tt>grep</tt> utility. * * @param condition a condition to apply to each element in the list * @return a list of values which match the condition. */ public TFloatArrayList grep(TFloatProcedure condition) { TFloatArrayList list = new TFloatArrayList(); for (int i = 0; i < _pos; i++) { if (condition.execute(_data[i])) { list.add(_data[i]); } } return list; }
private void runQuery(Query query, int execType) throws Exception { System.out.println("Executing Query: " + query.getQueryString()); System.out.println("Num iterations=" + NUM_ITERATIONS); System.out.println(); boolean indexed = execType == INDEXED; for (int i = 0; i < DATA_SET_SIZES.length; i++) { int num = DATA_SET_SIZES[i]; populate(num, indexed); System.out.println("Executing (" + execTypeStrings[execType] + ")..."); long startTime = NanoTimer.getTime(); SelectResults results = null; for (int j = 0; j < NUM_ITERATIONS; j++) { results = (SelectResults)query.execute(); } long totalTime = NanoTimer.getTime() - startTime; System.out.println("results size =" + results.size()); float aveTime = totalTime / NUM_ITERATIONS / 1e6f; System.out.println("ave execution time=" + aveTime + " ms"); this.results[execType].add(aveTime); System.out.println(); } System.out.println("--------------------------------------------"); }
private void populate(int numPortfolios, boolean indexed) throws CacheException, QueryException { System.out.println("Populating Cache with " + numPortfolios + " Portfolios"); if (this.region != null) { this.region.localDestroyRegion(); } this.region = cache.createRegion("portfolios", this.regionAttributes); for (int i = 0; i < numPortfolios; i++) { this.region.put(String.valueOf(i), new Portfolio(i)); } if (indexed) { System.out.println("Creating index..."); long startNanos = NanoTimer.getTime(); this.qs.createIndex("portfolios", IndexType.FUNCTIONAL, "type", "/portfolios"); float createTime = (NanoTimer.getTime() - startNanos) / 1e6f; System.out.println("Index created in " + createTime + " ms."); this.results[INDEX_CREATE].add(createTime); } }