/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return BooleanType.instance.decompose((Boolean) value).array(); }
return BooleanType.instance.decompose(Boolean.valueOf(value.toString()));
private static byte[] compose(Object value, Class clazz) { return BooleanType.instance.decompose((Boolean) value).array(); }
public ByteBuffer fromString(String source) throws MarshalException { if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString())) return decompose(false); if (source.equalsIgnoreCase(Boolean.TRUE.toString())) return decompose(true); throw new MarshalException(String.format("Unable to make boolean from '%s'", source)); }
public ByteBuffer fromString(String source) throws MarshalException { if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString())) return decompose(false); if (source.equalsIgnoreCase(Boolean.TRUE.toString())) return decompose(true); throw new MarshalException(String.format("Unable to make boolean from '%s'", source)); }
public ByteBuffer fromString(String source) throws MarshalException { if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString())) return decompose(false); if (source.equalsIgnoreCase(Boolean.TRUE.toString())) return decompose(true); throw new MarshalException(String.format("unable to make boolean from '%s'", source)); }
public ByteBuffer fromString(String source) throws MarshalException { if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString())) return decompose(false); if (source.equalsIgnoreCase(Boolean.TRUE.toString())) return decompose(true); throw new MarshalException(String.format("Unable to make boolean from '%s'", source)); }
public ByteBuffer fromString(String source) throws MarshalException { if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString())) return decompose(false); if (source.equalsIgnoreCase(Boolean.TRUE.toString())) return decompose(true); throw new MarshalException(String.format("Unable to make boolean from '%s'", source)); }
public static ResultSet buildCasResultSet(String ksName, String tableName, RowIterator partition, Iterable<ColumnDefinition> columnsWithConditions, boolean isBatch, QueryOptions options) throws InvalidRequestException { boolean success = partition == null; ColumnSpecification spec = new ColumnSpecification(ksName, tableName, CAS_RESULT_COLUMN, BooleanType.instance); ResultSet.ResultMetadata metadata = new ResultSet.ResultMetadata(Collections.singletonList(spec)); List<List<ByteBuffer>> rows = Collections.singletonList(Collections.singletonList(BooleanType.instance.decompose(success))); ResultSet rs = new ResultSet(metadata, rows); return success ? rs : merge(rs, buildCasFailureResultSet(partition, columnsWithConditions, isBatch, options)); }
public static ResultSet buildCasResultSet(String ksName, String tableName, RowIterator partition, Iterable<ColumnDefinition> columnsWithConditions, boolean isBatch, QueryOptions options) throws InvalidRequestException { boolean success = partition == null; ColumnSpecification spec = new ColumnSpecification(ksName, tableName, CAS_RESULT_COLUMN, BooleanType.instance); ResultSet.ResultMetadata metadata = new ResultSet.ResultMetadata(Collections.singletonList(spec)); List<List<ByteBuffer>> rows = Collections.singletonList(Collections.singletonList(BooleanType.instance.decompose(success))); ResultSet rs = new ResultSet(metadata, rows); return success ? rs : merge(rs, buildCasFailureResultSet(partition, columnsWithConditions, isBatch, options)); }
public static ResultSet buildCasResultSet(String ksName, ByteBuffer key, String cfName, ColumnFamily cf, Iterable<ColumnDefinition> columnsWithConditions, boolean isBatch, QueryOptions options) throws InvalidRequestException { boolean success = cf == null; ColumnSpecification spec = new ColumnSpecification(ksName, cfName, CAS_RESULT_COLUMN, BooleanType.instance); ResultSet.Metadata metadata = new ResultSet.Metadata(Collections.singletonList(spec)); List<List<ByteBuffer>> rows = Collections.singletonList(Collections.singletonList(BooleanType.instance.decompose(success))); ResultSet rs = new ResultSet(metadata, rows); return success ? rs : merge(rs, buildCasFailureResultSet(key, cf, columnsWithConditions, isBatch, options)); }
public static ResultSet buildCasResultSet(String ksName, String tableName, RowIterator partition, Iterable<ColumnDefinition> columnsWithConditions, boolean isBatch, QueryOptions options) throws InvalidRequestException { boolean success = partition == null; ColumnSpecification spec = new ColumnSpecification(ksName, tableName, CAS_RESULT_COLUMN, BooleanType.instance); ResultSet.ResultMetadata metadata = new ResultSet.ResultMetadata(Collections.singletonList(spec)); List<List<ByteBuffer>> rows = Collections.singletonList(Collections.singletonList(BooleanType.instance.decompose(success))); ResultSet rs = new ResultSet(metadata, rows); return success ? rs : merge(rs, buildCasFailureResultSet(partition, columnsWithConditions, isBatch, options)); }
case BOOLEAN: final Boolean boolData = (Boolean) rawData; bb = BooleanType.instance.decompose(boolData); break; case INT:
protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(roleManager.isSuper(role))); result.addColumnValue(BooleanType.instance.decompose(roleManager.canLogin(role))); result.addColumnValue(optionsType.decompose(roleManager.getCustomOptions(role))); } return new ResultMessage.Rows(result); } }
protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(roleManager.isSuper(role))); result.addColumnValue(BooleanType.instance.decompose(roleManager.canLogin(role))); result.addColumnValue(optionsType.decompose(roleManager.getCustomOptions(role))); } return new ResultMessage.Rows(result); } }
protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(roleManager.isSuper(role))); result.addColumnValue(BooleanType.instance.decompose(roleManager.canLogin(role))); result.addColumnValue(optionsType.decompose(roleManager.getCustomOptions(role))); } return new ResultMessage.Rows(result); } }
@Override protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { if (!roleManager.canLogin(role)) continue; result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(Roles.hasSuperuserStatus(role))); } return new ResultMessage.Rows(result); } }
@Override protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { if (!roleManager.canLogin(role)) continue; result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(Roles.hasSuperuserStatus(role))); } return new ResultMessage.Rows(result); } }
public static ByteBuffer defaultValue(AbstractType type, boolean min) { CQL3Type cqlType = type.asCQL3Type(); if (cqlType == CQL3Type.Native.INT || cqlType == CQL3Type.Native.VARINT) { return ByteBufferUtil.bytes(min ? Integer.MIN_VALUE : Integer.MAX_VALUE); } else if (cqlType == CQL3Type.Native.BIGINT) { return ByteBufferUtil.bytes(min ? Long.MIN_VALUE : Long.MAX_VALUE); } else if (cqlType == CQL3Type.Native.DECIMAL || cqlType == CQL3Type.Native.DOUBLE) { return ByteBufferUtil.bytes(min ? Double.MIN_VALUE : Double.MAX_VALUE); } else if (cqlType == CQL3Type.Native.FLOAT) { return ByteBufferUtil.bytes(min ? Float.MIN_VALUE : Float.MAX_VALUE); } else if (cqlType == CQL3Type.Native.TEXT || cqlType == CQL3Type.Native.VARCHAR) { return ByteBufferUtil.bytes(""); } else if (cqlType == CQL3Type.Native.UUID) { return ByteBufferUtil.bytes(UUID.randomUUID()); } else if (cqlType == CQL3Type.Native.TIMEUUID) { return ByteBufferUtil.bytes(UUIDGen.getTimeUUID(0)); } else if (cqlType == CQL3Type.Native.TIMESTAMP) { return ByteBufferUtil.bytes(0L); } else if (cqlType == CQL3Type.Native.BOOLEAN) { return BooleanType.instance.decompose(!min); } else { return ByteBufferUtil.EMPTY_BYTE_BUFFER; } }
@Override protected ResultMessage formatResults(List<RoleResource> sortedRoles) { ResultSet result = new ResultSet(metadata); IRoleManager roleManager = DatabaseDescriptor.getRoleManager(); for (RoleResource role : sortedRoles) { if (!roleManager.canLogin(role)) continue; result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName())); result.addColumnValue(BooleanType.instance.decompose(Roles.hasSuperuserStatus(role))); } return new ResultMessage.Rows(result); } }