List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:edu.cornell.med.icb.goby.stats.DifferentialExpressionCalculator.java
public String[] samples() { final Set<String> sampleSet = sampleToGroupMap.keySet(); return sampleSet.toArray(new String[sampleSet.size()]); }
From source file:com.mirth.connect.plugins.httpauth.digest.DigestAuthenticator.java
/** * Iterates through all nonces in the cache and removes any that are expired. *//*from w w w . j a v a 2s . c o m*/ private void cleanupNonces() { Set<String> keySet = nonceMap.keySet(); for (String nonceString : keySet.toArray(new String[keySet.size()])) { Nonce nonce = nonceMap.get(nonceString); if (nonce != null && nonce.isExpired()) { nonceMap.remove(nonceString); } } }
From source file:com.google.dart.tools.internal.search.ui.FindReferencesAction.java
private List<SearchMatch> findElementReferences(SearchEngine searchEngine, Element searchElement) { Element[] refElements;// w w w.j av a 2 s.c o m if (searchElement instanceof MethodElement || searchElement instanceof FieldElement) { // field or method ClassMemberElement member = (ClassMemberElement) searchElement; Set<ClassMemberElement> hierarchyMembers = HierarchyUtils.getHierarchyMembers(searchEngine, member); refElements = hierarchyMembers.toArray(new ClassMemberElement[hierarchyMembers.size()]); } else if (searchElement.getEnclosingElement() instanceof ClassElement && searchElement instanceof PropertyAccessorElement) { // class property accessor PropertyAccessorElement accessor = (PropertyAccessorElement) searchElement; ClassMemberElement property = (ClassMemberElement) accessor.getVariable(); Set<ClassMemberElement> hierarchyMembers = HierarchyUtils.getHierarchyMembers(searchEngine, property); Set<PropertyAccessorElement> hierarchyAccessors = Sets.newHashSet(); for (ClassMemberElement hierarchyMember : hierarchyMembers) { if (hierarchyMember instanceof FieldElement) { FieldElement hierarchyField = (FieldElement) hierarchyMember; if (accessor.isGetter()) { hierarchyAccessors.add(hierarchyField.getGetter()); } else if (accessor.isSetter()) { hierarchyAccessors.add(hierarchyField.getSetter()); } } } refElements = hierarchyAccessors.toArray(new PropertyAccessorElement[hierarchyAccessors.size()]); } else { // some other element refElements = new Element[] { searchElement }; } // find references to "refElements" List<SearchMatch> references = Lists.newArrayList(); for (Element refElement : refElements) { references.addAll(searchEngine.searchReferences(refElement, null, new SearchFilter() { @Override public boolean passes(SearchMatch match) { MatchKind kind = match.getKind(); if (kind == MatchKind.CONSTRUCTOR_DECLARATION) { return false; } if (kind == MatchKind.ANGULAR_CLOSING_TAG_REFERENCE) { return false; } return true; } })); } return references; }
From source file:jp.co.nemuzuka.dao.UploadFileDao.java
/** * ?./*from w w w.j a v a 2 s . c om*/ * ??????? * @param ticketKeyToString ?Key * @param projectKeyString Key * @return */ public List<UploadFileModel> getList(String ticketKeyToString, String projectKeyString) { UploadFileModelMeta e = (UploadFileModelMeta) getModelMeta(); Set<FilterCriterion> filterSet = new HashSet<FilterCriterion>(); if (StringUtils.isNotEmpty(ticketKeyToString)) { filterSet.add(e.parentKey.equal(Datastore.stringToKey(ticketKeyToString))); } if (StringUtils.isNotEmpty(projectKeyString)) { filterSet.add(e.projectKey.equal(Datastore.stringToKey(projectKeyString))); } return Datastore.query(e).filter(filterSet.toArray(new FilterCriterion[0])).sortInMemory(e.key.asc) .asList(); }
From source file:hoot.services.controllers.osm.OSMTestUtils.java
private static void verifyTestWaysUnmodified(Set<Long> wayIds, Set<Long> nodeIds, long changesetId, boolean verifyTags) { Long[] nodeIdsArr = nodeIds.toArray(new Long[nodeIds.size()]); Long[] wayIdsArr = wayIds.toArray(new Long[wayIds.size()]); Map<Long, CurrentWays> ways = createQuery(getMapId()).from(currentWays) .where((currentWays.changesetId.eq(changesetId))) .transform(groupBy(currentWays.id).as(currentWays)); assertEquals(3, ways.size());/* w w w. j a v a2 s .com*/ CurrentWays wayRecord = ways.get(wayIdsArr[0]); assertEquals(new Long(changesetId), wayRecord.getChangesetId()); assertEquals(wayIdsArr[0], wayRecord.getId()); assertEquals(new Long(1), wayRecord.getVersion()); QCurrentWayNodes currentWayNodes = QCurrentWayNodes.currentWayNodes; List<CurrentWayNodes> wayNodes = createQuery(getMapId()).select(QCurrentWayNodes.currentWayNodes) .from(currentWayNodes).where(currentWayNodes.wayId.eq(wayIdsArr[0])) .orderBy(currentWayNodes.sequenceId.asc()).fetch(); assertEquals(3, wayNodes.size()); CurrentWayNodes wayNode = wayNodes.get(0); assertEquals(nodeIdsArr[0], wayNode.getNodeId()); assertEquals(new Long(1), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); wayNode = wayNodes.get(1); assertEquals(nodeIdsArr[1], wayNode.getNodeId()); assertEquals(new Long(2), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); wayNode = wayNodes.get(2); assertEquals(nodeIdsArr[4], wayNode.getNodeId()); assertEquals(new Long(3), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); if (verifyTags) { Map<String, String> tags = PostgresUtils.postgresObjToHStore(wayRecord.getTags()); assertEquals(2, tags.size()); assertEquals("val 1", tags.get("key 1")); assertEquals("val 2", tags.get("key 2")); } wayRecord = ways.get(wayIdsArr[1]); assertEquals(new Long(changesetId), wayRecord.getChangesetId()); assertEquals(wayIdsArr[1], wayRecord.getId()); assertEquals(new Long(1), wayRecord.getVersion()); wayNodes = createQuery(getMapId()).select(QCurrentWayNodes.currentWayNodes).from(currentWayNodes) .where(currentWayNodes.wayId.eq(wayIdsArr[1])).orderBy(currentWayNodes.sequenceId.asc()).fetch(); assertEquals(2, wayNodes.size()); wayNode = wayNodes.get(0); assertEquals(nodeIdsArr[2], wayNode.getNodeId()); assertEquals(new Long(1), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); wayNode = wayNodes.get(1); assertEquals(nodeIdsArr[1], wayNode.getNodeId()); assertEquals(new Long(2), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); if (verifyTags) { assertTrue((wayRecord.getTags() == null) || PostgresUtils.postgresObjToHStore(wayRecord.getTags()).isEmpty()); } wayRecord = ways.get(wayIdsArr[2]); assertEquals(new Long(changesetId), wayRecord.getChangesetId()); assertEquals(wayIdsArr[2], wayRecord.getId()); assertEquals(new Long(1), wayRecord.getVersion()); wayNodes = createQuery(getMapId()).select(QCurrentWayNodes.currentWayNodes).from(currentWayNodes) .where(currentWayNodes.wayId.eq(wayIdsArr[2])).orderBy(currentWayNodes.sequenceId.asc()).fetch(); assertEquals(2, wayNodes.size()); wayNode = wayNodes.get(0); assertEquals(nodeIdsArr[0], wayNode.getNodeId()); assertEquals(new Long(1), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); wayNode = wayNodes.get(1); assertEquals(nodeIdsArr[1], wayNode.getNodeId()); assertEquals(new Long(2), wayNode.getSequenceId()); assertEquals(wayRecord.getId(), wayNode.getWayId()); if (verifyTags) { Map<String, String> tags = PostgresUtils.postgresObjToHStore(wayRecord.getTags()); assertEquals(1, tags.size()); assertEquals("val 3", tags.get("key 3")); } }
From source file:com.splicemachine.mrio.api.SpliceTableMapReduceUtil.java
/** * Add the jars containing the given classes to the job's configuration * such that JobClient will ship them to the cluster and add them to * the DistributedCache.// w w w .jav a 2 s . c om */ public static void addDependencyJars(Configuration conf, Class... classes) throws IOException { FileSystem localFs = FileSystem.getLocal(conf); Set<String> jars = new HashSet<String>(); // Add jars that are already in the tmpjars variable jars.addAll(conf.getStringCollection("tmpjars")); // Add jars containing the specified classes for (Class clazz : classes) { if (clazz == null) continue; String pathStr = findOrCreateJar(clazz); if (pathStr == null) { LOG.warn("Could not find jar for class " + clazz + " in order to ship it to the cluster."); continue; } Path path = new Path(pathStr); if (!localFs.exists(path)) { LOG.warn("Could not validate jar file " + path + " for class " + clazz); continue; } jars.add(path.makeQualified(localFs).toString()); } if (jars.isEmpty()) return; conf.set("tmpjars", StringUtils.arrayToString(jars.toArray(new String[0]))); }
From source file:edu.wisc.my.stats.dao.support.ConsolidatingQueryInformationDao.java
/** * @see edu.wisc.my.stats.dao.QueryInformationDao#getfactByIdMap() */// www .j ava 2s.co m @SuppressWarnings("unchecked") public Map<Long, Fact> getfactByIdMap() { final Set<Map<Long, Fact>> queryInformationByFactMaps = new HashSet<Map<Long, Fact>>(); for (final QueryInformationDao queryInformationDao : this.readableQueryInformationDaos) { final Map<Long, Fact> queryInformationByFactMap = queryInformationDao.getfactByIdMap(); queryInformationByFactMaps.add(queryInformationByFactMap); } final CompositeMap cm = new CompositeMap( queryInformationByFactMaps.toArray(new Map[queryInformationByFactMaps.size()])); return Collections.unmodifiableMap(cm); //will this work? }
From source file:NaraePreference.java
public String[] getValue(String key, String[] defaultvalue) { try {/*from www . j ava 2 s.c o m*/ Set<String> stringSet = pref.getStringSet(key, null); return stringSet.toArray(new String[stringSet.size()]); } catch (Exception e) { return defaultvalue; } }
From source file:com.linkedin.pinot.core.segment.index.readers.ImmutableDictionaryReaderTest.java
@BeforeClass public void setUp() throws Exception { FileUtils.deleteQuietly(TEMP_DIR);//from ww w .ja v a 2 s. c o m IntOpenHashSet intSet = new IntOpenHashSet(); while (intSet.size() < NUM_VALUES) { intSet.add(RANDOM.nextInt()); } _intValues = intSet.toIntArray(); Arrays.sort(_intValues); LongOpenHashSet longSet = new LongOpenHashSet(); while (longSet.size() < NUM_VALUES) { longSet.add(RANDOM.nextLong()); } _longValues = longSet.toLongArray(); Arrays.sort(_longValues); FloatOpenHashSet floatSet = new FloatOpenHashSet(); while (floatSet.size() < NUM_VALUES) { floatSet.add(RANDOM.nextFloat()); } _floatValues = floatSet.toFloatArray(); Arrays.sort(_floatValues); DoubleOpenHashSet doubleSet = new DoubleOpenHashSet(); while (doubleSet.size() < NUM_VALUES) { doubleSet.add(RANDOM.nextDouble()); } _doubleValues = doubleSet.toDoubleArray(); Arrays.sort(_doubleValues); Set<String> stringSet = new HashSet<>(); while (stringSet.size() < NUM_VALUES) { stringSet.add(RandomStringUtils.random(RANDOM.nextInt(MAX_STRING_LENGTH)).replace('\0', ' ')); } _stringValues = stringSet.toArray(new String[NUM_VALUES]); Arrays.sort(_stringValues); try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_intValues, new DimensionFieldSpec(INT_COLUMN_NAME, FieldSpec.DataType.INT, true), TEMP_DIR)) { dictionaryCreator.build(); } try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_longValues, new DimensionFieldSpec(LONG_COLUMN_NAME, FieldSpec.DataType.LONG, true), TEMP_DIR)) { dictionaryCreator.build(); } try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_floatValues, new DimensionFieldSpec(FLOAT_COLUMN_NAME, FieldSpec.DataType.FLOAT, true), TEMP_DIR)) { dictionaryCreator.build(); } try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_doubleValues, new DimensionFieldSpec(DOUBLE_COLUMN_NAME, FieldSpec.DataType.DOUBLE, true), TEMP_DIR)) { dictionaryCreator.build(); } try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_stringValues, new DimensionFieldSpec(STRING_COLUMN_NAME, FieldSpec.DataType.STRING, true), TEMP_DIR)) { dictionaryCreator.build(); _numBytesPerStringValue = dictionaryCreator.getNumBytesPerString(); } }
From source file:com.dianping.wed.cache.redis.WeddingRedisServiceImplTest.java
private void testSortedSet() { //************************** Sorted Set ********************************// //key ?/*from w w w. j ava2 s . co m*/ weddingRedisService.del(key); //? a:1 long zAdd = weddingRedisService.zAdd(key, 1, "a"); Assert.assertTrue(zAdd == 1); //a:1.1 zAdd = weddingRedisService.zAdd(key, 1.1, "a"); Assert.assertTrue(zAdd == 0); // b:2.0 c:3.0 d:4.0 Map<String, Double> scoreMembers = new HashMap<String, Double>(); scoreMembers.put("b", 2.0); scoreMembers.put("c", 3.0); scoreMembers.put("d", 4.0); long zAdds = weddingRedisService.zMAdd(key, scoreMembers); Assert.assertTrue(zAdds == 3); //?? long zCard = weddingRedisService.zCard(key); Assert.assertTrue(zCard == 4); //?[1,2] long zCount = weddingRedisService.zCount(key, 1, 2); Assert.assertTrue(zCount == 2); //a0.1?avalue?1.2 double zIncrBy = weddingRedisService.zIncrBy(key, 0.1, "a"); //???1.20000000000..2 //Assert.assertTrue(zIncrBy == 1.2); //??01member? Set<String> zRange = weddingRedisService.zRange(key, 0, 1); Assert.assertTrue(zRange.size() == 2); Assert.assertTrue(zRange.toArray(new String[0])[0].equals("a")); //??01member? Set<String> zRevRange = weddingRedisService.zRevRange(key, 0, 1); Assert.assertTrue(zRevRange.size() == 2); Assert.assertTrue(zRevRange.toArray(new String[0])[0].equals("d")); //?? memberscore? Set<WeddingRedisTupleDTO> zRangeWithScores = weddingRedisService.zRangeWithScores(key, -2, -1); Assert.assertTrue(zRangeWithScores.size() == 2); Assert.assertTrue( zRangeWithScores.toArray((new WeddingRedisTupleDTO[0]))[1].getScore().equals(new Double(4.0))); //?? memberscore? Set<WeddingRedisTupleDTO> zRevRangeWithScores = weddingRedisService.zRevRangeWithScores(key, -2, -1); Assert.assertTrue(zRevRangeWithScores.size() == 2); Assert.assertTrue( zRevRangeWithScores.toArray((new WeddingRedisTupleDTO[0]))[0].getScore().equals(new Double(2.0))); //?,?c??(0??) long zRank = weddingRedisService.zRank(key, "c"); Assert.assertTrue(zRank == 2); //?,?c??(0??) long zRevRank = weddingRedisService.zRevRank(key, "c"); Assert.assertTrue(zRevRank == 1); //??d Double zScore = weddingRedisService.zScore(key, "d"); Assert.assertTrue(zScore == 4.0); //?a long zRem = weddingRedisService.zRem(key, "a"); Assert.assertTrue(zRem == 1); }