/** * Initialization to be done after constructor assignments, such as setting of the all-important * DDFManager. */ protected void initialize( DDFManager manager, Object data, Class<?>[] typeSpecs, String namespace, String name, Schema schema) throws DDFException { this.validateSchema(schema); this.setManager(manager); // this must be done first in case later stuff needs a manager if (typeSpecs != null) { this.getRepresentationHandler().set(data, typeSpecs); } this.getSchemaHandler().setSchema(schema); if (schema != null && schema.getTableName() == null) { String tableName = this.getSchemaHandler().newTableName(); schema.setTableName(tableName); } if (Strings.isNullOrEmpty(namespace)) namespace = this.getManager().getNamespace(); this.setNamespace(namespace); manager.setDDFUUID(this, UUID.randomUUID()); if (!Strings.isNullOrEmpty(name)) manager.setDDFName(this, name); // Facades this.ML = new MLFacade(this, this.getMLSupporter()); this.VIEWS = new ViewsFacade(this, this.getViewHandler()); this.Transform = new TransformFacade(this, this.getTransformationHandler()); this.R = new RFacade(this, this.getAggregationHandler()); this.mCreatedTime = new Date(); }
// ////// MetaData that deserves to be right here at the top level //////// private void validateSchema(Schema schema) throws DDFException { Set<String> columnSet = new HashSet<String>(); if (schema != null && schema.getColumns() != null) { for (Column column : schema.getColumns()) { if (columnSet.contains(column.getName())) { throw new DDFException(String.format("Duplicated column name %s", column.getName())); } else { columnSet.add(column.getName()); } } } }
/** * @param manager * @param data * @param typeSpecs * @param namespace * @param name * @param schema * @param tableName: name of the underlying table that representing the DDF * @throws DDFException */ protected void initialize( DDFManager manager, Object data, Class<?>[] typeSpecs, String namespace, String name, Schema schema, String tableName) throws DDFException { initialize(manager, data, typeSpecs, namespace, name, schema); if (schema != null && tableName != null) { schema.setTableName(tableName); } }