private void sampleThresholds(int yi){ _ti[yi] = (_newThresholds[yi].length >> 2); try{ Arrays.sort(_newThresholds[yi]);} catch(Throwable t){ System.out.println("got AIOOB during sort?! ary = " + Arrays.toString(_newThresholds[yi])); return; } // sort throws AIOOB sometimes! for (int i = 0; i < _newThresholds.length; i += 4) _newThresholds[yi][i >> 2] = _newThresholds[yi][i]; } @Override public void processRow(long gid, final double [] nums, final int ncats, final int [] cats, double [] responses /* time...*/){
public static void main(String[] args) { final String str = "<tag>apple</tag><b>hello</b><tag>orange</tag><tag>pear</tag>"; System.out.println(Arrays.toString(getTagValues(str).toArray())); // Prints [apple, orange, pear] } private static final Pattern TAG_REGEX = Pattern.compile("<tag>(.+?)</tag>"); private static List<String> getTagValues(final String str) { final List<String> tagValues = new ArrayList<String>(); final Matcher matcher = TAG_REGEX.matcher(str); while (matcher.find()) { tagValues.add(matcher.group(1)); } return tagValues; }
import java.util.*; //... List<int[]> rowList = new ArrayList<int[]>(); rowList.add(new int[] { 1, 2, 3 }); rowList.add(new int[] { 4, 5, 6 }); rowList.add(new int[] { 7, 8 }); for (int[] row : rowList) { System.out.println("Row = " + Arrays.toString(row)); } // prints: // Row = [1, 2, 3] // Row = [4, 5, 6] // Row = [7, 8] System.out.println(rowList.get(1)[1]); // prints "5"
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
@Test public void testGet() throws Exception { int getNum = 3000; List<String[]> keys = Lists.newArrayList(); for (int i = 0; i < getNum; i++) { String[] keyi = new String[] { "keyyyyy" + random.nextInt(sourceRowNum) }; keys.add(keyi); } long start = System.currentTimeMillis(); for (int i = 0; i < getNum; i++) { String[] row = lookupTable.getRow(new Array<>(keys.get(i))); if (row == null) { System.out.println("null value for key:" + Arrays.toString(keys.get(i))); } } long take = System.currentTimeMillis() - start; System.out.println("muliti get " + getNum + " rows, take " + take + " ms"); }
out.print(indentString(indent)); if (appendToHeader != null && !appendToHeader.isEmpty()) { out.println(xpl_note.displayName() + appendToHeader); } else { out.println(xpl_note.displayName()); if (outputOperators != null) { ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put(OUTPUT_OPERATORS, Arrays.toString(outputOperators.toArray())); Arrays.sort(methods, new MethodComparator()); out.print(" "); out.println(val); List l = val instanceof List ? (List)val : new ArrayList((Set)val); if (out != null && !skipHeader && l != null && !l.isEmpty()) { out.print(header);
final List<Cell> results = new ArrayList<>(); final List<Cell> actualKVs = new ArrayList<>(); final String columnRestrictionStr = columnArr.length == 0 ? "all columns" : ("columns=" + Arrays.toString(columnArr)); final String testDesc = "Bloom=" + bloomType + ", compr=" + comprAlgo + ", " long seekCount = StoreFileScanner.getSeekCount() - initialSeekCount; if (VERBOSE) { System.err.println("Seek count: " + seekCount + ", KVs returned: " + actualKVs.size() + ". " + testDesc + (lazySeekEnabled ? "\n" : ""));
String lastSegmentsFile = SegmentInfos.getLastCommitSegmentsFileName(files); if (lastSegmentsFile == null) { throw new IndexNotFoundException("no segments* file found in " + dir + ": files: " + Arrays.toString(files)); delCount += info.getDelCount(); infoStream.println(String.format(Locale.ROOT, "%.2f%% total deletions; %d documents; %d deleteions", 100.*delCount/maxDoc, maxDoc, result.segmentInfos.add(segInfoStat); msg(infoStream, " " + (1+i) + " of " + numSegments + ": name=" + info.info.name + " maxDoc=" + info.info.maxDoc()); segInfoStat.name = info.info.name;
/** * Traverse tree on the current level and starts procedure of child traversing. * * @param map The current state of the data. * @param nextPnt Next point. * @param dimensionNum Dimension number. */ private void traverseTree(Map<Integer, Double[]> map, Double[] nextPnt, int dimensionNum) { dimensionNum++; if (dimensionNum == sizeOfParamVector){ Double[] paramSet = Arrays.copyOf(nextPnt, sizeOfParamVector); System.out.println(Arrays.toString(paramSet)); params.add(paramSet); return; } Double[] valuesOfCurrDimension = map.get(dimensionNum); for (Double specificValue : valuesOfCurrDimension) { nextPnt[dimensionNum] = specificValue; traverseTree(map, nextPnt, dimensionNum); } } }
private String vectorToString(double[] vector) { List<String> tokens = Lists.newArrayListWithCapacity(this.dimensionIndex.size()); for (Map.Entry<String, Integer> dimension : dimensionIndex.entrySet()) { tokens.add(dimension.getKey() + ": " + vector[dimension.getValue()]); } return Arrays.toString(tokens.toArray()); }
static void assertFileContents(final int runNumber) throws IOException { final Path path = Paths.get(FOLDER + "/audit.tmp"); final List<String> lines = Files.readAllLines(path, Charset.defaultCharset()); int i = 1; final int size = lines.size(); for (final String string : lines) { if (string.startsWith(",,")) { final Path folder = Paths.get(FOLDER); final File[] files = folder.toFile().listFiles(); Arrays.sort(files); System.out.println("Run " + runNumber + ": " + Arrays.toString(files)); Assert.fail( String.format("Run %,d, line %,d of %,d: \"%s\" in %s", runNumber, i++, size, string, lines)); } } }
break; default: System.err.printf("最多支持载入3个模型,然而传入了多于3个: %s", Arrays.toString(models)); return; if (option.input == null) scanner = new Scanner(System.in); scanner = new Scanner(new File(option.input), "utf-8"); System.err.println(e.getMessage()); Args.usage(option); System.err.println("发生了IO异常,请检查文件路径"); e.printStackTrace();
private List<AndroidAnnotationsPlugin> loadPlugins() throws FileNotFoundException, VersionNotFoundException { ServiceLoader<AndroidAnnotationsPlugin> serviceLoader = ServiceLoader.load(AndroidAnnotationsPlugin.class, AndroidAnnotationsPlugin.class.getClassLoader()); List<AndroidAnnotationsPlugin> plugins = new ArrayList<>(); for (AndroidAnnotationsPlugin plugin : serviceLoader) { plugins.add(plugin); if (plugin.shouldCheckApiAndProcessorVersions()) { plugin.loadVersion(); } } LOGGER.info("Plugins loaded: {}", Arrays.toString(plugins.toArray())); return plugins; }
public static void main(String[] args) throws Exception { ArrayList<String[]> listOfStringArrays = new ArrayList<String[]>(); listOfStringArrays.add(new String[] {"x","y","z"}); listOfStringArrays.add(new String[] {"a","b","c"}); listOfStringArrays.add(new String[] {"m","n","o"}); Collections.sort(listOfStringArrays,new Comparator<String[]>() { public int compare(String[] strings, String[] otherStrings) { return strings[1].compareTo(otherStrings[1]); } }); for (String[] sa : listOfStringArrays) { System.out.println(Arrays.toString(sa)); } /* prints out [a, b, c] [m, n, o] [x, y, z] */ }
/** * Loads the first available library in the collection with the specified * {@link ClassLoader}. * * @throws IllegalArgumentException * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { List<Throwable> suppressed = new ArrayList<Throwable>(); for (String name : names) { try { load(name, loader); return; } catch (Throwable t) { suppressed.add(t); logger.debug("Unable to load the library '{}', trying next name...", name, t); } } IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); throw iae; }
throw new IOException(String.format("Path %s does not exist.", path)); log.info(String.format("Found %d input files at %s: %s", inputs.length, path, Arrays.toString(inputs))); for (FileStatus input : inputs) { allPaths.add(input.getPath().toString()); allPaths.size() % maxMappers == 0 ? allPaths.size() / maxMappers : allPaths.size() / maxMappers + 1; while (pathsIt.hasNext()) { Iterator<String> limitedIterator = Iterators.limit(pathsIt, numTasksPerMapper); splits.add(new GobblinSplit(Lists.newArrayList(limitedIterator)));