-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from NationalSecurityAgency/feature/bypassTabl…
…eCache Allow table cache to be bypassed in WrappedAccumuloClient (#2359)
- Loading branch information
Showing
2 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/datawave/webservice/common/connection/WrappedScannerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package datawave.webservice.common.connection; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
import org.apache.accumulo.core.client.BatchScanner; | ||
import org.apache.accumulo.core.client.Scanner; | ||
import org.apache.accumulo.core.client.TableNotFoundException; | ||
import org.apache.accumulo.core.security.Authorizations; | ||
|
||
import datawave.security.util.AuthorizationsMinimizer; | ||
import datawave.security.util.ScannerHelper; | ||
|
||
/** | ||
* Scanner factory for {@link WrappedAccumuloClient} that allows the table cache to be bypassed, if desired | ||
*/ | ||
public class WrappedScannerHelper extends ScannerHelper { | ||
|
||
public static Scanner createScanner(WrappedAccumuloClient connector, String tableName, Collection<Authorizations> authorizations, boolean skipCache) | ||
throws TableNotFoundException { | ||
if (authorizations == null || authorizations.isEmpty()) { | ||
throw new IllegalArgumentException("Authorizations must not be empty."); | ||
} | ||
Iterator<Authorizations> iter = AuthorizationsMinimizer.minimize(authorizations).iterator(); | ||
Scanner scanner = connector.createScanner(tableName, iter.next(), skipCache); | ||
addVisibilityFilters(iter, scanner); | ||
return scanner; | ||
} | ||
|
||
public static BatchScanner createBatchScanner(WrappedAccumuloClient connector, String tableName, Collection<Authorizations> authorizations, | ||
int numQueryThreads, boolean skipCache) throws TableNotFoundException { | ||
if (authorizations == null || authorizations.isEmpty()) { | ||
throw new IllegalArgumentException("Authorizations must not be empty."); | ||
} | ||
Iterator<Authorizations> iter = AuthorizationsMinimizer.minimize(authorizations).iterator(); | ||
BatchScanner batchScanner = connector.createBatchScanner(tableName, iter.next(), numQueryThreads, skipCache); | ||
addVisibilityFilters(iter, batchScanner); | ||
return batchScanner; | ||
} | ||
} |