Java Code Examples for it.unimi.dsi.fastutil.longs.LongSet#size()
The following examples show how to use
it.unimi.dsi.fastutil.longs.LongSet#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AgreeSetGenerator.java From metanome-algorithms with Apache License 2.0 | 6 votes |
private boolean isSubset(IntList actuelList, Map<Long, LongSet> index) { boolean first = true; LongSet positions = new LongArraySet(); for (long e : actuelList) { if (!index.containsKey(Long.valueOf(e))) { return false; } if (first) { positions.addAll(index.get(Long.valueOf(e))); first = false; } else { this.intersect(positions, index.get(Long.valueOf(e))); // FIXME: Throws UnsupportedOperationExeption within fastUtil // positions.retainAll(index.get(e)); } if (positions.size() == 0) { return false; } } return true; }
Example 2
Source File: LongColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet uniqueElements = new LongOpenHashSet(); for (int i = 0; i < size(); i++) { uniqueElements.add(getLong(i)); } return uniqueElements.size(); }
Example 3
Source File: InstantColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet ints = new LongOpenHashSet(data.size()); for (long i : data) { ints.add(i); } return ints.size(); }
Example 4
Source File: DateTimeColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet ints = new LongOpenHashSet(data.size()); for (long i : data) { ints.add(i); } return ints.size(); }
Example 5
Source File: TopSecondDegreeByCountTweetRecsGenerator.java From GraphJet with Apache License 2.0 | 5 votes |
private static boolean isLessThanMinUserSocialProofSizeCombined( SmallArrayBasedLongToDoubleMap[] socialProofs, int minUserSocialProofSize, Set<byte[]> socialProofTypeUnions) { if (socialProofTypeUnions.isEmpty() || // check if the size of any social proof union is greater than minUserSocialProofSize before dedupping isSocialProofUnionSizeLessThanMin(socialProofs, minUserSocialProofSize, socialProofTypeUnions)) { return true; } LongSet uniqueNodes = new LongOpenHashSet(minUserSocialProofSize); for (byte[] socialProofTypeUnion: socialProofTypeUnions) { // Clear removes all elements, but does not change the size of the set. // Thus, we only use one LongOpenHashSet with at most a size of 2*minUserSocialProofSize uniqueNodes.clear(); for (byte socialProofType: socialProofTypeUnion) { if (socialProofs[socialProofType] != null) { for (int i = 0; i < socialProofs[socialProofType].size(); i++) { uniqueNodes.add(socialProofs[socialProofType].keys()[i]); if (uniqueNodes.size() >= minUserSocialProofSize) { return false; } } } } } return true; }
Example 6
Source File: TopSecondDegreeByCountTweetRecsGenerator.java From GraphJet with Apache License 2.0 | 5 votes |
private static boolean isLessThanMinUserSocialProofSizeCombined( SmallArrayBasedLongToDoubleMap[] socialProofs, int minUserSocialProofSize, Set<byte[]> socialProofTypeUnions) { if (socialProofTypeUnions.isEmpty() || // check if the size of any social proof union is greater than minUserSocialProofSize before dedupping isSocialProofUnionSizeLessThanMin(socialProofs, minUserSocialProofSize, socialProofTypeUnions)) { return true; } LongSet uniqueNodes = new LongOpenHashSet(minUserSocialProofSize); for (byte[] socialProofTypeUnion: socialProofTypeUnions) { // Clear removes all elements, but does not change the size of the set. // Thus, we only use one LongOpenHashSet with at most a size of 2*minUserSocialProofSize uniqueNodes.clear(); for (byte socialProofType: socialProofTypeUnion) { if (socialProofs[socialProofType] != null) { for (int i = 0; i < socialProofs[socialProofType].size(); i++) { uniqueNodes.add(socialProofs[socialProofType].keys()[i]); if (uniqueNodes.size() >= minUserSocialProofSize) { return false; } } } } } return true; }
Example 7
Source File: NodeMetadataSocialProofResult.java From GraphJet with Apache License 2.0 | 5 votes |
/** * Calculate the total number of interactions for the current nodeMetadataId (right node's metadata) * given the set of users (left nodes). * * @return the number of unique edgeType/user/tweet interactions. * For example (0 (byte), 12 (long), 99 (long)) would be a single unique interaction. */ public int getSocialProofSize() { int socialProofSize = 0; for (Long2ObjectMap<LongSet> userToTweetsMap: socialProof.values()) { for (LongSet connectingTweets: userToTweetsMap.values()) { socialProofSize += connectingTweets.size(); } } return socialProofSize; }
Example 8
Source File: SocialProofResult.java From GraphJet with Apache License 2.0 | 5 votes |
/** * Calculate the total number of interactions for current entity (right node) * on given set of users (left nodes). * * @return the number of interactions. */ public int getSocialProofSize() { int socialProofSize = 0; for (LongSet connectingUsers: socialProof.values()) { socialProofSize += connectingUsers.size(); } return socialProofSize; }
Example 9
Source File: LongColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet uniqueElements = new LongOpenHashSet(); for (int i = 0; i < size(); i++) { uniqueElements.add(getLong(i)); } return uniqueElements.size(); }
Example 10
Source File: InstantColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet ints = new LongOpenHashSet(data.size()); for (long i : data) { ints.add(i); } return ints.size(); }
Example 11
Source File: DateTimeColumn.java From tablesaw with Apache License 2.0 | 5 votes |
@Override public int countUnique() { LongSet ints = new LongOpenHashSet(data.size()); for (long i : data) { ints.add(i); } return ints.size(); }
Example 12
Source File: HashedColumnStore.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override protected void writeColumnsAndSample(RelationalInput input) throws InputIterationException, IOException { boolean isWritingAnyColumn = false; FileOutputStream[] out = new FileOutputStream[columnFiles.length]; FileChannel[] channel = new FileChannel[columnFiles.length]; ByteBuffer[] bb = new ByteBuffer[columnFiles.length]; for (int i = 0; i < columnFiles.length; i++) { if (!isNew[i]) continue; out[i] = new FileOutputStream(columnFiles[i]); channel[i] = out[i].getChannel(); bb[i] = ByteBuffer.allocateDirect(BUFFERSIZE); isWritingAnyColumn = true; } List<List<String>> alternativeSamples = new ArrayList<>(); final List<LongSet> sampledColumnValues = new ArrayList<>(); for (int i = 0; i < columnFiles.length; i++) { sampledColumnValues.add(new LongOpenHashSet(this.sampleGoal < 0 ? 1000 : this.sampleGoal)); } Long[] firstColumnValues = new Long[columnFiles.length]; int rowCounter = 0; DebugCounter counter = new DebugCounter(); while (input.hasNext()) { List<String> row = input.next(); boolean isSampleCompleted = true; boolean rowHasUnseenValue = false; for (int i = 0; i < columnFiles.length; i++) { // Write the hash to the column. String str = row.get(i); long hash = getHash(str, i); if (isNew[i]) { if (bb[i].remaining() == 0) { bb[i].flip(); channel[i].write(bb[i]); bb[i].clear(); } bb[i].putLong(hash); } // Keep track of the first column value and delete it if multiple values are observed. if (rowCounter == 0) firstColumnValues[i] = Long.valueOf(hash); else if (firstColumnValues[i] != null && firstColumnValues[i].longValue() != hash) firstColumnValues[i] = null; // Check if the value requests to put the row into the sample. if (hash != NULLHASH) { final LongSet sampledValues = sampledColumnValues.get(i); boolean shouldSample = this.sampleGoal < 0 || sampledValues.size() < this.sampleGoal; isSampleCompleted &= !shouldSample; if (shouldSample && sampledValues.add(hash)) { rowHasUnseenValue = true; } } } if (rowHasUnseenValue) { alternativeSamples.add(row); } counter.countUp(); rowCounter++; if (!isWritingAnyColumn && isSampleCompleted) break; } counter.done(); writeSample(alternativeSamples); // Check for constant and null columns. for (int i = 0; i < firstColumnValues.length; i++) { this.isNullColumn[i] = firstColumnValues[i] != null && firstColumnValues[i].longValue() == NULLHASH; this.isConstantColumn[i] = firstColumnValues[i] != null && firstColumnValues[i].longValue() != NULLHASH; } for (int i = 0; i < columnFiles.length; i++) { if (!isNew[i]) continue; bb[i].flip(); channel[i].write(bb[i]); out[i].close(); } }
Example 13
Source File: VirtualColumnStore.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override protected void writeColumnsAndSample(RelationalInput input) throws InputIterationException, IOException { List<List<String>> alternativeSamples = new ArrayList<>(); final List<LongSet> sampledColumnValues = new ArrayList<>(); for (int i = 0; i < this.getNumberOfColumns(); i++) { sampledColumnValues.add(new LongOpenHashSet(this.sampleGoal < 0 ? 1000 : this.sampleGoal)); } // Keeps track of the first value in each column if it is the only value seen. Long[] firstColumnValues = new Long[this.getNumberOfColumns()]; int rowCounter = 0; DebugCounter counter = new DebugCounter(); while (input.hasNext()) { List<String> row = input.next(); boolean isSampleCompleted = true; boolean rowHasUnseenValue = false; for (int i = 0; i < this.getNumberOfColumns(); i++) { // Write the hash to the column. String str = row.get(i); long hash = getHash(str, i); // Keep track of the first column value and delete it if multiple values are observed. if (rowCounter == 0) firstColumnValues[i] = Long.valueOf(hash); else if (firstColumnValues[i] != null && firstColumnValues[i].longValue() != hash) firstColumnValues[i] = null; // Check if the value requests to put the row into the sample. if (hash != NULLHASH) { final LongSet sampledValues = sampledColumnValues.get(i); boolean shouldSample = this.sampleGoal < 0 || sampledValues.size() < this.sampleGoal; isSampleCompleted &= !shouldSample; if (shouldSample && sampledValues.add(hash)) { rowHasUnseenValue = true; } } } if (rowHasUnseenValue) { alternativeSamples.add(row); } counter.countUp(); rowCounter++; if (isSampleCompleted) break; } counter.done(); writeSample(alternativeSamples); // Check for constant and null columns. for (int i = 0; i < firstColumnValues.length; i++) { this.isNullColumn[i] = firstColumnValues[i] != null && firstColumnValues[i].longValue() == NULLHASH; this.isConstantColumn[i] = firstColumnValues[i] != null && firstColumnValues[i].longValue() != NULLHASH; } }