use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class TservConstraintEnvTest method testGetAuthorizationsContainer.
@Test
public void testGetAuthorizationsContainer() throws ThriftSecurityException {
SecurityOperation security = createMock(SecurityOperation.class);
TCredentials goodCred = createMock(TCredentials.class);
TCredentials badCred = createMock(TCredentials.class);
ByteSequence bs = new ArrayByteSequence("foo".getBytes());
List<ByteBuffer> bbList = Collections.singletonList(ByteBuffer.wrap(bs.getBackingArray(), bs.offset(), bs.length()));
expect(security.authenticatedUserHasAuthorizations(goodCred, bbList)).andReturn(true);
expect(security.authenticatedUserHasAuthorizations(badCred, bbList)).andReturn(false);
replay(security);
assertTrue(new TservConstraintEnv(security, goodCred).getAuthorizationsContainer().contains(bs));
assertFalse(new TservConstraintEnv(security, badCred).getAuthorizationsContainer().contains(bs));
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileWriter method startNewLocalityGroup.
/**
* Before appending any data, a locality group must be started. The default locality group must be started last.
*
* @param name
* locality group name, used for informational purposes
* @param families
* the column families the locality group can contain
*
* @throws IllegalStateException
* When default locality group already started.
*/
public void startNewLocalityGroup(String name, List<byte[]> families) throws IOException {
HashSet<ByteSequence> fams = new HashSet<>();
for (byte[] family : families) {
fams.add(new ArrayByteSequence(family));
}
_startNewLocalityGroup(name, fams);
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileWriter method startNewLocalityGroup.
/**
* See javadoc for {@link #startNewLocalityGroup(String, List)}.
*
* @param families
* will be encoded using UTF-8
*
* @throws IllegalStateException
* When default locality group already started.
*/
public void startNewLocalityGroup(String name, String... families) throws IOException {
HashSet<ByteSequence> fams = new HashSet<>();
for (String family : families) {
fams.add(new ArrayByteSequence(family));
}
_startNewLocalityGroup(name, fams);
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileWriter method append.
/**
* Append the key and value to the last locality group that was started. If no locality group was started, then the default group will automatically be
* started.
*
* @param key
* This key must be greater than or equal to the last key appended. For non-default locality groups, the keys column family must be one of the column
* families specified when calling startNewLocalityGroup(). Must be non-null.
* @param val
* value to append, must be non-null.
*
* @throws IllegalArgumentException
* This is thrown when data is appended out of order OR when the key contains a invalid visibility OR when a column family is not valid for a
* locality group.
*/
public void append(Key key, Value val) throws IOException {
if (!startedLG) {
startDefaultLocalityGroup();
}
Boolean wasChecked = (Boolean) validVisibilities.get(key.getColumnVisibilityData());
if (wasChecked == null) {
byte[] cv = key.getColumnVisibilityData().toArray();
new ColumnVisibility(cv);
validVisibilities.put(new ArrayByteSequence(Arrays.copyOf(cv, cv.length)), Boolean.TRUE);
}
writer.append(key, val);
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class ConditionCheckerContext method buildIterator.
SortedKeyValueIterator<Key, Value> buildIterator(SortedKeyValueIterator<Key, Value> systemIter, TCondition tc) throws IOException {
ArrayByteSequence key = new ArrayByteSequence(tc.iterators);
MergedIterConfig mic = mergedIterCache.get(key);
if (mic == null) {
IterConfig ic = compressedIters.decompress(tc.iterators);
List<IterInfo> mergedIters = new ArrayList<>(tableIters.size() + ic.ssiList.size());
Map<String, Map<String, String>> mergedItersOpts = new HashMap<>(tableIterOpts.size() + ic.ssio.size());
IteratorUtil.mergeIteratorConfig(mergedIters, mergedItersOpts, tableIters, tableIterOpts, ic.ssiList, ic.ssio);
mic = new MergedIterConfig(mergedIters, mergedItersOpts);
mergedIterCache.put(key, mic);
}
return IteratorUtil.loadIterators(systemIter, mic.mergedIters, mic.mergedItersOpts, tie, true, context, classCache);
}
Aggregations