Example usage for org.apache.cassandra.db.rows Row getCell

List of usage examples for org.apache.cassandra.db.rows Row getCell

Introduction

In this page you can find the example usage for org.apache.cassandra.db.rows Row getCell.

Prototype

public Cell getCell(ColumnMetadata c);

Source Link

Document

Returns a cell for a simple column.

Usage

From source file:com.stratio.cassandra.lucene.column.ColumnsMapper.java

License:Apache License

/**
 * Adds to the specified {@link Column} to the {@link Column}s contained in the specified {@link Row}.
 *
 * @param columns The {@link Columns} in which the {@link Column}s are going to be added.
 * @param row A {@link Row}./*w w w. j a  v  a 2 s.c o m*/
 */
public void addColumns(Columns columns, Row row) {

    for (ColumnDefinition columnDefinition : row.columns()) {
        if (columnDefinition.isComplex()) {
            addColumns(columns, row.getComplexColumnData(columnDefinition));
        } else {
            addColumns(columns, row.getCell(columnDefinition));
        }
    }
}

From source file:io.puntanegra.fhir.index.FhirIndexService.java

License:Apache License

/**
 * Creates a Lucene {@link Document} to index a FHIR {@link IBaseResource}.
 * //from  w ww .ja va  2 s. c om
 * @param key,
 *            the key of the row inserted.
 * @param row,
 *            the row inserted.
 * @return the Lucene {@link Document} to be inserted in the index.
 */
public Optional<Document> document(DecoratedKey key, Row row) {
    Document document = new Document();

    Cell cell = row.getCell(this.indexOptions.targetColumn);
    ByteBuffer value = cell.value();
    if (cell != null && !ByteBufferUtils.isEmpty(value)) {
        String json = ByteBufferUtils.toString(value, UTF8Type.instance);
        fhirMapper.addFields(document, json);
    }

    if (document.getFields().isEmpty()) {
        return Optional.empty();
    } else {
        Clustering clustering = row.clustering();
        tokenMapper.addFields(document, key);
        partitionMapper.addFields(document, key);
        keyMapper.addFields(document, key, clustering);
        return Optional.of(document);
    }
}