List of usage examples for org.apache.cassandra.db.marshal AsciiType instance
AsciiType instance
To view the source code for org.apache.cassandra.db.marshal AsciiType instance.
Click Source Link
From source file:clojurewerkz.cassaforte.Codec.java
License:Apache License
private static AbstractType getCodecInternal(DataType type) { switch (type.getName()) { case ASCII://from www. ja v a2 s . c o m return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); default: throw new RuntimeException("Unknown type"); } }
From source file:com.chaordicsystems.sstableconverter.SSTableConverter.java
License:Apache License
public static void main(String[] args) throws Exception { LoaderOptions options = LoaderOptions.parseArgs(args); OutputHandler handler = new OutputHandler.SystemOutput(options.verbose, options.debug); File srcDir = options.sourceDir; File dstDir = options.destDir; IPartitioner srcPart = options.srcPartitioner; IPartitioner dstPart = options.dstPartitioner; String keyspace = options.ks; String cf = options.cf;/*from w ww .ja v a 2 s . c om*/ if (keyspace == null) { keyspace = srcDir.getParentFile().getName(); } if (cf == null) { cf = srcDir.getName(); } CFMetaData metadata = new CFMetaData(keyspace, cf, ColumnFamilyType.Standard, BytesType.instance, null); Collection<SSTableReader> originalSstables = readSSTables(srcPart, srcDir, metadata, handler); handler.output( String.format("Converting sstables of ks[%s], cf[%s], from %s to %s. Src dir: %s. Dest dir: %s.", keyspace, cf, srcPart.getClass().getName(), dstPart.getClass().getName(), srcDir.getAbsolutePath(), dstDir.getAbsolutePath())); SSTableSimpleUnsortedWriter destWriter = new SSTableSimpleUnsortedWriter(dstDir, dstPart, keyspace, cf, AsciiType.instance, null, 64); for (SSTableReader reader : originalSstables) { handler.output("Reading: " + reader.getFilename()); SSTableIdentityIterator row; SSTableScanner scanner = reader.getDirectScanner(null); // collecting keys to export while (scanner.hasNext()) { row = (SSTableIdentityIterator) scanner.next(); destWriter.newRow(row.getKey().key); while (row.hasNext()) { IColumn col = (IColumn) row.next(); destWriter.addColumn(col.name(), col.value(), col.timestamp()); } } scanner.close(); } // Don't forget to close! destWriter.close(); System.exit(0); }
From source file:com.datastax.driver.core.ArrayBackedRow.java
License:Apache License
public String getString(int i) { DataType.Name type = metadata.checkType(i, DataType.Name.VARCHAR, DataType.Name.TEXT, DataType.Name.ASCII); ByteBuffer value = data.get(i); if (value == null) return null; return type == DataType.Name.ASCII ? AsciiType.instance.compose(value) : UTF8Type.instance.compose(value); }
From source file:com.datastax.driver.core.BoundStatement.java
License:Apache License
/** * Sets the {@code i}th value to the provided string. * * @param i the index of the variable to set. * @param v the value to set./*from ww w . j a va2 s .c om*/ * @return this BoundStatement. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.preparedStatement().variables().size()}. * @throws InvalidTypeException if column {@code i} is of neither of the * following types: VARCHAR, TEXT or ASCII. */ public BoundStatement setString(int i, String v) { DataType.Name type = metadata().checkType(i, DataType.Name.VARCHAR, DataType.Name.TEXT, DataType.Name.ASCII); switch (type) { case ASCII: return setValue(i, v == null ? null : AsciiType.instance.decompose(v)); case TEXT: case VARCHAR: return setValue(i, v == null ? null : UTF8Type.instance.decompose(v)); default: throw new AssertionError(); } }
From source file:com.datastax.driver.core.Codec.java
License:Apache License
private static AbstractType<?> getCodecInternal(DataType type) { switch (type.getName()) { case ASCII:/*from w w w . j a v a2 s . c o m*/ return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); // We don't interpret custom values in any way case CUSTOM: return BytesType.instance; default: throw new RuntimeException("Unknown type"); } }
From source file:com.datastax.driver.core.Row.java
License:Apache License
/** * Returns the {@code i}th value of this row as a string. * * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. * @return the value of the {@code i}th column in this row as a string. If the * value is NULL, {@code null} is returned. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. * @throws InvalidTypeException if column {@code i} type is none of: * VARCHAR, TEXT or ASCII./* w w w . ja va 2 s .c o m*/ */ public String getString(int i) { DataType.Name type = metadata.checkType(i, DataType.Name.VARCHAR, DataType.Name.TEXT, DataType.Name.ASCII); ByteBuffer value = data.get(i); if (value == null) return null; return type == DataType.Name.ASCII ? AsciiType.instance.compose(value) : UTF8Type.instance.compose(value); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBigDecimal.java
License:Apache License
/** * Builds a new {@link ColumnMapperBigDecimal} using the specified max number of digits for the integer and decimal * parts./*from w w w . j a v a 2 s. c o m*/ * * @param integerDigits The max number of digits for the integer part. If {@code null}, the {@link * #DEFAULT_INTEGER_DIGITS} will be used. * @param decimalDigits The max number of digits for the decimal part. If {@code null}, the {@link * #DEFAULT_DECIMAL_DIGITS} will be used. */ @JsonCreator public ColumnMapperBigDecimal(@JsonProperty("integer_digits") Integer integerDigits, @JsonProperty("decimal_digits") Integer decimalDigits) { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance, FloatType.instance, DoubleType.instance, DecimalType.instance }, new AbstractType[] {}); // Setup integer part mapping if (integerDigits != null && integerDigits <= 0) { throw new IllegalArgumentException("Positive integer part digits required"); } this.integerDigits = integerDigits == null ? DEFAULT_INTEGER_DIGITS : integerDigits; // Setup decimal part mapping if (decimalDigits != null && decimalDigits <= 0) { throw new IllegalArgumentException("Positive decimal part digits required"); } this.decimalDigits = decimalDigits == null ? DEFAULT_DECIMAL_DIGITS : decimalDigits; int totalDigits = this.integerDigits + this.decimalDigits; BigDecimal divisor = BigDecimal.valueOf(10).pow(this.decimalDigits); BigDecimal dividend = BigDecimal.valueOf(10).pow(totalDigits).subtract(BigDecimal.valueOf(1)); complement = dividend.divide(divisor); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBigInteger.java
License:Apache License
/** * Builds a new {@link ColumnMapperBigDecimal} using the specified max number of digits. * * @param digits The max number of digits. If {@code null}, the {@link #DEFAULT_DIGITS} will be used. *//*from w w w .ja va 2 s . com*/ @JsonCreator public ColumnMapperBigInteger(@JsonProperty("digits") Integer digits) { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance }, new AbstractType[] {}); if (digits != null && digits <= 0) { throw new IllegalArgumentException("Positive digits required"); } this.digits = digits == null ? DEFAULT_DIGITS : digits; complement = BigInteger.valueOf(10).pow(this.digits).subtract(BigInteger.valueOf(1)); BigInteger maxValue = complement.multiply(BigInteger.valueOf(2)); hexDigits = encode(maxValue).length(); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBlob.java
License:Apache License
/** * Builds a new {@link ColumnMapperBlob}. *///from ww w . j a v a2s.com @JsonCreator public ColumnMapperBlob() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, BytesType.instance }, new AbstractType[] {}); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBoolean.java
License:Apache License
/** * Builds a new {@link ColumnMapperBlob}. *//* w w w .ja v a 2 s. c o m*/ @JsonCreator public ColumnMapperBoolean() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, BooleanType.instance }, new AbstractType[] {}); }