List of usage examples for org.apache.commons.collections BufferOverflowException BufferOverflowException
public BufferOverflowException(String message)
BufferOverflowException
. From source file:org.apache.accumulo.core.iterators.user.RowEncodingIterator.java
private void prepKeys() throws IOException { long kvBufSize = 0; if (topKey != null) return;/*from w w w . jav a 2 s. c o m*/ Text currentRow; do { if (sourceIter.hasTop() == false) return; currentRow = new Text(sourceIter.getTopKey().getRow()); keys.clear(); values.clear(); while (sourceIter.hasTop() && sourceIter.getTopKey().getRow().equals(currentRow)) { Key sourceTopKey = sourceIter.getTopKey(); Value sourceTopValue = sourceIter.getTopValue(); keys.add(new Key(sourceTopKey)); values.add(new Value(sourceTopValue)); kvBufSize += sourceTopKey.getSize() + sourceTopValue.getSize() + 128; if (kvBufSize > maxBufferSize) { throw new BufferOverflowException("Exceeded buffer size of " + maxBufferSize + " for row: " + sourceTopKey.getRow().toString()); } sourceIter.next(); } } while (!filter(currentRow, keys, values)); topKey = new Key(currentRow); topValue = rowEncoder(keys, values); }
From source file:org.apache.accumulo.core.iterators.user.TransformingIterator.java
/** * Reads all keys matching the first key's prefix from the source iterator, transforms them, and sorts the resulting keys. Transformed keys that fall outside * of our seek range or can't be seen by the user are excluded. *//* ww w . j av a 2s.c o m*/ protected void transformKeys() throws IOException { keyPos = -1; keys.clear(); final Key prefixKey = super.hasTop() ? new Key(super.getTopKey()) : null; transformRange(new RangeIterator(getSource(), prefixKey, getKeyPrefix()), new KVBuffer() { long appened = 0; @Override public void append(Key key, Value val) { // ensure the key provided by the user has the correct prefix if (!key.equals(prefixKey, getKeyPrefix())) throw new IllegalArgumentException("Key prefixes are not equal " + key + " " + prefixKey); // Transformation could have produced a key that falls outside // of the seek range, or one that the user cannot see. Check // these before adding it to the output list. if (includeTransformedKey(key)) { // try to defend against a scan or compaction using all memory in a tablet server if (appened > maxBufferSize) throw new BufferOverflowException( "Exceeded buffer size of " + maxBufferSize + ", prefixKey: " + prefixKey); if (getSource().hasTop() && key == getSource().getTopKey()) key = new Key(key); keys.add(new Pair<Key, Value>(key, new Value(val))); appened += (key.getSize() + val.getSize() + 128); } } }); // consume any key in range that user did not consume while (super.hasTop() && super.getTopKey().equals(prefixKey, getKeyPrefix())) { super.next(); } if (!keys.isEmpty()) { Collections.sort(keys, keyComparator); keyPos = 0; } }
From source file:oz.hadoop.yarn.api.utils.ByteBufferUtils.java
/** * /*ww w. j av a 2 s . c om*/ * @param source * @param target * @return */ public static ByteBuffer merge(ByteBuffer source, ByteBuffer target) { if (target.position() != 0) { target.flip(); } int rPos = source.position() + target.limit(); if (rPos <= source.capacity()) { source.put(target); return source; } else { int newLength = calculateNewLength(source, target); if (newLength > 0) { ByteBuffer b = ByteBuffer.allocate(newLength); source.flip(); b.put(source); b.put(target); return b; } else { throw new BufferOverflowException( "Buffer can no longer be expended. Maximum allowed size is " + threshold + " bytes."); } } }
From source file:securitymon.collections.BoundedFifoBuffer.java
/** * Adds the given element to this buffer. * * @param element the element to add//from www .j a va 2 s . c om * @return true, always * @throws NullPointerException if the given element is null * @throws BufferOverflowException if this buffer is full */ public boolean add(byte element) { if (full) { throw new BufferOverflowException("The buffer cannot hold more than " + maxElements + " objects."); } elements[end++] = element; if (end >= maxElements) { end = 0; } if (end == start) { full = true; } return true; }