public CompareFunctionsProcessor(String functionName) { this.success = false; this.functionName = functionName; this.isEqualityFn = COMPARE_FUNCTIONS_TRANSPOSE_MAP.containsKey(functionName) && COMPARE_FUNCTIONS_TRANSPOSE_MAP.get(functionName).equals(functionName); this.isRowKeyPrefixComparison = false; this.sortOrderAscending = true; }
@JsonProperty public Map<String, String> getConfig() { return ImmutableMap.copyOf(config); }
private List<KafkaPartitionScanSpec> createScanSpecForTimestamp(String functionName, Long fieldValue) { List<KafkaPartitionScanSpec> scanSpec = Lists.newArrayList(); Map<TopicPartition, Long> timesValMap = Maps.newHashMap(); ImmutableSet<TopicPartition> topicPartitions = fullScanSpec.keySet(); for(TopicPartition partitions : topicPartitions) { timesValMap.put(partitions, functionName.equals("greater_than") ? fieldValue+1 : fieldValue); } Map<TopicPartition, OffsetAndTimestamp> offsetAndTimestamp = kafkaConsumer.offsetsForTimes(timesValMap); for(TopicPartition tp : topicPartitions) { OffsetAndTimestamp value = offsetAndTimestamp.get(tp); //OffsetAndTimestamp is null if there is no offset greater or equal to requested timestamp if(value == null) { scanSpec.add( new KafkaPartitionScanSpec(tp.topic(), tp.partition(), fullScanSpec.get(tp).getEndOffset(), fullScanSpec.get(tp).getEndOffset())); } else { scanSpec.add( new KafkaPartitionScanSpec(tp.topic(), tp.partition(), value.offset(), fullScanSpec.get(tp).getEndOffset())); } } return scanSpec; }
public List<KafkaPartitionScanSpec> parseTree() { ImmutableMap.Builder<TopicPartition, KafkaPartitionScanSpec> builder = ImmutableMap.builder(); for(KafkaPartitionScanSpec scanSpec : groupScan.getPartitionScanSpecList()) { builder.put(new TopicPartition(scanSpec.getTopicName(), scanSpec.getPartitionId()), scanSpec); } fullScanSpec = builder.build(); List<KafkaPartitionScanSpec> pushdownSpec = le.accept(this, null); /* Non-existing / invalid partitions may result in empty scan spec. This results in a "ScanBatch" with no reader. DRILL currently requires at least one reader to be present in a scan batch. */ if(pushdownSpec != null && pushdownSpec.isEmpty()) { TopicPartition firstPartition = new TopicPartition(groupScan.getKafkaScanSpec().getTopicName(), 0); KafkaPartitionScanSpec emptySpec = new KafkaPartitionScanSpec(firstPartition.topic(),firstPartition.partition(), fullScanSpec.get(firstPartition).getEndOffset(), fullScanSpec.get(firstPartition).getEndOffset()); pushdownSpec.add(emptySpec); } return pushdownSpec; }
public static boolean isCompareFunction(String functionName) { return COMPARE_FUNCTIONS_TRANSPOSE_MAP.keySet().contains(functionName); }
@JsonCreator public AnnotationDescriptor( @JsonProperty("annotationType") String annotationType, @JsonProperty("attributes") List<AttributeDescriptor> attributes) { this.annotationType = annotationType; this.attributes = Collections.unmodifiableList(attributes); ImmutableMap.Builder<String, AttributeDescriptor> mapBuilder = ImmutableMap.builder(); for (AttributeDescriptor att : attributes) { mapBuilder.put(att.getName(), att); } this.attributeMap = mapBuilder.build(); }
@BeforeClass public static void setup_TestEncodedFieldPaths() throws Exception { try (Table table = DBTests.createOrReplaceTable(TABLE_NAME, ImmutableMap.of("codes", "codes"))) { tableCreated = true; tablePath = table.getPath().toUri().getPath(); DBTests.createIndex(TABLE_NAME, INDEX_NAME, new String[] {"age"}, new String[] {"name.last", "data.salary"}); DBTests.admin().getTableIndexes(table.getPath(), true); try (final InputStream in = TestEncodedFieldPaths.class.getResourceAsStream(JSON_FILE_URL); final DocumentStream stream = Json.newDocumentStream(in);) { table.insertOrReplace(stream); table.flush(); } // wait for the indexes to sync DBTests.waitForRowCount(table.getPath(), 5, INDEX_FLUSH_TIMEOUT); DBTests.waitForIndexFlush(table.getPath(), INDEX_FLUSH_TIMEOUT); } finally { test("ALTER SESSION SET `planner.disable_full_table_scan` = true"); } }
/** * Returns {@code true} if the provided row key is among the row keys * provided when the table was constructed. */ @Override public boolean containsRow(@Nullable Object rowKey) { return rowKeyToIndex.containsKey(rowKey); }
Object readResolve() { return map.entrySet(); }
@Override public int hashCode() { /* * The sum of the sums of the hash codes in each subset is just the sum of * each input element's hash code times the number of sets that element * appears in. Each element appears in exactly half of the 2^n sets, so: */ return inputSet.keySet().hashCode() << (inputSet.size() - 1); }
@VisibleForTesting public static Direction getOrderingSpecFromString(String strDirection) { Direction dir = null; if (strDirection != null) { dir = DRILL_TO_CALCITE_DIR_MAPPING.get(strDirection.toUpperCase()); } if (dir != null || strDirection == null) { return filterDrillSupportedDirections(dir); } else { throw new DrillRuntimeException( "Unknown <ordering specification> string (not \"ASC\", \"DESC\", " + "or null): \"" + strDirection + "\"" ); } }
public static boolean isCompareFunction(String functionName) { return COMPARE_FUNCTIONS_TRANSPOSE_MAP.keySet().contains(functionName); }
/** * Returns a new instance of {@link ImmutableMap} with key case-insensitivity. This map is built from the given * map. See {@link ImmutableMap}. * * @param map map to copy from * @param <VALUE> type of values to be stored in the map * @return key case-insensitive immutable map */ public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? extends String, ? extends VALUE> map) { final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder(); for (final Entry<? extends String, ? extends VALUE> entry : map.entrySet()) { builder.put(entry.getKey().toLowerCase(), entry.getValue()); } return new CaseInsensitiveMap<>(builder.build()); }
/** * Returns a map of types in this schema by name. * * <p>The implementations of {@link #getTypeNames()} * and {@link #getType(String)} depend on this map. * The default implementation of this method returns the empty map. * Override this method to change their behavior.</p> * * @return Map of types in this schema by name */ protected Map<String, RelProtoDataType> getTypeMap() { return ImmutableMap.of(); }
/** * Returns {@code true} if the provided column key is among the column keys * provided when the table was constructed. */ @Override public boolean containsColumn(@Nullable Object columnKey) { return columnKeyToIndex.containsKey(columnKey); }
private abstract class Itr<T> extends UnmodifiableIterator<T> { final Iterator<Entry<K, Collection<V>>> mapIterator = asMap().entrySet().iterator(); K key = null; Iterator<V> valueIterator = Iterators.emptyIterator(); abstract T output(K key, V value); @Override public boolean hasNext() { return mapIterator.hasNext() || valueIterator.hasNext(); } @Override public T next() { if (!valueIterator.hasNext()) { Entry<K, Collection<V>> mapEntry = mapIterator.next(); key = mapEntry.getKey(); valueIterator = mapEntry.getValue().iterator(); } return output(key, valueIterator.next()); } }