Using H2OApi Java bindings to retrieve H2O Frame

可紊 提交于 2019-12-23 03:12:57

问题


I work on a Java project using the H2O (3.10.4.7) REST Api provided by the H2O Java bindings and I have the following problem:

We need to retrieve Metadata from existing H2O Frames like:

  • Column Names and
  • DataTypes of those columns,

preferrably using the H2oApi.class.

Our approach is to fetch one Row from the H2O Frame and then use it to get the Metadata we need.

So far I tried the following:

 FramesV3 targetFrame = new FramesV3();
 targetFrame.frameId = frameKey; // key provided by import process - works
 targetFrame.rowCount = 1; // get one row to figure out specs of all cols
 H2OApi h2oApi = new H2OApi("http://localhost:54321/");
 FramesV3 result = h2oApi.frames(targetFrame);

I get this Exception:

 java.lang.IllegalArgumentException: @Field parameters can only be used with form encoding. (parameter #1)
 for method Frames.list
 at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:695)
 at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:686)
 at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:704)
 at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:476)
 at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:328)
 at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:201)
 at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
 at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
 at com.sun.proxy.$Proxy14.list(Unknown Source)
 at water.bindings.H2oApi.frames(H2oApi.java:882)
 at H2ORestCloudTests.getSpecFromFrameTest(H2ORestCloudTests.java:388)

If I use the REST API Frames Endpoint via Browser it works. Example:

"http://localhost:54321/3/Frames/89a05762-4bcd-41d8-a800-f9cfc3ac73dd?row_count=1"

Result in Browser:

 {

 "__meta": {
     "schema_version": 3,
     "schema_name": "FramesV3",
     "schema_type": "Frames"
 },
 "_exclude_fields": "",
 "row_offset": 0,
 "row_count": 1,
 "column_offset": 0,
 "column_count": 0,
 "job": null,
 "frames": [
     {
         "__meta": {
             "schema_version": 3,
             "schema_name": "FrameV3",
             "schema_type": "Frame"
         },
         "_exclude_fields": "",
         "frame_id": {
             "__meta": {
                 "schema_version": 3,
                 "schema_name": "FrameKeyV3",
                 "schema_type": "Key<Frame>"
             },
             "name": "89a05762-4bcd-41d8-a800-f9cfc3ac73dd",
             "type": "Key<Frame>",
             "URL": "/3/Frames/89a05762-4bcd-41d8-a800-f9cfc3ac73dd"
         },
         "byte_size": 1928,
         "is_text": false,
         "row_offset": 0,
         "row_count": 1,
         "column_offset": 0,
         "column_count": 5,
         "total_column_count": 5,
         "checksum": -7731554748204616990,
         "rows": 150,
         "num_columns": 5,
         "default_percentiles": [
             0.001,
             0.01,
             0.1,
             0.2,
             0.25,
             0.3,
             0.3333333333333333,
             0.4,
             0.5,
             0.6,
             0.6666666666666666,
             0.7,
             0.75,
             0.8,
             0.9,
             0.99,
             0.999
         ],
         "columns": [
             {
                 "__meta": {
                     "schema_version": 3,
                     "schema_name": "ColV3",
                     "schema_type": "Vec"
                 },
                 "label": "sepal_length",
                 "missing_count": 0,
                 "zero_count": 0,
                 "positive_infinity_count": 0,
                 "negative_infinity_count": 0,
                 "mins": [
                     4.3,
                     4.4,
                     4.4,
                     4.4,
                     4.5
                 ],
                 "maxs": [
                     7.9,
                     7.7,
                     7.7,
                     7.7,
                     7.7
                 ],
                 "mean": 5.843333333333334,
                 "sigma": 0.8280661279778637,
                 "type": "real",
                 "domain": null,
                 "domain_cardinality": 0,
                 "data": [
                     5.1000000000000005
                 ],
                 "string_data": null,
                 "precision": 1,
                 "histogram_bins": null,
                 "histogram_base": 0.0,
                 "histogram_stride": 0.0,
                 "percentiles": null
             },
             ...
 }

Am I missing something or is there maybe a better way to get those Frame infos via the H2O Java Rest API?

Thank you in advance and have a nice day!

Nico


回答1:


To answer the original question (exception) this is indeed a bug in H2O, currently there's no workaround besides building from this branch.

As pointed out this method does not return the metadata, will answer this part in this question.



来源:https://stackoverflow.com/questions/44110233/using-h2oapi-java-bindings-to-retrieve-h2o-frame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!