@Override public synchronized void onCommit(List<? extends IndexCommit> commits) throws IOException { final int keptPosition = indexOfKeptCommits(commits, globalCheckpointSupplier.getAsLong()); lastCommit = commits.get(commits.size() - 1); safeCommit = commits.get(keptPosition); for (int i = 0; i < keptPosition; i++) { if (snapshottedCommits.containsKey(commits.get(i)) == false) { deleteCommit(commits.get(i)); } } updateRetentionPolicy(); }
/** * Return true if all keys of some other container exist in this container. * Equality comparison is performed with this object's {@link #equals(Object, Object)} * method. */ protected boolean equalElements(ObjectIntHashMap<?> other) { if (other.size() != size()) { return false; } for (ObjectIntCursor<?> c : other) { KType key = (KType) c.key; if (!containsKey(key) || !((get(key)) == (c.value))) { return false; } } return true; }
/** * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}. * * @return true if the snapshotting commit can be clean up. */ synchronized boolean releaseCommit(final IndexCommit snapshotCommit) { final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate; assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" + "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]"; final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]"; if (refCount == 0) { snapshottedCommits.remove(releasingCommit); } // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit. return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false; }
public boolean containsKey(T key) { return g_map.containsKey(key); }
if (fullValues != null) { for (String fullValue : fullValues) { if (!shardPerAttribute.containsKey(fullValue)) { numberOfAttributes++;
public boolean dependsOn(ColumnDefinition column) { return this.mappingInfo != null && this.mappingInfo.fieldsToIdx.containsKey(column.name.toString()); }
private int getFieldIndex(final String name, final InstructionModifier mv) { if (!fieldMap.containsKey(name)) { throw new IllegalArgumentException(String.format( "Unknown name '%s' on line %d.", name, mv.getLastLineNumber())); } return fieldMap.get(name); // using lget() is not thread-safe }
@Override public synchronized void onCommit(List<? extends IndexCommit> commits) throws IOException { final int keptPosition = indexOfKeptCommits(commits, globalCheckpointSupplier.getAsLong()); lastCommit = commits.get(commits.size() - 1); safeCommit = commits.get(keptPosition); for (int i = 0; i < keptPosition; i++) { if (snapshottedCommits.containsKey(commits.get(i)) == false) { deleteCommit(commits.get(i)); } } updateTranslogDeletionPolicy(); }
/** * <a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent * of the following code: * <pre> * if (!map.containsKey(key)) map.put(value); * </pre> * * @param key The key of the value to check. * @param value The value to put if <code>key</code> does not exist. * @return <code>true</code> if <code>key</code> did not exist and <code>value</code> * was placed in the map. */ public boolean putIfAbsent(KType key, int value) { if (!containsKey(key)) { put(key, value); return true; } else { return false; } }
@Override public synchronized void onCommit(List<? extends IndexCommit> commits) throws IOException { final int keptPosition = indexOfKeptCommits(commits, globalCheckpointSupplier.getAsLong()); lastCommit = commits.get(commits.size() - 1); safeCommit = commits.get(keptPosition); for (int i = 0; i < keptPosition; i++) { if (snapshottedCommits.containsKey(commits.get(i)) == false) { deleteCommit(commits.get(i)); } } updateRetentionPolicy(); }
private void releaseViewExpansionToken(ViewExpansionToken token) { final String viewOwner = token.viewOwner; if (Objects.equals(queryUser, viewOwner)) { // If the token owner and queryUser are same, no need to track the token release. return; } Preconditions.checkState(userTokens.containsKey(token.viewOwner), "Given user doesn't exist in User Token store. Make sure token for this user is obtained first."); final int userTokenCount = userTokens.get(viewOwner); if (userTokenCount == 1) { // Remove the user from collection, when there are no more tokens issued to the user. userTokens.remove(viewOwner); } else { userTokens.put(viewOwner, userTokenCount - 1); } logger.debug("Released view expansion token issued for user '{}'", viewOwner); }
/** * Reserve a token for expansion of view owned by given user name. * * @param viewOwner Name of the user who owns the view. * @return An instance of {@link com.dremio.exec.ops.ViewExpansionContext.ViewExpansionToken} which must be * released when done using the token. */ public ViewExpansionToken reserveViewExpansionToken(String viewOwner) { int totalTokens = 1; if (!Objects.equals(queryUser, viewOwner)) { // We want to track the tokens only if the "viewOwner" is not same as the "queryUser". if (userTokens.containsKey(viewOwner)) { totalTokens += userTokens.get(viewOwner); } userTokens.put(viewOwner, totalTokens); logger.debug("Issued view expansion token for user '{}'", viewOwner); } return new ViewExpansionToken(viewOwner); }
/** * If <code>key</code> exists, <code>putValue</code> is inserted into the map, * otherwise any existing value is incremented by <code>additionValue</code>. * * @param key * The key of the value to adjust. * @param putValue * The value to put if <code>key</code> does not exist. * @param incrementValue * The value to add to the existing value if <code>key</code> exists. * @return Returns the current value associated with <code>key</code> (after * changes). */ @Override public int putOrAdd(KType key, int putValue, int incrementValue) { assert assigned < mask + 1; if (containsKey(key)) { putValue = get(key); putValue = (int) (((putValue) + (incrementValue))); } put(key, putValue); return putValue; }
private void releaseViewExpansionToken(ViewExpansionToken token) { final String viewOwner = token.viewOwner; if (viewOwner.equals(queryUser)) { // If the token owner and queryUser are same, no need to track the token release. return; } Preconditions.checkState(userTokens.containsKey(token.viewOwner), "Given user doesn't exist in User Token store. Make sure token for this user is obtained first."); final int userTokenCount = userTokens.get(viewOwner); if (userTokenCount == 1) { // Remove the user from collection, when there are no more tokens issued to the user. userTokens.remove(viewOwner); } else { userTokens.put(viewOwner, userTokenCount - 1); } logger.debug("Released view expansion token issued for user '{}'", viewOwner); }
/** * Return true if all keys of some other container exist in this container. * Equality comparison is performed with this object's {@link #equals(Object, Object)} * method. */ protected boolean equalElements(ObjectIntHashMap<?> other) { if (other.size() != size()) { return false; } for (ObjectIntCursor<?> c : other) { KType key = (KType) c.key; if (!containsKey(key) || !((get(key)) == (c.value))) { return false; } } return true; }
if (!viewOwner.equals(queryUser)) { if (userTokens.containsKey(viewOwner)) {
/** * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}. * * @return true if the snapshotting commit can be clean up. */ synchronized boolean releaseCommit(final IndexCommit snapshotCommit) { final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate; assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" + "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]"; final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]"; if (refCount == 0) { snapshottedCommits.remove(releasingCommit); } // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit. return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false; }
/** * Releases an index commit that acquired by {@link #acquireIndexCommit(boolean)}. * * @return true if the snapshotting commit can be clean up. */ synchronized boolean releaseCommit(final IndexCommit snapshotCommit) { final IndexCommit releasingCommit = ((SnapshotIndexCommit) snapshotCommit).delegate; assert snapshottedCommits.containsKey(releasingCommit) : "Release non-snapshotted commit;" + "snapshotted commits [" + snapshottedCommits + "], releasing commit [" + releasingCommit + "]"; final int refCount = snapshottedCommits.addTo(releasingCommit, -1); // release refCount assert refCount >= 0 : "Number of snapshots can not be negative [" + refCount + "]"; if (refCount == 0) { snapshottedCommits.remove(releasingCommit); } // The commit can be clean up only if no pending snapshot and it is neither the safe commit nor last commit. return refCount == 0 && releasingCommit.equals(safeCommit) == false && releasingCommit.equals(lastCommit) == false; }
public Indexer indexerFor(DecoratedKey key, PartitionColumns columns, int nowInSec, Group opGroup, Type transactionType) { if (isIndexing()) { if (transactionType == Type.COMPACTION && !this.mappingInfo.indexOnCompaction) return null; boolean found = (columns.size() == 0); if (!found) { for(ColumnDefinition cd : columns) { if (this.mappingInfo.fieldsToIdx.containsKey(cd.name.toString())) { found = true; break; } } } if (found) { try { if (baseCfs.getComparator().size() == 0) return this.mappingInfo.new SkinnyRowcumentIndexer(key, columns, nowInSec, opGroup, transactionType); else return this.mappingInfo.new WideRowcumentIndexer(key, columns, nowInSec, opGroup, transactionType); } catch (Throwable e) { throw new RuntimeException(e); } } } return null; }
if (fullValues != null) { for (String fullValue : fullValues) { if (!shardPerAttribute.containsKey(fullValue)) { numberOfAttributes++;