use of org.locationtech.geowave.core.index.Mergeable in project geowave by locationtech.
the class MergingVisibilityCombiner method transformRangeInternal.
@Override
protected void transformRangeInternal(final SortedKeyValueIterator<Key, Value> input, final KVBuffer output) throws IOException {
Mergeable currentMergeable = null;
Key outputKey = null;
workKey.set(input.getTopKey());
// contain this column
if ((combiners == null) || !combiners.contains(workKey) || workKey.isDeleted()) {
// don't transform at all
while (input.hasTop()) {
output.append(input.getTopKey(), input.getTopValue());
input.next();
}
return;
}
while (input.hasTop()) {
final Value val = input.getTopValue();
// the SortedKeyValueIterator uses the same instance of topKey to
// hold keys (a wrapper)
final Key currentKey = new Key(input.getTopKey());
if (outputKey == null) {
outputKey = currentKey;
} else if ((currentMergeable != null) && !outputKey.getRowData().equals(currentKey.getRowData())) {
output.append(outputKey, new Value(URLClassloaderUtils.toBinary(currentMergeable)));
currentMergeable = null;
outputKey = currentKey;
continue;
} else {
final Text combinedVisibility = new Text(combineVisibilities(currentKey.getColumnVisibility().getBytes(), outputKey.getColumnVisibility().getBytes()));
outputKey = replaceColumnVisibility(outputKey, combinedVisibility);
}
final Mergeable mergeable = getMergeable(currentKey, val.get());
// but just in case, check
if (mergeable != null) {
if (currentMergeable == null) {
currentMergeable = mergeable;
} else {
currentMergeable.merge(mergeable);
}
}
input.next();
}
if (currentMergeable != null) {
output.append(outputKey, new Value(getBinary(currentMergeable)));
}
}
use of org.locationtech.geowave.core.index.Mergeable in project geowave by locationtech.
the class HBaseMergingFilter method filterRowCells.
/**
* Handle the entire row at one time
*/
@Override
public void filterRowCells(final List<Cell> rowCells) throws IOException {
if (!rowCells.isEmpty()) {
if (rowCells.size() > 1) {
try {
final Cell firstCell = rowCells.get(0);
final byte[] singleRow = CellUtil.cloneRow(firstCell);
final byte[] singleFam = CellUtil.cloneFamily(firstCell);
final byte[] singleQual = CellUtil.cloneQualifier(firstCell);
Mergeable mergedValue = null;
for (final Cell cell : rowCells) {
final byte[] byteValue = CellUtil.cloneValue(cell);
final Mergeable value = (Mergeable) URLClassloaderUtils.fromBinary(byteValue);
if (mergedValue != null) {
mergedValue.merge(value);
} else {
mergedValue = value;
}
}
final Cell singleCell = CellUtil.createCell(singleRow, singleFam, singleQual, System.currentTimeMillis(), KeyValue.Type.Put.getCode(), URLClassloaderUtils.toBinary(mergedValue));
rowCells.clear();
rowCells.add(singleCell);
} catch (final Exception e) {
throw new IOException("Exception in filter", e);
}
}
}
}
use of org.locationtech.geowave.core.index.Mergeable in project geowave by locationtech.
the class MergingServerOp method mergeList.
protected Cell mergeList(final List<Cell> cells) {
synchronized (MUTEX) {
Mergeable currentMergeable = null;
final Cell firstCell = cells.get(0);
for (final Cell cell : cells) {
final Mergeable mergeable = getMergeable(cell, // bytebuffer instead of byte[])
CellUtil.cloneValue(cell));
if (mergeable != null) {
if (currentMergeable == null) {
currentMergeable = mergeable;
} else {
currentMergeable.merge(mergeable);
}
}
}
final byte[] valueBinary = getBinary(currentMergeable);
// value
return new KeyValue(firstCell.getRowArray(), firstCell.getRowOffset(), firstCell.getRowLength(), firstCell.getFamilyArray(), firstCell.getFamilyOffset(), firstCell.getFamilyLength(), firstCell.getQualifierArray(), firstCell.getQualifierOffset(), firstCell.getQualifierLength(), firstCell.getTimestamp(), Type.codeToType(firstCell.getTypeByte()), valueBinary, 0, valueBinary.length, firstCell.getTagsArray(), firstCell.getTagsOffset(), firstCell.getTagsLength());
}
}
use of org.locationtech.geowave.core.index.Mergeable in project geowave by locationtech.
the class DataStoreUtils method mergeSingleRowValues.
public static GeoWaveRow mergeSingleRowValues(final GeoWaveRow singleRow, final RowTransform rowTransform) {
if (singleRow.getFieldValues().length < 2) {
return singleRow;
}
// merge all values into a single value
Mergeable merged = null;
for (final GeoWaveValue fieldValue : singleRow.getFieldValues()) {
final Mergeable mergeable = rowTransform.getRowAsMergeableObject(singleRow.getAdapterId(), new ByteArray(fieldValue.getFieldMask()), fieldValue.getValue());
if (merged == null) {
merged = mergeable;
} else {
merged.merge(mergeable);
}
}
final GeoWaveValue[] mergedFieldValues = new GeoWaveValue[] { new GeoWaveValueImpl(singleRow.getFieldValues()[0].getFieldMask(), singleRow.getFieldValues()[0].getVisibility(), rowTransform.getBinaryFromMergedObject(merged)) };
return new GeoWaveRowImpl(new GeoWaveKeyImpl(singleRow.getDataId(), singleRow.getAdapterId(), singleRow.getPartitionKey(), singleRow.getSortKey(), singleRow.getNumberOfDuplicates()), mergedFieldValues);
}
use of org.locationtech.geowave.core.index.Mergeable in project geowave by locationtech.
the class MergingCombiner method reduce.
@Override
public Value reduce(final Key key, final Iterator<Value> iter) {
Mergeable currentMergeable = null;
Value val = null;
while (iter.hasNext()) {
val = iter.next();
// hopefully its never the case that null stastics are stored,
// but just in case, check
final Mergeable mergeable = getMergeable(key, val.get());
if (mergeable != null) {
if (currentMergeable == null) {
currentMergeable = mergeable;
} else {
currentMergeable.merge(mergeable);
}
}
}
if (currentMergeable != null) {
return new Value(getBinary(currentMergeable));
}
return val;
}
Aggregations