You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by brightchen <gi...@git.apache.org> on 2015/11/17 01:18:20 UTC

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

GitHub user brightchen opened a pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100

    MLHR-1906 #resolve #comment Snapshot Server support tags

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/brightchen/incubator-apex-malhar MLHR-1906

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-apex-malhar/pull/100.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #100
    
----
commit 2cf4de6f4b54cf26f72f46cb5373b2082e3753e1
Author: bright <br...@bright-mac.local>
Date:   2015-11-17T00:16:18Z

    MLHR-1906 #resolve #comment Snapshot Server support tags

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45012931
  
    --- Diff: library/src/test/resources/satisfactionRatingSnapshotSchema_test.json ---
    @@ -0,0 +1,8 @@
    +{
    +  "values": [
    +    {"name": "current", "type": "long", "tags": ["current"]}, 
    +    {"name": "min", "type": "long", "tags": ["min"]}, 
    +    {"name": "max", "type": "long", "tags": ["max"]}, 
    +    {"name": "threshold", "type": "long", "tags": ["threshold"]}
    +  ]
    +}
    --- End diff --
    
    Add a newline at the end of the file.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45016459
  
    --- Diff: library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerTagsSupportTest.java ---
    @@ -0,0 +1,67 @@
    +package com.datatorrent.lib.appdata.snapshot;
    +
    +import org.codehaus.jettison.json.JSONArray;
    +import org.codehaus.jettison.json.JSONObject;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import com.google.common.collect.Sets;
    +
    +import com.datatorrent.lib.appdata.gpo.GPOMutable;
    +import com.datatorrent.lib.appdata.schemas.Schema;
    +import com.datatorrent.lib.appdata.schemas.SchemaResult;
    +import com.datatorrent.lib.appdata.schemas.SchemaUtils;
    +
    +public class AppDataSnapshotServerTagsSupportTest
    +{
    +  public static class AppDataSnapshotServerSchemaExport extends AbstractAppDataSnapshotServer<Object>
    +  {
    +    SchemaResult schemaResult;
    +    String schemaResultJSON;
    +
    +    @Override
    +    public GPOMutable convert(Object inputEvent)
    +    {
    +      return null;
    +    }
    +
    +    @Override
    +    public void endWindow()
    +    {
    +      while ((schemaResult = schemaQueue.poll()) != null) {
    +        schemaResultJSON = resultSerializerFactory.serialize(schemaResult);
    +        queryResult.emit(schemaResultJSON);
    +      }
    +
    +      queryProcessor.endWindow();
    +    }
    +  }
    +
    +  private static final String schemaLocation = "satisfactionRatingSnapshotSchema_test.json";
    +  private static final String TAG = "bulletin";
    +
    +  @Test
    +  public void testSchema() throws Exception
    --- End diff --
    
    Please add a test for a predifined schema string satisfactionRatingSnapshotSchema_test_2.json
    
    {
      "tags":["something"],
      "values": [
        {"name": "current", "type": "long", "tags": ["current"]}, 
        {"name": "min", "type": "long", "tags": ["min"]}, 
        {"name": "max", "type": "long", "tags": ["max"]}, 
        {"name": "threshold", "type": "long", "tags": ["threshold"]}
      ]
    }


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45016265
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    +      return;
    +
    +    JSONArray tagArray = new JSONArray();
    +
    +    try {
    +      int index = 0;
    +      for (String tag : tags)
    +        tagArray.put(index++, tag);
    +
    +      schema.put(FIELD_SCHEMA_TAGS, tagArray);
    +    } catch (JSONException e) {
    +      Preconditions.checkState(false, e.getMessage());
    --- End diff --
    
    Rethrow the exception so that the stack trace will be printed
    
    throw new RuntimeException(e);


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by brightchen <gi...@git.apache.org>.
Github user brightchen commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45023991
  
    --- Diff: library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerTagsSupportTest.java ---
    @@ -0,0 +1,67 @@
    +package com.datatorrent.lib.appdata.snapshot;
    +
    +import org.codehaus.jettison.json.JSONArray;
    +import org.codehaus.jettison.json.JSONObject;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import com.google.common.collect.Sets;
    +
    +import com.datatorrent.lib.appdata.gpo.GPOMutable;
    +import com.datatorrent.lib.appdata.schemas.Schema;
    +import com.datatorrent.lib.appdata.schemas.SchemaResult;
    +import com.datatorrent.lib.appdata.schemas.SchemaUtils;
    +
    +public class AppDataSnapshotServerTagsSupportTest
    +{
    +  public static class AppDataSnapshotServerSchemaExport extends AbstractAppDataSnapshotServer<Object>
    +  {
    +    SchemaResult schemaResult;
    +    String schemaResultJSON;
    +
    +    @Override
    +    public GPOMutable convert(Object inputEvent)
    +    {
    +      return null;
    +    }
    +
    +    @Override
    +    public void endWindow()
    +    {
    +      while ((schemaResult = schemaQueue.poll()) != null) {
    +        schemaResultJSON = resultSerializerFactory.serialize(schemaResult);
    +        queryResult.emit(schemaResultJSON);
    +      }
    +
    +      queryProcessor.endWindow();
    +    }
    +  }
    +
    +  private static final String schemaLocation = "satisfactionRatingSnapshotSchema_test.json";
    +  private static final String TAG = "bulletin";
    +
    +  @Test
    +  public void testSchema() throws Exception
    --- End diff --
    
    The Preconditions.checkState() in the initialize() method forbid keys in the first level. I am not sure why this precondition was checked, but maybe have some trap here if break this logic.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45016325
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    --- End diff --
    
    throw IllegalArgumentException


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45027429
  
    --- Diff: library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerTagsSupportTest.java ---
    @@ -0,0 +1,67 @@
    +package com.datatorrent.lib.appdata.snapshot;
    +
    +import org.codehaus.jettison.json.JSONArray;
    +import org.codehaus.jettison.json.JSONObject;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import com.google.common.collect.Sets;
    +
    +import com.datatorrent.lib.appdata.gpo.GPOMutable;
    +import com.datatorrent.lib.appdata.schemas.Schema;
    +import com.datatorrent.lib.appdata.schemas.SchemaResult;
    +import com.datatorrent.lib.appdata.schemas.SchemaUtils;
    +
    +public class AppDataSnapshotServerTagsSupportTest
    +{
    +  public static class AppDataSnapshotServerSchemaExport extends AbstractAppDataSnapshotServer<Object>
    +  {
    +    SchemaResult schemaResult;
    +    String schemaResultJSON;
    +
    +    @Override
    +    public GPOMutable convert(Object inputEvent)
    +    {
    +      return null;
    +    }
    +
    +    @Override
    +    public void endWindow()
    +    {
    +      while ((schemaResult = schemaQueue.poll()) != null) {
    +        schemaResultJSON = resultSerializerFactory.serialize(schemaResult);
    +        queryResult.emit(schemaResultJSON);
    +      }
    +
    +      queryProcessor.endWindow();
    +    }
    +  }
    +
    +  private static final String schemaLocation = "satisfactionRatingSnapshotSchema_test.json";
    +  private static final String TAG = "bulletin";
    +
    +  @Test
    +  public void testSchema() throws Exception
    --- End diff --
    
    I'm not sure I understand, maybe you can explain it to me tomorrow.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45016300
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    +      return;
    +
    +    JSONArray tagArray = new JSONArray();
    --- End diff --
    
    move this logic into initialize so that the schema is built in one place


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45012902
  
    --- Diff: library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerTagsSupportTest.java ---
    @@ -0,0 +1,67 @@
    +package com.datatorrent.lib.appdata.snapshot;
    --- End diff --
    
    Travis build is failing because correct license is not added at the top of the file. Please see other files in Malhar and copy the license header over. Also make sure that the year stated in the license is this year.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by brightchen <gi...@git.apache.org>.
Github user brightchen commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45097101
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    +      return;
    +
    +    JSONArray tagArray = new JSONArray();
    +
    +    try {
    +      int index = 0;
    +      for (String tag : tags)
    +        tagArray.put(index++, tag);
    +
    +      schema.put(FIELD_SCHEMA_TAGS, tagArray);
    +    } catch (JSONException e) {
    +      Preconditions.checkState(false, e.getMessage());
    --- End diff --
    
    There are several constructors, add this parameter to the constructors will add more constructors( one for no tags, one for tags ). So I think maybe use setTags more clear.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by ilooner <gi...@git.apache.org>.
Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45027363
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    +      return;
    +
    +    JSONArray tagArray = new JSONArray();
    +
    +    try {
    +      int index = 0;
    +      for (String tag : tags)
    +        tagArray.put(index++, tag);
    +
    +      schema.put(FIELD_SCHEMA_TAGS, tagArray);
    +    } catch (JSONException e) {
    +      Preconditions.checkState(false, e.getMessage());
    --- End diff --
    
    I see, Instead of a setTags method could you create a new constructor that takes the tags, and then do this work in initialize?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-apex-malhar/pull/100


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: MLHR-1906 #resolve #comment Sn...

Posted by brightchen <gi...@git.apache.org>.
Github user brightchen commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/100#discussion_r45023863
  
    --- Diff: library/src/main/java/com/datatorrent/lib/appdata/schemas/SnapshotSchema.java ---
    @@ -246,6 +247,26 @@ private void initialize() throws JSONException
         schemaJSON = this.schema.toString();
       }
     
    +  public void setTags(Set<String> tags)
    +  {
    +    if (tags == null || tags.isEmpty())
    +      return;
    +
    +    JSONArray tagArray = new JSONArray();
    +
    +    try {
    +      int index = 0;
    +      for (String tag : tags)
    +        tagArray.put(index++, tag);
    +
    +      schema.put(FIELD_SCHEMA_TAGS, tagArray);
    +    } catch (JSONException e) {
    +      Preconditions.checkState(false, e.getMessage());
    --- End diff --
    
    The method initialize() was called by the constructor. and the tags haven't set at that time.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---