List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY
String[] EMPTY_STRING_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.
Click Source Link
String
array. From source file:org.apache.hadoop.hive.ql.exec.tez.Utils.java
public static SplitLocationProvider getSplitLocationProvider(Configuration conf, Logger LOG) throws IOException { boolean useCustomLocations = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_MODE).equals("llap") && HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_CLIENT_CONSISTENT_SPLITS); SplitLocationProvider splitLocationProvider; LOG.info("SplitGenerator using llap affinitized locations: " + useCustomLocations); if (useCustomLocations) { LlapRegistryService serviceRegistry = LlapRegistryService.getClient(conf); LOG.info("Using LLAP instance " + serviceRegistry.getApplicationId()); Collection<ServiceInstance> serviceInstances = serviceRegistry.getInstances() .getAllInstancesOrdered(true); Preconditions.checkArgument(!serviceInstances.isEmpty(), "No running LLAP daemons! Please check LLAP service status and zookeeper configuration"); ArrayList<String> locations = new ArrayList<>(serviceInstances.size()); for (ServiceInstance serviceInstance : serviceInstances) { if (LOG.isDebugEnabled()) { LOG.debug("Adding " + serviceInstance.getWorkerIdentity() + " with hostname=" + serviceInstance.getHost() + " to list for split locations"); }/* w ww .j av a2s. co m*/ locations.add(serviceInstance.getHost()); } splitLocationProvider = new HostAffinitySplitLocationProvider(locations); } else { splitLocationProvider = new SplitLocationProvider() { @Override public String[] getLocations(InputSplit split) throws IOException { if (split == null) { return null; } String[] locations = split.getLocations(); if (locations != null && locations.length == 1) { if ("localhost".equals(locations[0])) { return ArrayUtils.EMPTY_STRING_ARRAY; } } return locations; } }; } return splitLocationProvider; }
From source file:org.apache.jackrabbit.core.query.lucene.JahiaLuceneQueryFactoryImpl.java
private boolean checkIndexedAcl(Map<String, Boolean> checkedAcls, IndexedNodeInfo infos) throws RepositoryException { boolean canRead = true; String[] acls = infos.getAclUuid() != null ? Patterns.SPACE.split(infos.getAclUuid()) : ArrayUtils.EMPTY_STRING_ARRAY; ArrayUtils.reverse(acls);// w w w .j av a 2 s. c om for (String acl : acls) { if (acl.contains("/")) { // ACL indexed contains a single user ACE, get the username String singleUser = StringUtils.substringAfter(acl, "/"); acl = StringUtils.substringBefore(acl, "/"); if (singleUser.contains("/")) { // Granted roles are specified in the indexed entry String roles = StringUtils.substringBeforeLast(singleUser, "/"); singleUser = StringUtils.substringAfterLast(singleUser, "/"); if (!singleUser.equals(session.getUserID())) { // If user does not match, skip this ACL continue; } else { // If user matches, check if one the roles gives the read permission for (String role : StringUtils.split(roles, '/')) { if (((JahiaAccessManager) session.getAccessControlManager()).matchPermission( Sets.newHashSet(Privilege.JCR_READ + "_" + session.getWorkspace().getName()), role)) { // User and role matches, read is granted return true; } } } } else { if (!singleUser.equals(session.getUserID())) { // If user does not match, skip this ACL continue; } // Otherwise, do normal ACL check. } } // Verify first if this acl has already been checked Boolean aclChecked = checkedAcls.get(acl); if (aclChecked == null) { try { canRead = session.getAccessManager().canRead(null, new NodeId(acl)); checkedAcls.put(acl, canRead); } catch (RepositoryException e) { } } else { canRead = aclChecked; } break; } return canRead; }
From source file:org.apache.tez.common.TezCommonUtils.java
/** * Splits a comma separated value <code>String</code>, trimming leading and trailing whitespace on each value. * @param str a comma separated <String> with values * @return an array of <code>String</code> values *///from www. j ava2 s . com public static String[] getTrimmedStrings(String str) { if (null == str || (str = str.trim()).isEmpty()) { return ArrayUtils.EMPTY_STRING_ARRAY; } return str.split("\\s*,\\s*"); }
From source file:org.bdval.DAVMode.java
/** * Obtain a classifier for training with known labels. * * @param processedTable/*from w ww .jav a2 s. c om*/ * @param labelValueGroups * @return * @throws TypeMismatchException * @throws InvalidColumnException */ protected ClassificationHelper getClassifier(final Table processedTable, final List<Set<String>> labelValueGroups) throws TypeMismatchException, InvalidColumnException { final ClassificationHelper helper = new ClassificationHelper(); // libSVM: // Calculate SumOfSquares sum over all samples x.x: final SumOfSquaresCalculatorRowProcessor calculator = new SumOfSquaresCalculatorRowProcessor(processedTable, davOptions.IDENTIFIER_COLUMN_NAME); processedTable.processRows(calculator); // use the svmLight default C value, so that results are comparable: final double C = processedTable.getRowNumber() / calculator.getSumOfSquares(); final double gamma = 1d / processedTable.getColumnNumber(); // 1/<number of features> default for libSVM try { final Classifier classifier = (Classifier) davOptions.classiferClass.newInstance(); final LoadClassificationProblem loader = new LoadClassificationProblem(); final ClassificationProblem problem = classifier.newProblem(0); loader.load(problem, processedTable, "ID_REF", labelValueGroups); helper.problem = problem; if (classifier instanceof LibSvmClassifier) { // set default value of C classifier.getParameters().setParameter("C", C); classifier.getParameters().setParameter("gamma", gamma); } if (davOptions.classifierParameters.length == 1 && davOptions.classifierParameters[0].length() == 0) { davOptions.classifierParameters = ArrayUtils.EMPTY_STRING_ARRAY; } helper.parseParameters(classifier, davOptions.classifierParameters); helper.classifier = classifier; helper.parameters = classifier.getParameters(); return helper; } catch (IllegalAccessException e) { LOG.error("Cannot instantiate classifier.", e); } catch (InstantiationException e) { LOG.error("Cannot instantiate classifier.", e); } assert false : "Could not instantiate classifier"; return null; }
From source file:org.bdval.DiscoverWithGeneticAlgorithm.java
private String[] parseDiscreteParameters(final JSAPResult result) { final String paramDefs = result.getString("discrete-parameters"); if (paramDefs == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } else {//w ww . j a v a2 s . c o m return paramDefs.split("[:]"); } }
From source file:org.bdval.ExecuteSplitsMode.java
/** * Parse properties to extract optional model id definitions. The format is as follow: * <p/>/*from w w w . j a va 2 s. com*/ * <PRE> * define.model-id.column-id=modelid-noScaler * define.model-id.modelid-noScaler.exclude=a,b * define.model-id.modelid-noScaler.exclude.a.argument=scaler-name * define.model-id.modelid-noScaler.exclude.a.skip=1 * define.model-id.modelid-noScaler.exclude.b.argument=normalizer-name * define.model-id.modelid-noScaler.exclude.b.skip=1 * </PRE> * These properties would define one new model-id called, to be written in a column called modelid-noScaler, * which excludes two arguments and one value each from the hashcode modelId calculation. */ public static OptionalModelId[] parseOptionalModelIdProperties(final Properties configurationProperties) { final ObjectList<OptionalModelId> result = new ObjectArrayList<OptionalModelId>(); if (configurationProperties != null) { // inspect properties to figure out which optional model ids to create: final ObjectSet<String> optionalModelIdColumnNames = new ObjectArraySet<String>(); for (final String propertyName : configurationProperties.stringPropertyNames()) { if (propertyName.startsWith("define.model-id.column-id")) { final String columnIdNames = configurationProperties.getProperty(propertyName); final String[] names = columnIdNames.split(","); for (final String name : names) { optionalModelIdColumnNames.add(name); } } } for (final String optionalColumnId : optionalModelIdColumnNames) { final String defineModelIdExcludePropertyName = "define.model-id." + optionalColumnId + ".exclude"; final String argumentKeys = configurationProperties.getProperty(defineModelIdExcludePropertyName); final String[] keys; if (argumentKeys == null) { System.err.println( "Error parsing properties. Cannot find key=" + defineModelIdExcludePropertyName); keys = ArrayUtils.EMPTY_STRING_ARRAY; } else { keys = argumentKeys.split(","); } final OptionalModelId newOne = new OptionalModelId(optionalColumnId); for (String key : keys) { key = key.trim(); final String excludeArgumentName = configurationProperties .getProperty(defineModelIdExcludePropertyName + "." + key + ".argument"); final String excludeArgumentSkip = configurationProperties .getProperty(defineModelIdExcludePropertyName + "." + key + ".skip"); newOne.addExcludeArgument(excludeArgumentName, Integer.parseInt(excludeArgumentSkip)); } result.add(newOne); LOGGER.debug("Defined modelId: " + newOne); } } return result.toArray(new OptionalModelId[result.size()]); }
From source file:org.bdval.util.TestShortHash.java
License:asdf
@Test public void testShortHash() { assertNull(ShortHash.shortHash((String) null)); assertNull(ShortHash.shortHash("")); assertNull(ShortHash.shortHash(" ")); assertNull(ShortHash.shortHash(" ")); assertNull(ShortHash.shortHash(ArrayUtils.EMPTY_STRING_ARRAY)); assertEquals("PHMJM", ShortHash.shortHash("A")); assertEquals("PHMJM", ShortHash.shortHash(new String[] { "A" })); assertEquals("OZKTS", ShortHash.shortHash("asdfasdf")); assertEquals("OZKTS", ShortHash.shortHash(new String[] { "asdfasdf" })); assertEquals("FIWCB", ShortHash.shortHash("foo bar")); assertEquals("FIWCB", ShortHash.shortHash(new String[] { "foo", "bar" })); final String stringWithQuotes = "Checks if a String is not empty (\"\"), not null and not whitespace only."; assertEquals("GDEQM", ShortHash.shortHash(stringWithQuotes)); assertEquals("GDEQM", ShortHash.shortHash(stringWithQuotes.split(" "))); final String stringWithArgs = "--this=that --fudge=cicle --cat=dog"; assertEquals("ADQVZ", ShortHash.shortHash(stringWithArgs)); assertEquals("ADQVZ", ShortHash.shortHash(stringWithArgs.split(" "))); }
From source file:org.eclim.plugin.core.preference.Preferences.java
/** * Gets the array value of a project option/preference. * * @param project The project./*from ww w . j a v a2 s. co m*/ * @param name The name of the option/preference. * @return The array value or and empty array if not found. */ public String[] getArrayValue(IProject project, String name) throws Exception { String value = getValues(project).get(name); if (value != null && value.trim().length() != 0) { return new Gson().fromJson(value, String[].class); } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.eclim.plugin.core.project.ProjectNatureFactory.java
/** * Gets array of registered nature aliases. * * @return Array of aliases./*from www . j ava 2s . co m*/ */ public static String[] getNatureAliases() { return natureAliases.keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY); }
From source file:org.eclim.plugin.dltk.preference.DltkInterpreterTypeManager.java
/** * Gets array of registered interpreter type aliases for the supplied eclipse * project nature.// w w w .ja v a2s.co m * * @param nature The eclipse project nature. * @return Array of aliases. */ public static String[] getIntepreterTypeAliases(String nature) { ArrayList<String> aliases = new ArrayList<String>(); for (String alias : interpreterTypeAliases.keySet()) { if (alias.startsWith(nature + '.')) { aliases.add(alias); } } return aliases.toArray(ArrayUtils.EMPTY_STRING_ARRAY); }