@Override public void unsetAsFactor(int columnIndex) { if (this.getSchema() != null) this.getSchema().getColumn(columnIndex).unsetAsFactor(); }
/** * Gets an existing representation for our {@link DDF} matching the given dataType, if any. * * @param typeSpecs * @return null if no matching representation available */ @Override public Object get(Class<?>... typeSpecs) throws DDFException { // return this.get(this.getSpecsAsString(typeSpecs), true); return this.get(Representation.typeSpecsToString(typeSpecs), true); }
public void copy(IHandleMetaData fromMetaData) throws DDFException { if(fromMetaData instanceof AMetaDataHandler) { AMetaDataHandler metaDataHandler = (AMetaDataHandler) fromMetaData; this.mLastRefreshTime = metaDataHandler.getLastRefreshTime(); this.mLastRefreshUser = metaDataHandler.getLastRefreshUser(); this.mLastModifiedTime = metaDataHandler.getLastModifiedTime(); this.mLastModifiedUser = metaDataHandler.getLastModifiedUser(); } this.copyFactor(fromMetaData.getDDF()); }
@Test public void testParseSchema() throws DDFException { String columns = "row Int, \n\tprice double, \n\t lotsize int, \n\t bedrooms int,\n\tbathrms int"; Schema schema = new Schema(null, columns); for(Schema.Column column: schema.getColumns()) { assert(column.getName() != null); assert(column.getType().toString() != null); } } }
@Override public Column clone() { Column clonedColumn = new Column(this.getName(), this.getType()); if (mClass == ColumnClass.FACTOR) { clonedColumn = clonedColumn.setAsFactor(mOptionalFactor); } return clonedColumn; }
@Override public DDF updateInplace(DDF newddf) throws DDFException { //copy content of newddf to this ddf DDF curDDF = this.getDDF(); curDDF.getRepresentationHandler().reset(); curDDF.getRepresentationHandler().setRepresentations(newddf.getRepresentationHandler().getAllRepresentations()); newddf.getMetaDataHandler().copyFactor(this.getDDF()); curDDF.getSchemaHandler().setSchema(newddf.getSchema()); return curDDF; } }
@Override public Schema generateSchema() throws DDFException { if (this.getSchema() != null) return this.getSchema(); // Try to infer from the DDF's data Object data = this.getDDF().getRepresentationHandler().getDefault(); // TODO: for now, we'll just support the "null" case if (data == null) return new Schema(null, "null BLOB"); return null; }
public DummyRepresentationHandler(DDF ddf) { super(ddf); Representation rep1 = new Representation(Double[].class); Representation rep2 = new Representation(Object[].class); Representation rep3 = new Representation(Integer[].class); Representation rep4 = new Representation(String[].class); this.addConvertFunction(rep1, rep2, new DoubleToObject(this.getDDF())); this.addConvertFunction(rep2, rep3, new ObjectToInt(this.getDDF())); this.addConvertFunction(rep3, rep4, new IntToString(this.getDDF())); } }
@Override public IGetResult get(Class<?>[][] acceptableTypeSpecs) throws DDFException { if (acceptableTypeSpecs == null || acceptableTypeSpecs.length == 0) return null; // First check what formats are *already* there, so we can save the effort of having to create it for (Class<?>[] ats : acceptableTypeSpecs) { if (this.has(ats)) return new GetResult(this.get(ats), ats); } // Now see which formats can be created for (Class<?>[] ats : acceptableTypeSpecs) { Object result = this.get(ats); if (result != null) return new GetResult(result, ats); } return null; }
@Override public void setFactorLevels(String columnName, Factor<?> factor) throws DDFException { Column c = this.getColumn(columnName); Factor<?> f = c.getOptionalFactor(); if(factor.getLevelCounts() != null) { f.setLevelCounts(factor.getLevelCounts()); } if(factor.getLevels() != null) { f.setLevels(factor.getLevels(), false); } }
public RepresentationHandler(DDF theDDF) { super(theDDF); this.mGraph = new RepresentationsGraph(this.getDDF()); }
public void generateDummyCoding() throws NumberFormatException, DDFException { this.getSchema().generateDummyCoding(); }
public Column(String name, ColumnType type) { this.mName = name; this.mType = type; this.mClass = ColumnClass.get(type); }
@Override public long getNumRows() throws DDFException { if (!bNumRowsIsValid) { mNumRows = this.getNumRowsImpl(); // bNumRowsIsValid = true; } return mNumRows; }
@Override public void addConvertFunction(Representation fromRepresentation, Representation toRepresentation, ConvertFunction convertFunction) { this.mGraph.addEdge(fromRepresentation, toRepresentation, convertFunction); }
public String toString(){ String outString = ""; for (String s : schema.getColumnNames()) { outString += s + "\t"; } outString += "\n"; for (String s : rows) { outString += s + "\n"; } return outString; } }
@Override public IGetResult get(String[] acceptableTypeSpecs) throws DDFException { if (acceptableTypeSpecs == null || acceptableTypeSpecs.length == 0) return null; // First check what formats are *already* there, so we can save the effort of having to create it for (String ats : acceptableTypeSpecs) { if (this.has(ats)) return new GetResult(this.get(ats, false), ats); } // Now see which formats can be created for (String ats : acceptableTypeSpecs) { Object result = this.get(ats, true); if (result != null) return new GetResult(result, ats); } return null; }
public Column unsetAsFactor() { mClass = ColumnClass.get(mType); mOptionalFactor = null; return this; }