コード例 #1
0
  /** Dump out all existing properties to message logging info channel. */
  @Override
  public void dumpProperties() {

    Iterator<String> keyIterator = config.getKeys();

    while (keyIterator.hasNext()) {
      String key = keyIterator.next();

      Object o = config.getProperty(key);
      if (o != null) {
        // Check for multiple setting of properties
        if (o instanceof ArrayList) {
          logger.debug(
              key
                  + " is set multiple times the value used will be the first! This maybe ok if deliberately overridden");
        }
        if (o instanceof String) {
          // Calling getString method ensures value has any
          // processing
          // done by commons config applied - ie string
          // interpolation, etc.
          logger.debug(key + " = " + LocalProperties.get(key));
        } else {
          // Handle non-string objects, eg ArrayList's
          logger.debug(key + " = " + o.toString());
        }
      }
    }
  }
コード例 #2
0
    @Override
    public ActualProperties visitDistinctLimit(
        DistinctLimitNode node, List<ActualProperties> inputProperties) {
      ActualProperties properties = Iterables.getOnlyElement(inputProperties);

      return ActualProperties.builderFrom(properties)
          .local(LocalProperties.grouped(node.getDistinctSymbols()))
          .build();
    }
コード例 #3
0
    @Override
    public ActualProperties visitTableScan(
        TableScanNode node, List<ActualProperties> inputProperties) {
      checkArgument(node.getLayout().isPresent(), "table layout has not yet been chosen");

      TableLayout layout = metadata.getLayout(session, node.getLayout().get());
      Map<ColumnHandle, Symbol> assignments =
          ImmutableBiMap.copyOf(node.getAssignments()).inverse();

      ActualProperties.Builder properties = ActualProperties.builder();

      // Globally constant assignments
      Map<ColumnHandle, NullableValue> globalConstants = new HashMap<>();
      extractFixedValues(node.getCurrentConstraint())
          .orElse(ImmutableMap.of())
          .entrySet()
          .stream()
          .filter(entry -> !entry.getValue().isNull())
          .forEach(entry -> globalConstants.put(entry.getKey(), entry.getValue()));

      Map<Symbol, NullableValue> symbolConstants =
          globalConstants
              .entrySet()
              .stream()
              .filter(entry -> assignments.containsKey(entry.getKey()))
              .collect(toMap(entry -> assignments.get(entry.getKey()), Map.Entry::getValue));
      properties.constants(symbolConstants);

      // Partitioning properties
      properties.global(deriveGlobalProperties(layout, assignments, globalConstants));

      // Append the global constants onto the local properties to maximize their translation
      // potential
      List<LocalProperty<ColumnHandle>> constantAppendedLocalProperties =
          ImmutableList.<LocalProperty<ColumnHandle>>builder()
              .addAll(
                  globalConstants
                      .keySet()
                      .stream()
                      .map(column -> new ConstantProperty<>(column))
                      .iterator())
              .addAll(layout.getLocalProperties())
              .build();
      properties.local(
          LocalProperties.translate(
              constantAppendedLocalProperties,
              column -> Optional.ofNullable(assignments.get(column))));

      return properties.build();
    }
コード例 #4
0
    @Override
    public ActualProperties visitAggregation(
        AggregationNode node, List<ActualProperties> inputProperties) {
      ActualProperties properties = Iterables.getOnlyElement(inputProperties);

      ActualProperties translated =
          properties.translate(
              symbol ->
                  node.getGroupingKeys().contains(symbol)
                      ? Optional.of(symbol)
                      : Optional.<Symbol>empty());

      return ActualProperties.builderFrom(translated)
          .local(LocalProperties.grouped(node.getGroupingKeys()))
          .build();
    }
コード例 #5
0
    @Override
    public ActualProperties visitWindow(WindowNode node, List<ActualProperties> inputProperties) {
      ActualProperties properties = Iterables.getOnlyElement(inputProperties);

      // If the input is completely pre-partitioned and sorted, then the original input properties
      // will be respected
      if (ImmutableSet.copyOf(node.getPartitionBy()).equals(node.getPrePartitionedInputs())
          && node.getPreSortedOrderPrefix() == node.getOrderBy().size()) {
        return properties;
      }

      ImmutableList.Builder<LocalProperty<Symbol>> localProperties = ImmutableList.builder();

      // If the WindowNode has pre-partitioned inputs, then it will not change the order of those
      // inputs at output,
      // so we should just propagate those underlying local properties that guarantee the
      // pre-partitioning.
      // TODO: come up with a more general form of this operation for other streaming operators
      if (!node.getPrePartitionedInputs().isEmpty()) {
        GroupingProperty<Symbol> prePartitionedProperty =
            new GroupingProperty<>(node.getPrePartitionedInputs());
        for (LocalProperty<Symbol> localProperty : properties.getLocalProperties()) {
          if (!prePartitionedProperty.isSimplifiedBy(localProperty)) {
            break;
          }
          localProperties.add(localProperty);
        }
      }

      if (!node.getPartitionBy().isEmpty()) {
        localProperties.add(new GroupingProperty<>(node.getPartitionBy()));
      }
      for (Symbol column : node.getOrderBy()) {
        localProperties.add(new SortingProperty<>(column, node.getOrderings().get(column)));
      }

      return ActualProperties.builderFrom(properties)
          .local(LocalProperties.normalizeAndPrune(localProperties.build()))
          .build();
    }