public JsonNode asNode(){ Preconditions.checkArgument(this.root != null, "Attempted to grab JSONOptions as JsonNode when no root node was stored. You can only convert non-opaque JSONOptions values to JsonNodes."); return root; }
protected ProjectionPassthroughVectorWriter(final OjaiValueWriter valueWriter, final FieldProjector projector, final boolean includeId) { super(valueWriter); this.includeId = includeId; this.projector = Preconditions.checkNotNull(projector); }
/** * Expects principal of the format primary/instance@REALM. * * @param principal principal * @return components */ public static String[] splitPrincipalIntoParts(final String principal) { final String[] components = principal.split("[/@]"); checkState(components.length == 3); checkNotNull(components[0]); checkNotNull(components[1]); checkNotNull(components[2]); return components; }
protected SubDirTestWatcher(File baseDir, boolean createAtBeginning, boolean deleteAtEnd, List<Path> subDirs) { this.baseDir = Preconditions.checkNotNull(baseDir); this.createAtBeginning = createAtBeginning; this.deleteAtEnd = deleteAtEnd; this.subDirs = Preconditions.checkNotNull(subDirs); Preconditions.checkArgument(!subDirs.isEmpty(), "The list of subDirs is empty."); }
@Override public boolean add(final int nBytes) { assertOpen(); Preconditions.checkArgument(nBytes >= 0, "nBytes(%d) < 0", nBytes); Preconditions.checkState(!closed, "Attempt to increase reservation after reservation has been closed"); Preconditions.checkState(!used, "Attempt to increase reservation after reservation has been used"); // we round up to next power of two since all reservations are done in powers of two. This may overestimate the // preallocation since someone may perceive additions to be power of two. If this becomes a problem, we can look // at // modifying this behavior so that we maintain what we reserve and what the user asked for and make sure to only // round to power of two as necessary. final int nBytesTwo = BaseAllocator.nextPowerOfTwo(nBytes); if (!reserve(nBytesTwo)) { return false; } this.nBytes += nBytesTwo; return true; }
byte[] stop = rowkeyRanges.get(rowkeyRanges.size() - 1).getStopRow(); Preconditions.checkNotNull(start, String.format("Encountered a null start key at position %d for scan range condition %s.", count, condition.toString())); Preconditions.checkNotNull(stop, String.format("Encountered a null stop key at position %d for scan range condition %s.", count, condition.toString())); Preconditions.checkState( !(Bytes.equals(start, MapRConstants.EMPTY_BYTE_ARRAY)), String.format("Encountered an empty start key at position %d", count)); Preconditions.checkState( !(Bytes.equals(stop, MapRConstants.EMPTY_BYTE_ARRAY)), String.format("Encountered an empty stop key at position %d", count)); Preconditions.checkArgument(startKeys.size() > 0, "Found empty list of start/stopKeys."); Preconditions.checkState(startKeys.size() == ranges.size(), String.format("Mismatch between the lengths: num start keys = %d, num scan ranges = %d", startKeys.size(), ranges.size())); Preconditions.checkState(stopKeys.size() == ranges.size(), String.format("Mismatch between the lengths: num stop keys = %d, num scan ranges = %d", stopKeys.size(), ranges.size()));
public synchronized Exception getAndClear() { Preconditions.checkState(!isClosed); if (exception != null) { final Exception local = exception; exception = null; return local; } return null; }
@Override public void splitAndTransfer(int startIndex, int length) { Preconditions.checkPositionIndexes(startIndex, startIndex + length, valueCount); splitAndTransferTo(startIndex, length, to); }
@Override public Object getObject(int index) { Preconditions.checkElementIndex(index, valueCount); return null; }
public Window internalBuild() { //TODO withins can actually be empty: over(), over(order by <expression>), ... checkState(!withins.isEmpty(), "Withins in window must not be empty."); checkState(!aggregations.isEmpty(), "Aggregations in window must not be empty."); return new Window(withins, aggregations, orderings, start, end); }
@Override public Writer append(CharSequence csq, int start, int end) { checkPositionIndexes(start, end, csq.length()); return this; }
@Override public boolean isNull(int index){ Preconditions.checkElementIndex(index, valueCount); return true; }
@Override public synchronized DrillBuf capacity(int newCapacity) { if (newCapacity == length) { return this; } Preconditions.checkArgument(newCapacity >= 0); if (newCapacity < length) { length = newCapacity; return this; } throw new UnsupportedOperationException("Buffers don't support resizing that increases the size."); }
protected BaseValueVector(MaterializedField field, BufferAllocator allocator) { this.field = Preconditions.checkNotNull(field, "field cannot be null"); this.allocator = Preconditions.checkNotNull(allocator, "allocator cannot be null"); }
/** * Add an exception. If this is the first exception added, it will be the one * that is thrown when this is closed. If not the first exception, then it will * be added to the suppressed exceptions on the first exception. * * @param exception the exception to add */ public void addException(final Exception exception) { Preconditions.checkNotNull(exception); synchronized(this) { Preconditions.checkState(!isClosed); if (this.exception == null) { if (exceptionSupplier == null) { this.exception = exception; } else { this.exception = exceptionSupplier.get(); if (this.exception == null) { this.exception = new RuntimeException("Missing root exception"); } this.exception.addSuppressed(exception); } } else { this.exception.addSuppressed(exception); } } }
@Override public void addMember(AbstractObjectWriter colWriter) { // Should only be called when promoting from a no-type shim to this // single type shim. Otherwise, something is wrong with the type // promotion logic. Preconditions.checkState(this.colWriter == null); this.colWriter = colWriter; writer.addMember(colWriter); }
@Override public Hasher putBytes(byte[] bytes, int off, int len) { Preconditions.checkPositionIndexes(off, off + len, bytes.length); for (int i = 0; i < len; i++) { putByte(bytes[off + i]); } return this; }
/** * Given a 0-based index relative to the current array, return an absolute offset * vector location for the array value. * * @param index 0-based index into the current array * @return absolute offset vector location for the array value */ @Override public int offset() { Preconditions.checkElementIndex(position, length); return startOffset + position; }
public RpcConfig build() { Preconditions.checkArgument(timeout > -1, "Timeout must be a positive number or zero for disabled."); Preconditions.checkArgument(name != null, "RpcConfig name must be set."); return new RpcConfig(name, sendMap, receiveMap, timeout, executor); }
SaslChallengeContext(SaslMessage challenge, UserGroupInformation ugi, C connection) { this.challenge = checkNotNull(challenge); this.ugi = checkNotNull(ugi); this.connection = checkNotNull(connection); } }