public boolean contains(long id) { if (id >= 0 && id <= 0x00000000FFFFFFFFL) { return this.ints.contains((int) id); } else { return this.longs.contains(id); } }
private void initFloatValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } IntArrayList floatBits = new IntArrayList(values.size()); for (String value : values) { Float floatValue = Floats.tryParse(value); if (floatValue != null) { floatBits.add(Float.floatToIntBits(floatValue)); } } if (floatBits.size() > NUMERIC_HASHING_THRESHOLD) { final IntOpenHashSet floatBitsHashSet = new IntOpenHashSet(floatBits); predicate = input -> floatBitsHashSet.contains(Float.floatToIntBits(input)); } else { final int[] floatBitsArray = floatBits.toIntArray(); Arrays.sort(floatBitsArray); predicate = input -> Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0; } } }
private void saveInstantiator(int id, String instantiatorClassName, String instantiatedClassName) { lock(true); try { if (!this.compactInProgress && this.instIds.contains(id)) { // instantiator already written to disk so just return return; } final byte[] classNameBytes = classNameToBytes(instantiatorClassName); final byte[] instClassNameBytes = classNameToBytes(instantiatedClassName); ByteBuffer bb = getIFWriteBuffer(1 + 4 + 4 + classNameBytes.length + 4 + instClassNameBytes.length + 1); bb.put(IFREC_INSTANTIATOR_ID); bb.putInt(id); bb.putInt(classNameBytes.length); bb.put(classNameBytes); bb.putInt(instClassNameBytes.length); bb.put(instClassNameBytes); bb.put(END_OF_RECORD_ID); writeIFRecord(bb); } catch (IOException ex) { throw new DiskAccessException( String.format("Failed saving instantiator to disk because: %s", ex), this.parent); } finally { unlock(true); } }
/** * Write the specified DataSerializer to the file. */ private void saveDataSerializer(DataSerializer ds) { lock(true); try { if (!this.compactInProgress && this.dsIds.contains(ds.getId())) { // dataSerializer already written to disk so just return return; } final byte[] classNameBytes = classToBytes(ds.getClass()); ByteBuffer bb = getIFWriteBuffer(1 + 4 + classNameBytes.length + 1); bb.put(IFREC_DATA_SERIALIZER_ID); bb.putInt(classNameBytes.length); bb.put(classNameBytes); bb.put(END_OF_RECORD_ID); writeIFRecord(bb); } catch (IOException ex) { throw new DiskAccessException( String.format("Failed saving data serializer to disk because: %s", ex), this.parent); } finally { unlock(true); } }
@Override public void run() { // This thread will record updates for this single thread. The // update is the thread id * the update number for (int i = myNumber; i < updates; i += numUpdaters) { // Only apply the update if it is not an intended exception if (!exceptions.contains(i)) { synchronized (vh1) { vh1.recordVersion(i); } // Apply only half the updates to vh2. We will then mimic a GII if (i < updates / 2) { synchronized (vh2) { vh2.recordVersion(i); } } Thread.yield(); } } }
@Override public Selection selectIsIn(Collection<String> strings) { IntOpenHashSet keys = new IntOpenHashSet(strings.size()); for (String string : strings) { int key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getInt(i))) { results.add(i); } } return results; }
@Override public Selection selectIsIn(String... strings) { IntOpenHashSet keys = new IntOpenHashSet(strings.length); for (String string : strings) { int key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getInt(i))) { results.add(i); } } return results; }
@Override public int bulkContains(int[] keys) { int v = 0; for (int key : keys) { if (delegate.contains(key)) { v++; } } return v; }
} else if (seca.getRecipientDSIds().contains(this.getRemoteDSId())) { if (isDebugEnabled) { logger.debug(
@Override public boolean containsAny(Object set) { IntOpenHashSet setInt = (IntOpenHashSet) set; for (int i = 0; i < this._length; i++) if (setInt.contains(((TermIntList) _mTermList).getPrimitiveValue(_buf[i]))) return true; return false; }
/** * Checks whether a document is a source or a target for this anchor text * * @param docno Document to be checked * @return True if the document is a source/target of this anchor text */ public boolean containsDocument(int docno) { if(!hasValidDocumentList()) { return false; } return documentList.contains(docno); }
public boolean contains(long id) { if (id >= 0 && id <= 0x00000000FFFFFFFFL) { return this.ints.contains((int) id); } else { return this.longs.contains(id); } }
@Override public boolean accept(int i, int j, Label label) { return values.contains(key == null ? label.getInt() : label.getInt(key)); } }
private void initFloatValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } IntArrayList floatBits = new IntArrayList(values.size()); for (String value : values) { Float floatValue = Floats.tryParse(value); if (floatValue != null) { floatBits.add(Float.floatToIntBits(floatValue)); } } if (floatBits.size() > NUMERIC_HASHING_THRESHOLD) { final IntOpenHashSet floatBitsHashSet = new IntOpenHashSet(floatBits); predicate = input -> floatBitsHashSet.contains(Float.floatToIntBits(input)); } else { final int[] floatBitsArray = floatBits.toIntArray(); Arrays.sort(floatBitsArray); predicate = input -> Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0; } } }
/** * Write the specified DataSerializer to the file. */ private void saveDataSerializer(DataSerializer ds) { lock.lock(); try { if (!this.compactInProgress && this.dsIds.contains(ds.getId())) { // dataSerializer already written to disk so just return return; } final byte[] classNameBytes = classToBytes(ds.getClass()); ByteBuffer bb = getIFWriteBuffer(1 + 4 + classNameBytes.length + 1); bb.put(IFREC_DATA_SERIALIZER_ID); bb.putInt(classNameBytes.length); bb.put(classNameBytes); bb.put(END_OF_RECORD_ID); writeIFRecord(bb); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_SAVING_DATA_SERIALIZER_TO_DISK_BECAUSE_0.toLocalizedString(ex), this.parent); } finally { lock.unlock(); } }
@Override public Selection selectIsIn(Collection<String> strings) { IntOpenHashSet keys = new IntOpenHashSet(strings.size()); for (String string : strings) { int key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getInt(i))) { results.add(i); } } return results; }
@Override public List<PartitionUpdateParam> split() { List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager() .getPartitions(matrixId); IntOpenHashSet serverIds = new IntOpenHashSet(); List<PartitionUpdateParam> params = new ArrayList<>(); for (PartitionKey pkey : pkeys) { int serverId = PSAgentContext.get().getMatrixMetaManager() .getMasterPS(pkey).getIndex(); if (!serverIds.contains(serverId)) { serverIds.add(serverId); params.add(new InitPartitionParam(matrixId, pkey, numPartitions, maxIndex, maxLength, negative, order, partDim, window)); } } return params; } }
@Override public Selection selectIsIn(String... strings) { IntOpenHashSet keys = new IntOpenHashSet(strings.length); for (String string : strings) { int key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getInt(i))) { results.add(i); } } return results; }
/** * Checks whether two lines of anchor text share a source/target document * * @param other The other anchor text * @return True if this line of anchor text has a common source/target * with the other line of anchor text. */ public boolean intersects(AnchorText other) { if(!hasValidDocumentList() || !other.hasValidDocumentList()) { return false; } if(getSize() < other.getSize()) { IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { if(other.containsDocument(iterator.next())) { return true; } } } else { IntIterator iterator = other.documentList.iterator(); while(iterator.hasNext()) { if(documentList.contains(iterator.next())) { return true; } } } return false; }