protected int store(ByteRange bytes) { int indexOfNewElement = numUniqueRanges; if (uniqueRanges.size() <= numUniqueRanges) { uniqueRanges.add(new SimpleMutableByteRange()); } ByteRange storedRange = uniqueRanges.get(numUniqueRanges); int neededBytes = numBytes + bytes.getLength(); byteAppender = ArrayUtils.growIfNecessary(byteAppender, neededBytes, 2 * neededBytes); bytes.deepCopyTo(byteAppender, numBytes); storedRange.set(byteAppender, numBytes, bytes.getLength());// this isn't valid yet numBytes += bytes.getLength(); uniqueIndexByUniqueRange.put(storedRange, indexOfNewElement); int newestUniqueIndex = numUniqueRanges; ++numUniqueRanges; return newestUniqueIndex; }
public VisibilityLabelFilter(VisibilityExpEvaluator expEvaluator, Map<ByteRange, Integer> cfVsMaxVersions) { this.expEvaluator = expEvaluator; this.cfVsMaxVersions = cfVsMaxVersions; this.curFamily = new SimpleMutableByteRange(); this.curQualifier = new SimpleMutableByteRange(); }
public static Filter createVisibilityLabelFilter(Region region, Authorizations authorizations) throws IOException { Map<ByteRange, Integer> cfVsMaxVersions = new HashMap<ByteRange, Integer>(); for (HColumnDescriptor hcd : region.getTableDesc().getFamilies()) { cfVsMaxVersions.put(new SimpleMutableByteRange(hcd.getName()), hcd.getMaxVersions()); } VisibilityLabelService vls = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(); Filter visibilityLabelFilter = new VisibilityLabelFilter( vls.getVisibilityExpEvaluator(authorizations), cfVsMaxVersions); return visibilityLabelFilter; }
AccessControlFilter(TableAuthManager mgr, User ugi, TableName tableName, Strategy strategy, Map<ByteRange, Integer> cfVsMaxVersions) { authManager = mgr; table = tableName; user = ugi; isSystemTable = tableName.isSystemTable(); this.strategy = strategy; this.cfVsMaxVersions = cfVsMaxVersions; this.prevFam = new SimpleMutableByteRange(); this.prevQual = new SimpleMutableByteRange(); }
/** * Allocate a slice of the given length. * * If the size is larger than the maximum size specified for this * allocator, returns null. */ @Override public ByteRange allocateBytes(int size) { Preconditions.checkArgument(size >= 0, "negative size"); // Callers should satisfy large allocations directly from JVM since they // don't cause fragmentation as badly. if (size > maxAlloc) { return null; } while (true) { Chunk c = getOrMakeChunk(); // Try to allocate from this chunk int allocOffset = c.alloc(size); if (allocOffset != -1) { // We succeeded - this is the common case - small alloc // from a big buffer return new SimpleMutableByteRange(c.data, allocOffset, size); } // not enough space! // try to retire this chunk tryRetireChunk(c); } }
/***************** construct ***********************/ public PrefixTreeEncoder(OutputStream outputStream, boolean includeMvccVersion) { // used during cell accumulation this.blockMeta = new PrefixTreeBlockMeta(); this.rowRange = new SimpleMutableByteRange(); this.familyRange = new SimpleMutableByteRange(); this.qualifierRange = new SimpleMutableByteRange(); this.timestamps = new long[INITIAL_PER_CELL_ARRAY_SIZES]; this.mvccVersions = new long[INITIAL_PER_CELL_ARRAY_SIZES]; this.typeBytes = new byte[INITIAL_PER_CELL_ARRAY_SIZES]; this.valueOffsets = new int[INITIAL_PER_CELL_ARRAY_SIZES]; this.values = new byte[VALUE_BUFFER_INIT_SIZE]; // used during compilation this.familyDeduplicator = USE_HASH_COLUMN_SORTER ? new ByteRangeHashSet() : new ByteRangeTreeSet(); this.qualifierDeduplicator = USE_HASH_COLUMN_SORTER ? new ByteRangeHashSet() : new ByteRangeTreeSet(); this.timestampEncoder = new LongEncoder(); this.mvccVersionEncoder = new LongEncoder(); this.cellTypeEncoder = new CellTypeEncoder(); this.rowTokenizer = new Tokenizer(); this.familyTokenizer = new Tokenizer(); this.qualifierTokenizer = new Tokenizer(); this.rowWriter = new RowSectionWriter(); this.familyWriter = new ColumnSectionWriter(); this.qualifierWriter = new ColumnSectionWriter(); initializeTagHelpers(); reset(outputStream, includeMvccVersion); }
protected void initializeTagHelpers() { this.tagsRange = new SimpleMutableByteRange(); this.tagsDeduplicator = USE_HASH_COLUMN_SORTER ? new ByteRangeHashSet() : new ByteRangeTreeSet(); this.tagsTokenizer = new Tokenizer(); this.tagsWriter = new ColumnSectionWriter(); }
/*********************** construct *****************************/ public TokenizerNode(Tokenizer builder, TokenizerNode parent, int nodeDepth, int tokenStartOffset, int tokenOffset, int tokenLength) { this.token = new SimpleMutableByteRange(); reconstruct(builder, parent, nodeDepth, tokenStartOffset, tokenOffset, tokenLength); this.children = Lists.newArrayList(); }
protected void testInternal(List<String> inputs, int expectedTreeDepth) { Tokenizer builder = new Tokenizer(); for (String s : inputs) { SimpleMutableByteRange b = new SimpleMutableByteRange(Bytes.toBytes(s)); builder.addSorted(b); } Assert.assertEquals(1, builder.getRoot().getNodeDepth()); Assert.assertEquals(expectedTreeDepth, builder.getTreeDepth()); }
public TestTokenizer(TestTokenizerData sortedByteArrays) { this.inputs = sortedByteArrays.getInputs(); this.builder = new Tokenizer(); for (byte[] array : inputs) { builder.addSorted(new SimpleMutableByteRange(array)); } this.roundTripped = builder.getArrays(); }
/** * Increment the row bytes and clear the other fields */ public static KeyValue createFirstKeyInIncrementedRow(final Cell in){ byte[] thisRow = new SimpleMutableByteRange(in.getRowArray(), in.getRowOffset(), in.getRowLength()).deepCopyToNewArray(); byte[] nextRow = Bytes.unsignedCopyAndIncrement(thisRow); return createFirstOnRow(nextRow); }
public static Filter createVisibilityLabelFilter(HRegion region, Authorizations authorizations) throws IOException { Map<ByteRange, Integer> cfVsMaxVersions = new HashMap<ByteRange, Integer>(); for (HColumnDescriptor hcd : region.getTableDesc().getFamilies()) { cfVsMaxVersions.put(new SimpleMutableByteRange(hcd.getName()), hcd.getMaxVersions()); } VisibilityLabelService vls = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(); Filter visibilityLabelFilter = new VisibilityLabelFilter( vls.getVisibilityExpEvaluator(authorizations), cfVsMaxVersions); return visibilityLabelFilter; }
public static Filter createVisibilityLabelFilter(Region region, Authorizations authorizations) throws IOException { Map<ByteRange, Integer> cfVsMaxVersions = new HashMap<>(); for (ColumnFamilyDescriptor hcd : region.getTableDescriptor().getColumnFamilies()) { cfVsMaxVersions.put(new SimpleMutableByteRange(hcd.getName()), hcd.getMaxVersions()); } VisibilityLabelService vls = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(); Filter visibilityLabelFilter = new VisibilityLabelFilter( vls.getVisibilityExpEvaluator(authorizations), cfVsMaxVersions); return visibilityLabelFilter; }
public byte[] getToken() { // TODO pass in reusable ByteRange return new SimpleMutableByteRange(block, tokenOffset, tokenLength).deepCopyToNewArray(); }
public ByteRange getValueByteRange() { return new SimpleMutableByteRange(values, 0, totalValueBytes); }
@Test public void testConstructor() { ByteRange b = new SimpleMutableByteRange(new byte[] { 0, 1, 2 }); Assert.assertEquals(3, b.getLength()); }