/** * Gets the default table name from the configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return the default table name * @since 1.6.0 * @see #setDefaultTableName(Class, Configuration, String) */ public static String getDefaultTableName(Class<?> implementingClass, Configuration conf) { return conf.get(enumToConfKey(implementingClass, WriteOpts.DEFAULT_TABLE_NAME)); }
/** * Determines whether tables are permitted to be created as needed. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return true if the feature is disabled, false otherwise * @since 1.6.0 * @see #setCreateTables(Class, Configuration, boolean) */ public static Boolean canCreateTables(Class<?> implementingClass, Configuration conf) { return conf.getBoolean(enumToConfKey(implementingClass, Features.CAN_CREATE_TABLES), false); }
/** * Determines whether tables are permitted to be created as needed. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return true if the feature is disabled, false otherwise * @since 1.6.0 * @see #setCreateTables(Class, Configuration, boolean) */ public static Boolean canCreateTables(Class<?> implementingClass, Configuration conf) { return conf.getBoolean(enumToConfKey(implementingClass, Features.CAN_CREATE_TABLES), false); }
/** * Gets the default table name from the configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return the default table name * @since 1.6.0 * @see #setDefaultTableName(Class, Configuration, String) */ public static String getDefaultTableName(Class<?> implementingClass, Configuration conf) { return conf.get(enumToConfKey(implementingClass, WriteOpts.DEFAULT_TABLE_NAME)); }
/** * Determines whether this feature is enabled. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return true if the feature is enabled, false otherwise * @since 1.6.0 * @see #setSimulationMode(Class, Configuration, boolean) */ public static Boolean getSimulationMode(Class<?> implementingClass, Configuration conf) { return conf.getBoolean(enumToConfKey(implementingClass, Features.SIMULATION_MODE), false); }
/** * Determines whether this feature is enabled. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return true if the feature is enabled, false otherwise * @since 1.6.0 * @see #setSimulationMode(Class, Configuration, boolean) */ public static Boolean getSimulationMode(Class<?> implementingClass, Configuration conf) { return conf.getBoolean(enumToConfKey(implementingClass, Features.SIMULATION_MODE), false); }
/** * Sets the default table name to use if one emits a null in place of a table name for a given * mutation. Table names can only be alpha-numeric and underscores. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param tableName * the table to use when the tablename is null in the write call * @since 1.6.0 */ public static void setDefaultTableName(Class<?> implementingClass, Configuration conf, String tableName) { if (tableName != null) conf.set(enumToConfKey(implementingClass, WriteOpts.DEFAULT_TABLE_NAME), tableName); }
/** * Sets the default table name to use if one emits a null in place of a table name for a given * mutation. Table names can only be alpha-numeric and underscores. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param tableName * the table to use when the tablename is null in the write call * @since 1.6.0 */ public static void setDefaultTableName(Class<?> implementingClass, Configuration conf, String tableName) { if (tableName != null) conf.set(enumToConfKey(implementingClass, WriteOpts.DEFAULT_TABLE_NAME), tableName); }
/** * Sets the directive to create new tables, as necessary. Table names can only be alpha-numeric * and underscores. * * <p> * By default, this feature is <b>disabled</b>. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param enableFeature * the feature is enabled if true, disabled otherwise * @since 1.6.0 */ public static void setCreateTables(Class<?> implementingClass, Configuration conf, boolean enableFeature) { conf.setBoolean(enumToConfKey(implementingClass, Features.CAN_CREATE_TABLES), enableFeature); }
/** * Sets the directive to use simulation mode for this job. In simulation mode, no output is * produced. This is useful for testing. * * <p> * By default, this feature is <b>disabled</b>. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param enableFeature * the feature is enabled if true, disabled otherwise * @since 1.6.0 */ public static void setSimulationMode(Class<?> implementingClass, Configuration conf, boolean enableFeature) { conf.setBoolean(enumToConfKey(implementingClass, Features.SIMULATION_MODE), enableFeature); }
/** * Sets the directive to create new tables, as necessary. Table names can only be alpha-numeric * and underscores. * * <p> * By default, this feature is <b>disabled</b>. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param enableFeature * the feature is enabled if true, disabled otherwise * @since 1.6.0 */ public static void setCreateTables(Class<?> implementingClass, Configuration conf, boolean enableFeature) { conf.setBoolean(enumToConfKey(implementingClass, Features.CAN_CREATE_TABLES), enableFeature); }
/** * Sets the directive to use simulation mode for this job. In simulation mode, no output is * produced. This is useful for testing. * * <p> * By default, this feature is <b>disabled</b>. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param enableFeature * the feature is enabled if true, disabled otherwise * @since 1.6.0 */ public static void setSimulationMode(Class<?> implementingClass, Configuration conf, boolean enableFeature) { conf.setBoolean(enumToConfKey(implementingClass, Features.SIMULATION_MODE), enableFeature); }
/** * Sets the configuration for for the job's {@link BatchWriter} instances. If not set, a new * {@link BatchWriterConfig}, with sensible built-in defaults is used. Setting the configuration * multiple times overwrites any previous configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param bwConfig * the configuration for the {@link BatchWriter} * @since 1.6.0 */ public static void setBatchWriterOptions(Class<?> implementingClass, Configuration conf, BatchWriterConfig bwConfig) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); String serialized; try { bwConfig.write(new DataOutputStream(baos)); serialized = new String(baos.toByteArray(), UTF_8); baos.close(); } catch (IOException e) { throw new IllegalArgumentException( "unable to serialize " + BatchWriterConfig.class.getName()); } conf.set(enumToConfKey(implementingClass, WriteOpts.BATCH_WRITER_CONFIG), serialized); }
/** * Sets the configuration for for the job's {@link BatchWriter} instances. If not set, a new * {@link BatchWriterConfig}, with sensible built-in defaults is used. Setting the configuration * multiple times overwrites any previous configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param bwConfig * the configuration for the {@link BatchWriter} * @since 1.6.0 */ public static void setBatchWriterOptions(Class<?> implementingClass, Configuration conf, BatchWriterConfig bwConfig) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); String serialized; try { bwConfig.write(new DataOutputStream(baos)); serialized = new String(baos.toByteArray(), UTF_8); baos.close(); } catch (IOException e) { throw new IllegalArgumentException( "unable to serialize " + BatchWriterConfig.class.getName()); } conf.set(enumToConfKey(implementingClass, WriteOpts.BATCH_WRITER_CONFIG), serialized); }
/** * Gets the {@link BatchWriterConfig} settings. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return the configuration object * @since 1.6.0 * @see #setBatchWriterOptions(Class, Configuration, BatchWriterConfig) */ public static BatchWriterConfig getBatchWriterOptions(Class<?> implementingClass, Configuration conf) { String serialized = conf.get(enumToConfKey(implementingClass, WriteOpts.BATCH_WRITER_CONFIG)); BatchWriterConfig bwConfig = new BatchWriterConfig(); if (serialized == null || serialized.isEmpty()) { return bwConfig; } else { try { ByteArrayInputStream bais = new ByteArrayInputStream(serialized.getBytes(UTF_8)); bwConfig.readFields(new DataInputStream(bais)); bais.close(); return bwConfig; } catch (IOException e) { throw new IllegalArgumentException( "unable to serialize " + BatchWriterConfig.class.getName()); } } }
/** * Gets the {@link BatchWriterConfig} settings. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return the configuration object * @since 1.6.0 * @see #setBatchWriterOptions(Class, Configuration, BatchWriterConfig) */ public static BatchWriterConfig getBatchWriterOptions(Class<?> implementingClass, Configuration conf) { String serialized = conf.get(enumToConfKey(implementingClass, WriteOpts.BATCH_WRITER_CONFIG)); BatchWriterConfig bwConfig = new BatchWriterConfig(); if (serialized == null || serialized.isEmpty()) { return bwConfig; } else { try { ByteArrayInputStream bais = new ByteArrayInputStream(serialized.getBytes(UTF_8)); bwConfig.readFields(new DataInputStream(bais)); bais.close(); return bwConfig; } catch (IOException e) { throw new IllegalArgumentException( "unable to serialize " + BatchWriterConfig.class.getName()); } } }