List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:org.apache.hadoop.hbase.regionserver.TestMultiColumnScanner.java
@Parameters public static final Collection<Object[]> parameters() { List<Object[]> parameters = new ArrayList<Object[]>(); for (Object[] bloomAndCompressionParams : HBaseTestingUtility.BLOOM_AND_COMPRESSION_COMBINATIONS) { for (boolean useDataBlockEncoding : new boolean[] { false, true }) { parameters.add(ArrayUtils.add(bloomAndCompressionParams, useDataBlockEncoding)); }/*w ww .ja v a2 s.c o m*/ } return parameters; }
From source file:org.apache.kylin.cube.model.CubeDesc.java
private void initDerivedMap(TblColRef[] hostCols, DeriveType type, JoinDesc join, TblColRef[] derivedCols, String[] extra) {/*from ww w . j a va 2 s .c o m*/ if (hostCols.length == 0 || derivedCols.length == 0) throw new IllegalStateException("host/derived columns must not be empty"); // Although FK derives PK automatically, user unaware of this can declare PK as derived dimension explicitly. // In that case, derivedCols[] will contain a FK which is transformed from the PK by initDimensionColRef(). // Must drop FK from derivedCols[] before continue. for (int i = 0; i < derivedCols.length; i++) { if (ArrayUtils.contains(hostCols, derivedCols[i])) { derivedCols = (TblColRef[]) ArrayUtils.remove(derivedCols, i); if (extra != null) extra = (String[]) ArrayUtils.remove(extra, i); i--; } } if (derivedCols.length == 0) return; for (int i = 0; i < derivedCols.length; i++) { TblColRef derivedCol = derivedCols[i]; boolean isOneToOne = type == DeriveType.PK_FK || ArrayUtils.contains(hostCols, derivedCol) || (extra != null && extra[i].contains("1-1")); derivedToHostMap.put(derivedCol, new DeriveInfo(type, join, hostCols, isOneToOne)); } Array<TblColRef> hostColArray = new Array<TblColRef>(hostCols); List<DeriveInfo> infoList = hostToDerivedMap.get(hostColArray); if (infoList == null) { infoList = new ArrayList<DeriveInfo>(); hostToDerivedMap.put(hostColArray, infoList); } // Merged duplicated derived column List<TblColRef> whatsLeft = new ArrayList<>(); for (TblColRef derCol : derivedCols) { boolean merged = false; for (DeriveInfo existing : infoList) { if (existing.type == type && existing.join.getPKSide().equals(join.getPKSide())) { if (ArrayUtils.contains(existing.columns, derCol)) { merged = true; break; } if (type == DeriveType.LOOKUP) { existing.columns = (TblColRef[]) ArrayUtils.add(existing.columns, derCol); merged = true; break; } } } if (!merged) whatsLeft.add(derCol); } if (whatsLeft.size() > 0) { infoList.add(new DeriveInfo(type, join, (TblColRef[]) whatsLeft.toArray(new TblColRef[whatsLeft.size()]), false)); } }
From source file:org.apache.sling.resource.collection.impl.ResourceCollectionImpl.java
/** * {@inheritDoc}/* www . ja v a 2 s. co m*/ */ public boolean add(Resource res, Map<String, Object> properties) throws PersistenceException { if (res != null && !contains(res)) { ModifiableValueMap vm = membersResource.adaptTo(ModifiableValueMap.class); String[] order = vm.get(ResourceCollectionConstants.REFERENCES_PROP, new String[] {}); order = (String[]) ArrayUtils.add(order, res.getPath()); vm.put(ResourceCollectionConstants.REFERENCES_PROP, order); if (properties == null) { properties = new HashMap<String, Object>(); } properties.put(ResourceCollectionConstants.REF_PROPERTY, res.getPath()); resolver.create(membersResource, ResourceUtil.createUniqueChildName(membersResource, res.getName()), properties); log.debug("added member to resource {} to collection {}", new String[] { res.getPath(), resource.getPath() }); return true; } return false; }
From source file:org.apache.sling.resource.collection.impl.ResourceCollectionImpl.java
/** * {@inheritDoc}/*from w w w . ja v a2 s . co m*/ */ public boolean add(Resource res) throws PersistenceException { if (res != null && !contains(res)) { ModifiableValueMap vm = membersResource.adaptTo(ModifiableValueMap.class); String[] order = vm.get(ResourceCollectionConstants.REFERENCES_PROP, new String[] {}); order = (String[]) ArrayUtils.add(order, res.getPath()); vm.put(ResourceCollectionConstants.REFERENCES_PROP, order); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(ResourceCollectionConstants.REF_PROPERTY, res.getPath()); resolver.create(membersResource, ResourceUtil.createUniqueChildName(membersResource, res.getName()), properties); log.debug("added member to resource {} to collection {}", new String[] { res.getPath(), resource.getPath() }); return true; } return false; }
From source file:org.apache.sling.resource.collection.impl.ResourceCollectionImpl.java
public void orderBefore(Resource srcResource, Resource destResource) { if (srcResource == null) { throw new IllegalArgumentException("Source Resource can not be null"); }// w ww.java 2 s.c om ModifiableValueMap vm = membersResource.adaptTo(ModifiableValueMap.class); String[] order = vm.get(ResourceCollectionConstants.REFERENCES_PROP, new String[] {}); String srcPath = srcResource.getPath(); int srcIndex = ArrayUtils.indexOf(order, srcPath); if (srcIndex < 0) { log.warn("Collection ordering failed, as there is no resource {} in collection {} for destResource", srcPath, getPath()); return; } if (destResource == null) { //add it to the end. order = (String[]) ArrayUtils.remove(order, srcIndex); order = (String[]) ArrayUtils.add(order, srcPath); } else { String destPath = destResource.getPath(); if (destPath.equals(srcPath)) { String message = MessageFormat.format( "Collection ordering failed, as source {0} and destination {1} can not be same", srcPath, destPath); log.error(message); throw new IllegalArgumentException(message); } int destIndex = ArrayUtils.indexOf(order, destPath); if (destIndex < 0) { log.warn("Collection ordering failed, as there is no resource {} in collection {} for destResource", destPath, getPath()); return; } order = (String[]) ArrayUtils.remove(order, srcIndex); if (srcIndex < destIndex) { //recalculate dest index destIndex = ArrayUtils.indexOf(order, destPath); } order = (String[]) ArrayUtils.add(order, destIndex, srcPath); } vm.put(ResourceCollectionConstants.REFERENCES_PROP, order); }
From source file:org.apache.sysml.runtime.matrix.data.FrameBlock.java
/** * Append a column of value type STRING as the last column of * the data frame. The given array is wrapped but not copied * and hence might be updated in the future. * // w w w . j a va 2s . c om * @param col array of strings */ public void appendColumn(String[] col) { ensureColumnCompatibility(col.length); String[] colnames = getColumnNames(); //before schema modification _colnames = (String[]) ArrayUtils.add(colnames, createColName(_schema.length)); _schema = (ValueType[]) ArrayUtils.add(_schema, ValueType.STRING); _coldata = (_coldata == null) ? new Array[] { new StringArray(col) } : (Array[]) ArrayUtils.add(_coldata, new StringArray(col)); _numRows = col.length; }
From source file:org.apache.sysml.runtime.matrix.data.FrameBlock.java
/** * Append a column of value type BOOLEAN as the last column of * the data frame. The given array is wrapped but not copied * and hence might be updated in the future. * //w w w .ja v a 2s .com * @param col array of booleans */ public void appendColumn(boolean[] col) { ensureColumnCompatibility(col.length); String[] colnames = getColumnNames(); //before schema modification _schema = (ValueType[]) ArrayUtils.add(_schema, ValueType.BOOLEAN); _colnames = (String[]) ArrayUtils.add(colnames, createColName(_schema.length)); _coldata = (_coldata == null) ? new Array[] { new BooleanArray(col) } : (Array[]) ArrayUtils.add(_coldata, new BooleanArray(col)); _numRows = col.length; }
From source file:org.apache.sysml.runtime.matrix.data.FrameBlock.java
/** * Append a column of value type INT as the last column of * the data frame. The given array is wrapped but not copied * and hence might be updated in the future. * /*from w w w .j a v a 2s. com*/ * @param col array of longs */ public void appendColumn(long[] col) { ensureColumnCompatibility(col.length); String[] colnames = getColumnNames(); //before schema modification _schema = (ValueType[]) ArrayUtils.add(_schema, ValueType.INT); _colnames = (String[]) ArrayUtils.add(colnames, createColName(_schema.length)); _coldata = (_coldata == null) ? new Array[] { new LongArray(col) } : (Array[]) ArrayUtils.add(_coldata, new LongArray(col)); _numRows = col.length; }
From source file:org.apache.sysml.runtime.matrix.data.FrameBlock.java
/** * Append a column of value type DOUBLE as the last column of * the data frame. The given array is wrapped but not copied * and hence might be updated in the future. * /*w ww . j a va 2 s . c o m*/ * @param col array of doubles */ public void appendColumn(double[] col) { ensureColumnCompatibility(col.length); String[] colnames = getColumnNames(); //before schema modification _schema = (ValueType[]) ArrayUtils.add(_schema, ValueType.DOUBLE); _colnames = (String[]) ArrayUtils.add(colnames, createColName(_schema.length)); _coldata = (_coldata == null) ? new Array[] { new DoubleArray(col) } : (Array[]) ArrayUtils.add(_coldata, new DoubleArray(col)); _numRows = col.length; }
From source file:org.apereo.portal.portlet.container.properties.MockRequestPropertiesManager.java
public boolean addResponseProperty(HttpServletRequest request, IPortletWindow portletWindow, String property, String value) {//from ww w . j a va2 s . co m String[] values = this.properties.get(property); values = (String[]) ArrayUtils.add(values, value); this.properties.put(property, values); return true; }