Refine search
@Override public void collect(int docNumber) throws IOException { deleteLucandraDocument(indexName, docNumber, autoCommit); numRemoved.incrementAndGet(); //delete the id reference rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, ByteBufferUtil.bytes(Integer.toString(docNumber))), System.currentTimeMillis()-1); }
@Override public BigInteger compose(ByteBuffer bytes) { return new BigInteger(ByteBufferUtil.getArray(bytes)); }
public ColumnIdentifier getIdentifier(CFMetaData cfm) { if (!cfm.isStaticCompactTable()) return ColumnIdentifier.getInterned(text, true); AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType(); if (thriftColumnNameType instanceof UTF8Type) return ColumnIdentifier.getInterned(text, true); // We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use // thriftColumnNameType ByteBuffer bufferName = ByteBufferUtil.bytes(text); for (ColumnDefinition def : cfm.allColumns()) { if (def.name.bytes.equals(bufferName)) return def.name; } return ColumnIdentifier.getInterned(thriftColumnNameType, thriftColumnNameType.fromString(text), text); }
public static String readSchemaXML(String indexName) throws IOException { ByteBuffer schema = readCoreResource(indexName, CassandraUtils.schemaKey); //Schema resource not found for the core if (schema == null) { throw new IOException(String.format("invalid core '%s'", indexName)); } return ByteBufferUtil.string(schema); }
public List<String> getSSTablesForKey(String key, boolean hexFormat) { ByteBuffer keyBuffer = hexFormat ? ByteBufferUtil.hexToBytes(key) : metadata.getKeyValidator().fromString(key); DecoratedKey dk = decorateKey(keyBuffer); try (OpOrder.Group op = readOrdering.start()) { List<String> files = new ArrayList<>(); for (SSTableReader sstr : select(View.select(SSTableSet.LIVE, dk)).sstables) { // check if the key actually exists in this sstable, without updating cache and stats if (sstr.getPosition(dk, SSTableReader.Operator.EQ, false) != null) files.add(sstr.getFilename()); } return files; } }
public String deserialize(ByteBuffer bytes) { try { return ByteBufferUtil.string(bytes, charset); } catch (CharacterCodingException e) { throw new MarshalException("Invalid " + charset + " bytes " + ByteBufferUtil.bytesToHex(bytes)); } }
public ColumnIdentifier prepare(CFMetaData cfm) { AbstractType<?> comparator = cfm.comparator.asAbstractType(); if (cfm.getIsDense() || comparator instanceof CompositeType || comparator instanceof UTF8Type) return new ColumnIdentifier(text, true); // We have a Thrift-created table with a non-text comparator. We need to parse column names with the comparator // to get the correct ByteBuffer representation. However, this doesn't apply to key aliases, so we need to // make a special check for those and treat them normally. See CASSANDRA-8178. ByteBuffer bufferName = ByteBufferUtil.bytes(text); for (ColumnDefinition def : cfm.partitionKeyColumns()) { if (def.name.bytes.equals(bufferName)) return new ColumnIdentifier(text, true); } return new ColumnIdentifier(comparator.fromString(rawText), text); }
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException { assert parameters.size() == 1 : "Expected 1 argument for toJson(), but got " + parameters.size(); ByteBuffer parameter = parameters.get(0); if (parameter == null) return ByteBufferUtil.bytes("null"); return ByteBufferUtil.bytes(argTypes.get(0).toJSONString(parameter, protocolVersion)); } }
Assert.assertEquals("keyspace_name", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(0).getName()))); Assert.assertEquals(keyspaceName, ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(0).getValue()))); Assert.assertEquals("durable_writes", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(1).getName()))); Assert.assertEquals(false, Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(1).getValue())))); Assert.assertEquals("replication", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(2).getName()))); Assert.assertEquals("comment", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getName()))); Assert.assertTrue(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getValue())).isEmpty()); Assert.assertEquals("comparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getName()))); Assert.assertEquals(UTF8Type.class.getName(), ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getValue()))); Assert.assertEquals("default_validator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getName()))); Assert.assertEquals(BytesType.class.getName(), Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getValue())))); Assert.assertEquals("max_compaction_threshold", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(17).getName()))); Assert.assertEquals(16, ByteBufferUtil.toInt(ByteBuffer.wrap(cqlRow.getColumns().get(17).getValue()))); Assert.assertEquals("min_compaction_threshold", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(18).getName()))); Assert.assertEquals(64, ByteBufferUtil.toInt(ByteBuffer.wrap(cqlRow.getColumns().get(18).getValue()))); Assert.assertEquals("replicate_on_write", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(21).getName()))); Assert.assertEquals("true", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(21).getValue()))); Assert.assertEquals("subcomparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(22).getName()))); Assert.assertNull(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(22).getValue()))); Assert.assertEquals("type", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(23).getName()))); Assert.assertEquals("Standard", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(23).getValue()))); Assert.assertEquals("comment", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getName()))); Assert.assertTrue(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(5).getValue())).isEmpty()); Assert.assertEquals("comparator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getName()))); Assert.assertEquals(UTF8Type.class.getName(), ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(8).getValue()))); Assert.assertEquals("default_validator", ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getName()))); Assert.assertEquals(BytesType.class.getName(), Boolean.getBoolean(ByteBufferUtil.string(ByteBuffer.wrap(cqlRow.getColumns().get(10).getValue()))));
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException { ByteBuffer bb = parameters.get(0); if (bb == null) return ByteBufferUtil.bytes("null"); return ByteBufferUtil.bytes(argTypes.get(0).getSerializer().deserialize(bb).toString()); }
public void validateCollectionMember(ByteBuffer bytes, ByteBuffer collectionName) throws MarshalException { CollectionType t = defined.get(collectionName); if (t == null) throw new MarshalException(ByteBufferUtil.bytesToHex(collectionName) + " is not defined as a collection"); t.nameComparator().validate(bytes); }
private ColumnDefinition addDefaultValueAlias(ColumnDefinition compactValueDef) { if (comparator.isDense()) { if (compactValueDef != null) return compactValueDef; ColumnDefinition newDef = ColumnDefinition.compactValueDef(this, ByteBufferUtil.bytes(DEFAULT_VALUE_ALIAS), defaultValidator); addOrReplaceColumnDefinition(newDef); return newDef; } else { assert compactValueDef == null; return null; } }
/** * Decompose. * * @param value * the value * @param clazz * the clazz * @return the object */ private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return ByteBufferUtil.bytesToHex(buf); } }
public int compareCollectionMembers(ByteBuffer o1, ByteBuffer o2, ByteBuffer collectionName) { CollectionType t = defined.get(collectionName); if (t == null) throw new RuntimeException(ByteBufferUtil.bytesToHex(collectionName) + " is not defined as a collection"); return t.nameComparator().compare(o1, o2); }
/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return ByteBufferUtil.hexToBytes((String) value).array(); }
private static Object toJsonValue(Object o) { if (o instanceof UUID) return o.toString(); if (o instanceof Date) return ((Date)o).getTime(); if (o instanceof ByteBuffer) { // encode byte[] as Base64 encoded string ByteBuffer bb = ByteBufferUtil.clone((ByteBuffer)o); return Base64.getEncoder().encodeToString(ByteBufferUtil.getArray((ByteBuffer)o)); } if (o instanceof InetAddress) return InetAddresses.toAddrString((InetAddress)o); return o; }
/** * Decompose. * * @param value * the value * @param clazz * the clazz * @return the object */ private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return ByteBufferUtil.toLong(buf); } }
/** * Decompose. * * @param value * the value * @param clazz * the clazz * @return the object */ private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); return ByteBufferUtil.toFloat(buf); } }
@Override public ByteBuffer getValue(Cell element) { return org.apache.cassandra.utils.ByteBufferUtil.clone(element.value()); }