public Builder setHasMultipleValues(boolean hasMultipleValues) { if (this.hasMultipleValues != null && this.hasMultipleValues != hasMultipleValues) { throw new IAE( "hasMultipleValues[%s] is already set, cannot change to[%s]", this.hasMultipleValues, hasMultipleValues ); } this.hasMultipleValues = hasMultipleValues; return this; }
private static String getAvaticaConnectionId(Map<String, Object> requestMap) throws IOException { Object connectionIdObj = requestMap.get("connectionId"); if (connectionIdObj == null) { throw new IAE("Received an Avatica request without a connectionId."); } if (!(connectionIdObj instanceof String)) { throw new IAE("Received an Avatica request with a non-String connectionId."); } return (String) connectionIdObj; }
public InputRow formatRow(InputRow row) { for (Function<InputRow, InputRow> rowTransformer : rowTransformers) { row = rowTransformer.apply(row); } if (row == null) { throw new IAE("Row is null? How can this be?!"); } return row; }
public static String getString(Map<String, Object> in, String key, String defaultValue) { Object retVal = in.get(key); if (retVal == null) { if (defaultValue == null) { throw new IAE("Key[%s] is required in map[%s]", key, in); } return defaultValue; } return retVal.toString(); }
private static String convertValue(Object dimension, String name) { final String retVal; if (dimension instanceof String) { retVal = (String) dimension; } else if (dimension instanceof Map) { retVal = (String) ((Map) dimension).get(name); } else { throw new IAE("Unknown type[%s] for dimension[%s]", dimension.getClass(), dimension); } return retVal; }
private static String convertValue(Object metric) { final String retVal; if (metric instanceof String) { retVal = (String) metric; } else if (metric instanceof Map) { retVal = (String) ((Map) metric).get("metric"); } else { throw new IAE("Unknown type[%s] for metric[%s]", metric.getClass(), metric); } return retVal; }
@Override public int get(int index) { if (index >= size) { throw new IAE("Index[%d] >= size[%d]", index, size); } return values.get(index + offset); }
@Override public DimensionAndMetricValueExtractor apply(@Nullable Object input) { if (input instanceof Map) { return new DimensionAndMetricValueExtractor((Map) input); } else if (input instanceof DimensionAndMetricValueExtractor) { return (DimensionAndMetricValueExtractor) input; } else { throw new IAE("Unknown type for input[%s]", input.getClass()); } } }
@Nullable public DateTime getMinTime() { if (value instanceof Map) { return getDateTimeValue(((Map) value).get(TimeBoundaryQuery.MIN_TIME)); } else { throw new IAE("MinTime not supported!"); } }
private static ComplexMetricSerde getComplexMetricSerde(String type) { ComplexMetricSerde serde = ComplexMetrics.getSerdeForType(type); if (serde == null) { throw new IAE("Unknown type[%s]", type); } return serde; } }
@Override public void readFully(long pos, ByteBuffer buffer) throws IOException { flush(); if (pos < 0 || pos > ch.size()) { throw new IAE("pos %d out of range [%d, %d]", pos, 0, ch.size()); } ch.read(buffer, pos); if (buffer.remaining() > 0) { throw new BufferUnderflowException(); } }
public SearchQueryDecisionHelper getDecisionHelper(QueryableIndex index) { final BitmapFactory bitmapFactory = index.getBitmapFactoryForDimensions(); if (bitmapFactory.getClass().equals(ConciseBitmapFactory.class)) { return ConciseBitmapDecisionHelper.instance(); } else if (bitmapFactory.getClass().equals(RoaringBitmapFactory.class)) { return RoaringBitmapDecisionHelper.instance(); } else { throw new IAE("Unknown bitmap type[%s]", bitmapFactory.getClass().getCanonicalName()); } }
@Override public List<InputRow> parseBatch(Object input) { if (input instanceof Text) { return ImmutableList.of(parser.parse(((Text) input).toString())); } else if (input instanceof BytesWritable) { BytesWritable valueBytes = (BytesWritable) input; return parser.parseBatch(ByteBuffer.wrap(valueBytes.getBytes(), 0, valueBytes.getLength())); } else { throw new IAE("can't convert type [%s] to InputRow", input.getClass().getName()); } }
@Override public Expr apply(final List<Expr> args) { if (args.size() < 2 || args.size() > 4) { throw new IAE("Function[%s] must have 2 to 4 arguments", name()); } if (args.stream().skip(1).allMatch(Expr::isLiteral)) { return new TimestampCeilExpr(args); } else { return new TimestampCeilDynamicExpr(args); } }
public static <T> GenericIndexed<T> read(ByteBuffer buffer, ObjectStrategy<T> strategy, SmooshedFileMapper fileMapper) { byte versionFromBuffer = buffer.get(); if (VERSION_ONE == versionFromBuffer) { return createGenericIndexedVersionOne(buffer, strategy); } else if (VERSION_TWO == versionFromBuffer) { return createGenericIndexedVersionTwo(buffer, strategy, fileMapper); } throw new IAE("Unknown version [%s]", versionFromBuffer); }
public static DateTimeZone toTimeZone(final Expr timeZoneArg) { if (!timeZoneArg.isLiteral()) { throw new IAE("Time zone must be a literal"); } final Object literalValue = timeZoneArg.getLiteralValue(); return literalValue == null ? DateTimeZone.UTC : DateTimeZone.forID((String) literalValue); }
private void checkSize(E e) { if (getBytesSize(e) > capacity) { throw new IAE("cannot add element of size[%d] greater than capacity[%d]", getBytesSize(e), capacity); } }
private WritableSupplier<ColumnarInts> readSingleValuedColumn(VERSION version, ByteBuffer buffer) { switch (version) { case UNCOMPRESSED_SINGLE_VALUE: return VSizeColumnarInts.readFromByteBuffer(buffer); case COMPRESSED: return CompressedVSizeColumnarIntsSupplier.fromByteBuffer(buffer, byteOrder); default: throw new IAE("Unsupported single-value version[%s]", version); } }
protected SearchStrategy(SearchQuery query) { this.filter = Filters.convertToCNFFromQueryContext(query, Filters.toFilter(query.getDimensionsFilter())); final List<Interval> intervals = query.getQuerySegmentSpec().getIntervals(); if (intervals.size() != 1) { throw new IAE("Should only have one interval, got[%s]", intervals); } this.interval = intervals.get(0); }
public TableLongEncodingWriter(Long2IntMap table, LongList valueAddedInOrder) { if (table.size() > CompressionFactory.MAX_TABLE_SIZE) { throw new IAE("Invalid table size[%s]", table.size()); } this.table = table; this.valueAddedInOrder = valueAddedInOrder; this.bitsPerValue = VSizeLongSerde.getBitsForMax(table.size()); }