use of water.api.schemas3.TwoDimTableV3 in project h2o-3 by h2oai.
the class FrameV3 method fillFromImpl.
public FrameV3 fillFromImpl(Frame f, long row_offset, int row_count, int column_offset, int column_count) {
// 100 rows by default
if (row_count == 0)
row_count = 100;
// full width by default
if (column_count == 0)
column_count = f.numCols() - column_offset;
row_count = (int) Math.min(row_count, row_offset + f.numRows());
column_count = Math.min(column_count, column_offset + f.numCols());
this.frame_id = new FrameKeyV3(f._key);
this.checksum = f.checksum();
this.byte_size = f.byteSize();
this.row_offset = row_offset;
this.rows = f.numRows();
this.num_columns = f.numCols();
this.row_count = row_count;
this.total_column_count = f.numCols();
this.column_offset = column_offset;
this.column_count = column_count;
this.columns = new ColV3[column_count];
Vec[] vecs = f.vecs();
Futures fs = new Futures();
// NOTE: SKIP deleted Vecs! The columns entry will be null for deleted Vecs.
for (int i = 0; i < column_count; i++) if (null == DKV.get(vecs[column_offset + i]._key))
Log.warn("For Frame: " + f._key + ", Vec number: " + (column_offset + i) + " (" + f.name((column_offset + i)) + ") is missing; not returning it.");
else
vecs[column_offset + i].startRollupStats(fs);
for (int i = 0; i < column_count; i++) if (null == DKV.get(vecs[column_offset + i]._key))
Log.warn("For Frame: " + f._key + ", Vec number: " + (column_offset + i) + " (" + f.name((column_offset + i)) + ") is missing; not returning it.");
else
columns[i] = new ColV3(f._names[column_offset + i], vecs[column_offset + i], this.row_offset, this.row_count);
fs.blockForPending();
this.is_text = f.numCols() == 1 && vecs[0] instanceof ByteVec;
this.default_percentiles = Vec.PERCENTILES;
ChunkSummary cs = FrameUtils.chunkSummary(f);
this.chunk_summary = new TwoDimTableV3(cs.toTwoDimTableChunkTypes());
this.distribution_summary = new TwoDimTableV3(cs.toTwoDimTableDistribution());
this._fr = f;
return this;
}
use of water.api.schemas3.TwoDimTableV3 in project h2o-3 by h2oai.
the class ChunkSummaryTest method run.
@Test
public void run() {
CreateFrame cf = new CreateFrame();
cf.seed = 1234;
Frame f = cf.execImpl().get();
ChunkSummary cs = FrameUtils.chunkSummary(f);
TwoDimTable chunk_summary_table = cs.toTwoDimTableChunkTypes();
Log.info(chunk_summary_table);
TwoDimTableV3 td = new TwoDimTableV3().fillFromImpl(chunk_summary_table);
String json = td.toJsonString();
// if (H2O.CLOUD.size() == 1) {
// Assert.assertEquals("{\"__meta\":{\"schema_version\":3,\"schema_name\":\"TwoDimTableV3\"," +
// "\"schema_type\":\"TwoDimTable\"},\"name\":\"Chunk compression summary\",\"description\":\"\",\"columns\":[{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"chunk_type\",\"type\":\"string\",\"format\":\"%8s\",\"description\":\"Chunk Type\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"chunk_name\",\"type\":\"string\",\"format\":\"%s\",\"description\":\"Chunk Name\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"count\",\"type\":\"int\",\"format\":\"%10d\",\"description\":\"Count\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"count_percentage\",\"type\":\"float\",\"format\":\"%10.3f %%\",\"description\":\"Count Percentage\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"size\",\"type\":\"string\",\"format\":\"%10s\",\"description\":\"Size\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"size_percentage\",\"type\":\"float\",\"format\":\"%10.3f %%\",\"description\":\"Size Percentage\"}],\"rowcount\":4,\"data\":[[\"CXI\",\"C1\",\"C1S\",\"C8D\"],[\"Sparse Integers\",\"1-Byte Integers\",\"1-Byte Fractions\",\"64-bit Reals\"],[9,18,18,45],[10.0,20.0,20.0,50.0],[\" 1.9 KB\",\" 20.7 KB\",\" 21.0 KB\",\" 393.6 KB\"],[0.42528477,4.7406745,4.8050036,90.02904]]}"
// ,json);
// }
TwoDimTable distribution_summary_table = cs.toTwoDimTableDistribution();
Log.info(distribution_summary_table);
json = new TwoDimTableV3().fillFromImpl(distribution_summary_table).toJsonString();
// if (H2O.CLOUD.size() == 1) {
// Assert.assertEquals("{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"TwoDimTableV3\"," +
// "\"schema_type\":\"TwoDimTable\"},\"name\":\"Frame distribution summary\",\"description\":\"\",\"columns\":[{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"\",\"type\":\"string\",\"format\":\"%s\",\"description\":\"\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"size\",\"type\":\"string\",\"format\":\"%s\",\"description\":\"Size\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"number_of_rows\",\"type\":\"float\",\"format\":\"%f\",\"description\":\"Number of Rows\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"number_of_chunks_per_column\",\"type\":\"float\",\"format\":\"%f\",\"description\":\"Number of Chunks per Column\"},{\"__meta\":{\"schema_version\":-1,\"schema_name\":\"ColumnSpecsBase\",\"schema_type\":\"Iced\"},\"name\":\"number_of_chunks\",\"type\":\"float\",\"format\":\"%f\",\"description\":\"Number of Chunks\"}],\"rowcount\":6,\"data\":[[\"172.16.2.81:54321\",\"mean\",\"min\",\"max\",\"stddev\",\"total\"],[\" 436.9 KB\",\" 436.9 KB\",\" 436.9 KB\",\" 436.9 KB\",\" 0 B\",\" 436.9 KB\"],[10000.0,10000.0,10000.0,10000.0,0.0,10000.0],[9.0,9.0,9.0,9.0,0.0,9.0],[90.0,90.0,90.0,90.0,0.0,90.0]]}", json);
// }
f.remove();
}
use of water.api.schemas3.TwoDimTableV3 in project h2o-3 by h2oai.
the class TwoDimTableTest method run3.
@Test
public void run3() {
TwoDimTable table = new TwoDimTable("My foo bar table", "desc", new String[] { "First row", "R2", "Row #3", "Last row is here:" }, new String[] { "DoubleValue", "S2", "My Terrible Percent Value" }, new String[] { "double", "string", "double" }, new String[] { "%f", "%s", "%f" }, "", new String[][] { new String[] { null, "One", null }, new String[] { null, null, null }, new String[] { null, "Three", null }, new String[] { null, "FooBar", null } }, new double[][] { new double[] { 1.123, emptyDouble, 3200034.00001 }, new double[] { 123.34, emptyDouble, 1.0 }, new double[] { emptyDouble, emptyDouble, 3234.00001 }, new double[] { 3.33420923423423, emptyDouble, 3.40234234 } });
String ts = table.toString();
assertTrue(ts.length() > 0);
Log.info(ts);
String json = new TwoDimTableV3().fillFromImpl(table).toJsonString();
Log.info(json);
}
use of water.api.schemas3.TwoDimTableV3 in project h2o-3 by h2oai.
the class TwoDimTableTest method run1.
@Test
public void run1() {
TwoDimTable table = new TwoDimTable("My foo bar table", "Corner value", new String[] { "First row", "R2", "Row #3", "Last row is here:" }, new String[] { "DoubleValue", "S2", "My Terrible Percent Value" }, new String[] { "double", "string", "double" }, new String[] { "%5.8e", "%s", "%5.8g %%" }, "", new String[][] { new String[] { null, "One", null }, new String[] { null, null, null }, new String[] { null, "Three", null }, new String[] { null, "FooBar", null } }, new double[][] { new double[] { 1.123, emptyDouble, 3200034.00001 }, new double[] { 123.34, emptyDouble, 1.0 }, new double[] { emptyDouble, emptyDouble, 3234.00001 }, new double[] { 3.33420923423423, emptyDouble, 3.40234234 } });
String ts = table.toString();
assertTrue(ts.length() > 0);
Log.info(ts);
String json = new TwoDimTableV3().fillFromImpl(table).toJsonString();
Log.info(json);
}
use of water.api.schemas3.TwoDimTableV3 in project h2o-3 by h2oai.
the class TwoDimTableTest method run7.
@Test
public void run7() {
TwoDimTable table = new TwoDimTable("Mixed", "description", new String[] { "R0", "R1", "R2", "R3" }, new String[] { "C0", "C1", "C2", "C3" }, new String[] { "double", "float", "int", "long" }, new String[] { "%f", "%f", "%d", "%d" }, "");
table.set(0, 0, Double.NEGATIVE_INFINITY);
table.set(1, 0, Double.POSITIVE_INFINITY);
table.set(2, 0, Double.NaN);
table.set(3, 0, Math.PI);
table.set(0, 1, Float.NEGATIVE_INFINITY);
table.set(1, 1, Float.POSITIVE_INFINITY);
table.set(2, 1, Float.NaN);
table.set(3, 1, Float.MIN_VALUE);
table.set(0, 2, Integer.MAX_VALUE);
table.set(1, 2, Integer.MIN_VALUE);
table.set(2, 2, Double.NaN);
table.set(3, 2, 0);
table.set(0, 3, Long.MAX_VALUE);
table.set(1, 3, Long.MIN_VALUE);
table.set(2, 3, Double.NaN);
table.set(3, 3, null);
String ts = table.toString();
assertTrue(ts.length() > 0);
Log.info(ts);
assertTrue(table.get(0, 0).equals(Double.NEGATIVE_INFINITY));
assertTrue(table.get(1, 0).equals(Double.POSITIVE_INFINITY));
assertTrue(table.get(2, 0).equals(Double.NaN));
assertTrue(table.get(3, 0).equals(Math.PI));
assertTrue(table.get(0, 1).equals(Float.NEGATIVE_INFINITY));
assertTrue(table.get(1, 1).equals(Float.POSITIVE_INFINITY));
assertTrue(table.get(2, 1).equals(Float.NaN));
assertTrue(table.get(3, 1).equals(Float.MIN_VALUE));
assertTrue(table.get(0, 2).equals(Integer.MAX_VALUE));
assertTrue(table.get(1, 2).equals(Integer.MIN_VALUE));
assertTrue(table.get(2, 2).equals(Double.NaN));
assertTrue(table.get(3, 2).equals(0));
assertTrue(table.get(0, 3).equals(Long.MAX_VALUE));
assertTrue(table.get(1, 3).equals(Long.MIN_VALUE));
assertTrue(table.get(2, 3).equals(Double.NaN));
assertTrue(table.get(3, 3) == null);
String json = new TwoDimTableV3().fillFromImpl(table).toJsonString();
Log.info(json);
}
Aggregations