| 20 | * |
| 21 | */ |
| 22 | public class ViewHandler extends ADDFFunctionalGroupHandler implements IHandleViews { |
| 23 | |
| 24 | public ViewHandler(DDF theDDF) { |
| 25 | super(theDDF); |
| 26 | } |
| 27 | |
| 28 | // @SuppressWarnings("unchecked") |
| 29 | // @Override |
| 30 | // public <T> Iterator<T> getRowIterator(Class<T> dataType) { |
| 31 | // if (dataType == null) dataType = (Class<T>) this.getDDF().getRepresentationHandler().getDefaultDataType(); |
| 32 | // |
| 33 | // Object repr = this.getDDF().getRepresentationHandler().get(dataType); |
| 34 | // return (repr instanceof Iterable<?>) ? ((Iterable<T>) repr).iterator() : null; |
| 35 | // } |
| 36 | |
| 37 | @Override |
| 38 | public List<Object[]> getRandomSample(int numSamples, boolean withReplacement, int seed) { |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public DDF getRandomSampleByNum(long numSamples, boolean withReplacement, |
| 44 | int seed) { |
| 45 | return null; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public DDF getRandomSample(double percent, boolean withReplacement, int seed) { |
| 50 | return null; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public DDF getRandomSampleApprox(double percent, boolean withReplacement, int seed) { |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | @Override |
| 60 | public List<String> head(int numRows) throws DDFException { |
| 61 | return this.getDDF().sql(String.format("SELECT * FROM @this LIMIT %d", numRows), |
| 62 | String.format("Unable to fetch %d row(s) from table %%s", numRows)).getRows(); |
| 63 | } |
| 64 | |
| 65 | public List<String> top(int numRows, String orderColumns, String mode) throws DDFException { |
| 66 | |
| 67 | DDF temp = sql2ddf(String.format("SELECT * FROM %%s order by %s %s", orderColumns, mode), |
| 68 | String.format("Unable to fetch %d row(s) from table %%s", numRows)); |
| 69 | |
| 70 | return (temp.VIEWS.head(numRows)); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public DDF project(String... columnNames) throws DDFException { |
| 75 | if (columnNames == null || columnNames.length == 0) throw new DDFException("columnNames must be specified"); |
| 76 | List<String> colNames = new ArrayList<String>(columnNames.length); |
| 77 | for(String col: columnNames) {colNames.add(col);} |
| 78 | return project(colNames); |
| 79 | } |
nothing calls this directly
no outgoing calls
no test coverage detected