/** * Query one entity record that matches the given filter. If * there is more than one record, then it is undefined which one is * returned. If there are no matches than return null or raise * UnknownRecException based on checked flag. * NOTE: Was final */ public HDict read(string filter, bool bChecked) { HGrid grid = readAll(filter, 1); if (grid.numRows > 0) { return(grid.row(0)); } if (bChecked) { throw new Exception("rec not found for: " + filter); } return(null); }
// Map HGrid to HHisItem[]. Grid must have ts and val columns. public static HHisItem[] gridToItems(HGrid grid) { HCol ts = grid.col("ts"); HCol val = grid.col("val"); HHisItem[] items = new HHisItem[grid.numRows]; for (int i = 0; i < items.Length; ++i) { HRow row = grid.row(i); // Timestamp can't be NULL but val can items[i] = new HHisItem((HDateTime)row.get(ts, true), row.get(val, false)); } return(items); }
public override bool hequals(object o) { // Instance check if (o.Equals(this)) { return(true); } // null and unlike type check if (o == null || GetType() != o.GetType()) { return(false); } // further checks require it is of type HGrid if (!(o is HGrid)) { return(false); } HGrid gridO = (HGrid)o; // Compare Meta if (!meta.hequals(gridO.meta)) { return(false); } // Compare Cols - don't like the java implementation if (numCols != gridO.numCols) { return(false); } for (int iCurCol = 0; iCurCol < numCols; iCurCol++) { if (!col(iCurCol).hequals(gridO.col(iCurCol))) { return(false); } } // Compare Rows - don't like the java implementation if (numRows != gridO.numRows) { return(false); } for (int iCurRow = 0; iCurRow < numRows; iCurRow++) { if (!row(iCurRow).hequals(gridO.col(iCurRow))) { return(false); } } return(true); }
/** * Read a list of entity records by their unique identifier. * Return a grid where each row of the grid maps to the respective * id array (indexes line up). If checked is true and any one of the * ids cannot be resolved then raise UnknownRecException for first id * not resolved. If checked is false, then each id not found has a * row where every cell is null. * NOTE: Was final */ public HGrid readByIds(HRef[] ids, bool bChecked) { HGrid grid = onReadByIds(ids); if (bChecked) { for (int i = 0; i < grid.numRows; ++i) { if (grid.row(i).missing("id")) { throw new Exception("rec not found for: " + ids[i].ToString()); } } } return(grid); }
public static HaystackGrid Map(HGrid value) { return(value.Source); }
// internal constructor internal HRow(HGrid grid, List <HVal> cells) : base(new Dictionary <string, HVal>(11)) { m_cells = cells; Grid = grid; }
public static HHisItem[] gridToItems(HGrid grid) => HaystackHistoryItem.ReadGrid(M.Map(grid)).Select(M.Map).ToArray();