List of usage examples for org.apache.cassandra.db.rows Row clustering
@Override
public Clustering clustering();
From source file:com.stratio.cassandra.lucene.IndexServiceWide.java
License:Apache License
/** {@inheritDoc} */ @Override//from ww w. j av a2 s. co m public Columns columns(DecoratedKey key, Row row) { Clustering clustering = row.clustering(); Columns columns = new Columns(); partitionMapper.addColumns(columns, key); keyMapper.addColumns(columns, clustering); columnsMapper.addColumns(columns, row); return columns; }
From source file:com.stratio.cassandra.lucene.IndexServiceWide.java
License:Apache License
/** {@inheritDoc} */ @Override/*from w w w .ja v a2 s . c o m*/ public Optional<Document> document(DecoratedKey key, Row row) { Document document = new Document(); Columns columns = columns(key, row); schema.addFields(document, columns); 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); } }
From source file:com.stratio.cassandra.lucene.IndexServiceWide.java
License:Apache License
/** {@inheritDoc} */ @Override public Term term(DecoratedKey key, Row row) { return term(key, row.clustering()); }
From source file:com.stratio.cassandra.lucene.IndexWriterWide.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w . ja va2 s .c o m protected void index(Row row) { if (!row.isStatic()) { Clustering clustering = row.clustering(); if (service.needsReadBeforeWrite(key, row)) { rowsToRead.add(clustering); rows.put(clustering, Optional.empty()); } else { rows.put(clustering, Optional.of(row)); } } }
From source file:com.stratio.cassandra.lucene.IndexWriterWide.java
License:Apache License
/** {@inheritDoc} */ @Override//from w ww. j a va 2 s . co m public void finish() { // Read required rows from storage engine service.read(key, rowsToRead, nowInSec, opGroup).forEachRemaining(unfiltered -> { Row row = (Row) unfiltered; rows.put(row.clustering(), Optional.of(row)); }); // Write rows rows.forEach((clustering, optional) -> optional.ifPresent(row -> { if (row.hasLiveData(nowInSec)) { service.upsert(key, row); } else { service.delete(key, row); } })); }
From source file:io.puntanegra.fhir.index.FhirIndexIndexer.java
License:Apache License
/** * Temporally store the row to be indexed in a map. * * @param row/* w w w .j a v a2s .c o m*/ * the row to be indexed. */ public void index(Row row) { if (!row.isStatic()) { Clustering clustering = row.clustering(); if (service.needsReadBeforeWrite(key, row)) { rows.put(clustering, Optional.empty()); } else { rows.put(clustering, Optional.of(row)); } } }
From source file:io.puntanegra.fhir.index.FhirIndexIndexer.java
License:Apache License
public void finish() { // Read required rows from storage engine service.read(key, nowInSec, opGroup).forEachRemaining(unfiltered -> { Row row = (Row) unfiltered; rows.put(row.clustering(), Optional.of(row)); });/* w ww .j a va 2 s. c o m*/ // Write rows to Lucene index rows.forEach((clustering, optional) -> optional.ifPresent(row -> { if (row.hasLiveData(nowInSec)) { service.upsert(key, row); } else { service.delete(key, row); } })); }
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 w w . j av a2 s . c o m * @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); } }
From source file:io.puntanegra.fhir.index.FhirIndexService.java
License:Apache License
private Term term(DecoratedKey key, Row row) { return term(key, row.clustering()); }