List of usage examples for org.apache.commons.lang ArrayUtils toString
public static String toString(Object array)
Outputs an array as a String, treating null
as an empty array.
From source file:org.apache.hawq.pxf.plugins.hdfs.utilities.HdfsUtilities.java
/** * Parses fragment metadata and return matching {@link FileSplit}. * * @param inputData request input data//from w w w .j a v a2 s . c o m * @return FileSplit with fragment metadata */ public static FileSplit parseFragmentMetadata(InputData inputData) { try { byte[] serializedLocation = inputData.getFragmentMetadata(); if (serializedLocation == null) { throw new IllegalArgumentException("Missing fragment location information"); } ByteArrayInputStream bytesStream = new ByteArrayInputStream(serializedLocation); ObjectInputStream objectStream = new ObjectInputStream(bytesStream); long start = objectStream.readLong(); long end = objectStream.readLong(); String[] hosts = (String[]) objectStream.readObject(); FileSplit fileSplit = new FileSplit(new Path(inputData.getDataSource()), start, end, hosts); LOG.debug("parsed file split: path " + inputData.getDataSource() + ", start " + start + ", end " + end + ", hosts " + ArrayUtils.toString(hosts)); return fileSplit; } catch (Exception e) { throw new RuntimeException("Exception while reading expected fragment metadata", e); } }
From source file:org.apache.kylin.dict.HiveTableReaderTest.java
@Test public void test() throws IOException { HiveTableReader reader = new HiveTableReader("default", "test_kylin_fact"); int rowNumber = 0; while (reader.next()) { String[] row = reader.getRow(); Assert.assertEquals(9, row.length); System.out.println(ArrayUtils.toString(row)); rowNumber++;/*from w ww.j av a 2 s . c o m*/ } reader.close(); Assert.assertEquals(10000, rowNumber); }
From source file:org.apache.mahout.df.mapreduce.partial.Step2Mapper.java
@Override protected void setup(Context context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); // get the cached files' paths URI[] files = DistributedCache.getCacheFiles(conf); log.info("DistributedCache.getCacheFiles(): {}", ArrayUtils.toString(files)); if ((files == null) || (files.length < 2)) { throw new IllegalArgumentException("missing paths from the DistributedCache"); }/*from w w w . j a va 2s . com*/ Path datasetPath = new Path(files[0].getPath()); Dataset dataset = Dataset.load(conf, datasetPath); int numMaps = Builder.getNumMaps(conf); int p = conf.getInt("mapred.task.partition", -1); // total number of trees in the forest int numTrees = Builder.getNbTrees(conf); if (numTrees == -1) { throw new IllegalArgumentException("numTrees not found !"); } int nbConcerned = nbConcerned(numMaps, numTrees, p); keys = new TreeID[nbConcerned]; trees = new Node[nbConcerned]; Path forestPath = new Path(files[1].getPath()); FileSystem fs = forestPath.getFileSystem(conf); int numInstances = InterResults.load(fs, forestPath, numMaps, numTrees, p, keys, trees); log.debug("partition: {} numInstances: {}", p, numInstances); configure(p, dataset, keys, trees, numInstances); }
From source file:org.apache.ojb.broker.core.IdentityFactoryImpl.java
/** * Helper method which supports creation of proper error messages. * * @param ex An exception to include or <em>null</em>. * @param message The error message or <em>null</em>. * @param objectToIdentify The current used object or <em>null</em>. * @param topLevelClass The object top-level class or <em>null</em>. * @param realClass The object real class or <em>null</em>. * @param pks The associated PK values of the object or <em>null</em>. * @return The generated exception./*from w ww .j a v a 2s. com*/ */ private PersistenceBrokerException createException(final Exception ex, String message, final Object objectToIdentify, Class topLevelClass, Class realClass, Object[] pks) { final String eol = SystemUtils.LINE_SEPARATOR; StringBuffer msg = new StringBuffer(); if (message == null) { msg.append("Unexpected error: "); } else { msg.append(message).append(" :"); } if (topLevelClass != null) msg.append(eol).append("objectTopLevelClass=").append(topLevelClass.getName()); if (realClass != null) msg.append(eol).append("objectRealClass=").append(realClass.getName()); if (pks != null) msg.append(eol).append("pkValues=").append(ArrayUtils.toString(pks)); if (objectToIdentify != null) msg.append(eol).append("object to identify: ").append(objectToIdentify); if (ex != null) { // add causing stack trace Throwable rootCause = ExceptionUtils.getRootCause(ex); if (rootCause != null) { msg.append(eol).append("The root stack trace is --> "); String rootStack = ExceptionUtils.getStackTrace(rootCause); msg.append(eol).append(rootStack); } return new PersistenceBrokerException(msg.toString(), ex); } else { return new PersistenceBrokerException(msg.toString()); } }
From source file:org.apache.ojb.broker.Identity.java
private ClassNotPersistenceCapableException createException(String msg, final Object objectToIdentify, final Exception e) { final String eol = SystemUtils.LINE_SEPARATOR; if (msg == null) { msg = "Unexpected error:"; }// ww w.j av a 2s .co m if (e != null) { return new ClassNotPersistenceCapableException(msg + eol + "objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol + "objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol + "pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) + (objectToIdentify != null ? (eol + "object to identify: " + objectToIdentify) : ""), e); } else { return new ClassNotPersistenceCapableException(msg + eol + "objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol + "objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol + "pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) + eol + "object to identify: " + objectToIdentify); } }
From source file:org.apache.ojb.odmg.ObjectEnvelopeOrdering.java
/** * Reorders the object envelopes. The new order is available from the * <code>ordering</code> property. * @see #getOrdering()/*from ww w. j ava 2s . c o m*/ */ public void reorder() { int newOrderIndex = 0; long t1 = 0, t2 = 0, t3; if (log.isDebugEnabled()) { t1 = System.currentTimeMillis(); } newOrder = new Identity[originalOrder.size()]; if (log.isDebugEnabled()) log.debug("Orginal order: " + originalOrder); // set up the vertex array in the order the envelopes were added List vertexList = new ArrayList(originalOrder.size()); // int vertexIndex = 0; for (Iterator it = originalOrder.iterator(); it.hasNext();) { ObjectEnvelope envelope = (ObjectEnvelope) envelopes.get(it.next()); if (envelope.needsUpdate() || envelope.needsInsert() || envelope.needsDelete()) { Vertex vertex = new Vertex(envelope); vertexList.add(vertex); if (log.isDebugEnabled()) { log.debug("Add new Vertex object " + envelope.getIdentity() + " to VertexList"); } } else { // envelope is clean - just add identity to new order newOrder[newOrderIndex++] = envelope.getIdentity(); if (log.isDebugEnabled()) { log.debug("Add unmodified object " + envelope.getIdentity() + " to new OrderList"); } } } vertices = (Vertex[]) vertexList.toArray(new Vertex[vertexList.size()]); // set up the edges edgeList = new ArrayList(2 * vertices.length); for (int i = 0; i < vertices.length; i++) { addEdgesForVertex(vertices[i]); } if (log.isDebugEnabled()) { t2 = System.currentTimeMillis(); log.debug("Building object envelope graph took " + (t2 - t1) + " ms"); log.debug("Object envelope graph contains " + vertices.length + " vertices" + " and " + edgeList.size() + " edges"); } int remainingVertices = vertices.length; int iterationCount = 0; while (remainingVertices > 0) { // update iteration count iterationCount++; // update incoming edge counts for (Iterator it = edgeList.iterator(); it.hasNext();) { Edge edge = (Edge) it.next(); if (!edge.isProcessed()) { if (log.isDebugEnabled()) { final String msg = "Add weight '" + edge.getWeight() + "' for terminal vertex " + edge.getTerminalVertex() + " of edge " + edge; log.debug(msg); } edge.getTerminalVertex().incrementIncomingEdgeWeight(edge.getWeight()); } } // find minimum weight of incoming edges of a vertex int minIncomingEdgeWeight = Integer.MAX_VALUE; for (int i = 0; i < vertices.length; i++) { Vertex vertex = vertices[i]; if (!vertex.isProcessed() && minIncomingEdgeWeight > vertex.getIncomingEdgeWeight()) { minIncomingEdgeWeight = vertex.getIncomingEdgeWeight(); if (minIncomingEdgeWeight == 0) { // we won't get any lower break; } } } // process vertices having minimum incoming edge weight int processCount = 0; for (int i = 0; i < vertices.length; i++) { Vertex vertex = vertices[i]; if (!vertex.isProcessed() && vertex.getIncomingEdgeWeight() == minIncomingEdgeWeight) { newOrder[newOrderIndex++] = vertex.getEnvelope().getIdentity(); vertex.markProcessed(); processCount++; if (log.isDebugEnabled()) { log.debug("add minimum edge weight - " + minIncomingEdgeWeight + ", newOrderList: " + ArrayUtils.toString(newOrder)); } } vertex.resetIncomingEdgeWeight(); } if (log.isDebugEnabled()) { log.debug("Processed " + processCount + " of " + remainingVertices + " remaining vertices in iteration #" + iterationCount); } remainingVertices -= processCount; } if (log.isDebugEnabled()) { t3 = System.currentTimeMillis(); log.debug("New ordering: " + ArrayUtils.toString(newOrder)); log.debug("Processing object envelope graph took " + (t3 - t2) + " ms"); } }
From source file:org.apache.ranger.audit.utils.InMemoryJAASConfiguration.java
@Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { LOG.trace("==> InMemoryJAASConfiguration.getAppConfigurationEntry( {} )", name); AppConfigurationEntry[] ret = null; if (parent != null) { ret = parent.getAppConfigurationEntry(name); }//from w w w . ja va2 s . com if (ret == null || ret.length == 0) { List<AppConfigurationEntry> retList = applicationConfigEntryMap.get(name); if (retList != null && retList.size() > 0) { int sz = retList.size(); ret = new AppConfigurationEntry[sz]; ret = retList.toArray(ret); } } LOG.trace("<== InMemoryJAASConfiguration.getAppConfigurationEntry( {} ) : {}", name, ArrayUtils.toString(ret)); return ret; }
From source file:org.apereo.lap.services.BaseInputHandlerService.java
public static BaseInputHandlerService getInputHandler(String type, HierarchicalConfiguration sourceConfiguration, ConfigurationService configuration, StorageService storage) {/*ww w . ja v a2 s. c om*/ if (StringUtils.equalsIgnoreCase(type, BaseInputHandlerService.Type.SAMPLECSV.name())) { return new SampleCSVInputHandlerService(configuration, storage, sourceConfiguration); } if (StringUtils.equalsIgnoreCase(type, BaseInputHandlerService.Type.CSV.name())) { return new CSVInputHandlerService(configuration, storage, sourceConfiguration); } throw new IllegalArgumentException("collection type (" + type + ") does not match the valid types: " + ArrayUtils.toString(Type.values())); }
From source file:org.apereo.lap.services.input.BaseInputHandler.java
public static String parseString(String string, String[] valid, boolean cannotBeBlank, String name) { boolean blank = StringUtils.isBlank(string); if (cannotBeBlank && blank) { throw new IllegalArgumentException(name + " (" + string + ") cannot be blank"); } else if (!blank) { if (valid != null && valid.length > 0) { if (!ArrayUtils.contains(valid, string)) { // invalid if not in the valid set throw new IllegalArgumentException( name + " (" + string + ") must be in the valid set: " + ArrayUtils.toString(valid)); }/*from w w w .j a v a 2 s . co m*/ } } return string; }
From source file:org.bdval.ConsensusBDVModel.java
/** * Create a model that is a consensus of a number of given juror models. * @param modelFilenamePrefix Prefix to use for all files associated with this BDVModel * @param jurorModelFilenamePrefixes The prefix to use for the juror models *//* w w w.j a v a 2 s . c o m*/ public ConsensusBDVModel(final String modelFilenamePrefix, final String... jurorModelFilenamePrefixes) { super(modelFilenamePrefix); if (LOG.isDebugEnabled()) { LOG.debug("Creating consensus model with prefix: " + modelFilenamePrefix); LOG.debug("Composed of the following juror models"); LOG.debug(ArrayUtils.toString(jurorModelFilenamePrefixes)); } for (final String jurorModelFilenamePrefix : jurorModelFilenamePrefixes) { // remove ".model" or ".zip" extensions String prefix = removeSuffix(jurorModelFilenamePrefix, ".model"); prefix = removeSuffix(prefix, ".zip"); this.jurorModelFilenamePrefixes.add(prefix); } }