Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/242#discussion_r78424147
  
    --- Diff: 
metron-analytics/metron-profiler-client/src/main/java/org/apache/metron/profiler/client/stellar/GetProfile.java
 ---
    @@ -0,0 +1,179 @@
    +/*
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + *
    + */
    +
    +package org.apache.metron.profiler.client.stellar;
    +
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.hadoop.hbase.client.HTableInterface;
    +import org.apache.metron.common.dsl.Context;
    +import org.apache.metron.common.dsl.ParseException;
    +import org.apache.metron.common.dsl.Stellar;
    +import org.apache.metron.common.dsl.StellarFunction;
    +import org.apache.metron.common.utils.ConversionUtils;
    +import org.apache.metron.profiler.client.HBaseProfilerClient;
    +import org.apache.metron.profiler.client.ProfilerClient;
    +import org.apache.metron.profiler.hbase.ColumnBuilder;
    +import org.apache.metron.profiler.hbase.RowKeyBuilder;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.concurrent.TimeUnit;
    +import java.util.stream.Collectors;
    +import java.util.stream.Stream;
    +
    +import static java.lang.String.format;
    +import static 
org.apache.metron.common.dsl.Context.Capabilities.PROFILER_COLUMN_BUILDER;
    +import static 
org.apache.metron.common.dsl.Context.Capabilities.PROFILER_HBASE_TABLE;
    +import static 
org.apache.metron.common.dsl.Context.Capabilities.PROFILER_ROW_KEY_BUILDER;
    +
    +/**
    + * A Stellar function that can retrieve data contained within a Profile.
    + *
    + *  PROFILE_GET
    + *
    + * Retrieve all values for 'entity1' from 'profile1' over the past 4 hours.
    + *
    + *   <code>PROFILE_GET('profile1', 'entity1', 4, 'HOURS')</code>
    + *
    + * Retrieve all values for 'entity1' from 'profile1' over the past 2 days.
    + *
    + *   <code>PROFILE_GET('profile1', 'entity1', 2, 'DAYS')</code>
    + *
    + * Retrieve all values for 'entity1' from 'profile1' that occurred on 
'weekdays' over the past month.
    + *
    + *   <code>PROFILE_GET('profile1', 'entity1', 1, 'MONTHS', 
'weekdays')</code>
    + *
    + */
    +@Stellar(
    +        namespace="PROFILE",
    +        name="GET",
    +        description="Retrieves a series of values from a stored profile.",
    +        params={
    +          "profile - The name of the profile.",
    +          "entity - The name of the entity.",
    +          "durationAgo - How long ago should values be retrieved from?",
    +          "units - The units of 'durationAgo'.",
    +          "groups - Optional - The groups used to sort the profile."
    +        },
    +        returns="The profile measurements."
    +)
    +public class GetProfile implements StellarFunction {
    +
    +  private ProfilerClient client;
    +
    +  /**
    +   * Initialization.
    +   */
    +  @Override
    +  public void initialize(Context context) {
    +
    +    Context.Capabilities[] required = { PROFILER_HBASE_TABLE, 
PROFILER_ROW_KEY_BUILDER, PROFILER_COLUMN_BUILDER };
    --- End diff --
    
    Sure, You notice 
[here](https://github.com/cestella/incubator-metron/blob/cd6348279744ba521d99f1dbe71030fafad6cd1a/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java#L91)
 that I'm doing something similar except instead of insisting that the 
capability be there prior to the function, I look for the configuration 
information (i.e. the table provider and such) in the global config.  This way, 
we don't have to add new capabilities to every single topology (parser, 
enrichment and now profiler) for every stellar function.  Instead, they can 
pull their configs from the global config.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to