.defaultValue("def") .build()); .defaultValue("def") .build()); Schema schema = new Schema(cols);
.addColumn(new ColumnSchema.ColumnSchemaBuilder("a", Type.INT64) .nullable(false) .defaultValue(0L).build())); token.intoScanner(client);
.key(columnSchema.isKey()) .nullable(columnSchema.isNullable()) .defaultValue(defaultValue).build());
@Test public void testEquals() { ColumnSchema stringCol1 = new ColumnSchemaBuilder("col1", Type.STRING) .defaultValue("test") .build(); .defaultValue("test") .build(); assertEquals(stringCol1, stringCol2);
public static ColumnSchema pbToColumnSchema(Common.ColumnSchemaPB pb) { Type type = Type.getTypeForDataType(pb.getType()); ColumnTypeAttributes typeAttributes = pb.hasTypeAttributes() ? pbToColumnTypeAttributes(pb.getTypeAttributes()) : null; Object defaultValue = pb.hasWriteDefaultValue() ? byteStringToObject(type, typeAttributes, pb.getWriteDefaultValue()) : null; ColumnSchema.Encoding encoding = ColumnSchema.Encoding.valueOf(pb.getEncoding().name()); ColumnSchema.CompressionAlgorithm compressionAlgorithm = ColumnSchema.CompressionAlgorithm.valueOf(pb.getCompression().name()); int desiredBlockSize = pb.getCfileBlockSize(); return new ColumnSchema.ColumnSchemaBuilder(pb.getName(), type) .key(pb.getIsKey()) .nullable(pb.getIsNullable()) .defaultValue(defaultValue) .encoding(encoding) .compressionAlgorithm(compressionAlgorithm) .desiredBlockSize(desiredBlockSize) .typeAttributes(typeAttributes) .build(); }
/** * Add a new column that's nullable. * @param name name of the new column * @param type type of the new column * @param defaultVal the default value of the new column * @return this instance */ public AlterTableOptions addNullableColumn(String name, Type type, Object defaultVal) { return addColumn(new ColumnSchema.ColumnSchemaBuilder(name, type) .nullable(true) .defaultValue(defaultVal) .build()); }
/** * Add a new column that's not nullable. * @param name name of the new column * @param type type of the new column * @param defaultVal default value used for the currently existing rows * @return this instance */ public AlterTableOptions addColumn(String name, Type type, Object defaultVal) { return addColumn(new ColumnSchema.ColumnSchemaBuilder(name, type) .defaultValue(defaultVal) .build()); }
protected ColumnSchema columnSchema() { return new ColumnSchema.ColumnSchemaBuilder(name, type) .key(key) .nullable(nullable) .defaultValue(defaultValue) .desiredBlockSize(blockSize) .encoding(encoding.encode) .compressionAlgorithm(compression.algorithm) .build(); }