Search in sources :

Example 1 with Mergeable

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)));
    }
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Example 2 with Mergeable

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);
            }
        }
    }
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) IOException(java.io.IOException) Cell(org.apache.hadoop.hbase.Cell) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 3 with Mergeable

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());
    }
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) KeyValue(org.apache.hadoop.hbase.KeyValue) Cell(org.apache.hadoop.hbase.Cell)

Example 4 with Mergeable

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);
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) GeoWaveRowImpl(org.locationtech.geowave.core.store.entities.GeoWaveRowImpl) GeoWaveValueImpl(org.locationtech.geowave.core.store.entities.GeoWaveValueImpl) GeoWaveKeyImpl(org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl) ByteArray(org.locationtech.geowave.core.index.ByteArray) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue)

Example 5 with Mergeable

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;
}
Also used : Mergeable(org.locationtech.geowave.core.index.Mergeable) Value(org.apache.accumulo.core.data.Value)

Aggregations

Mergeable (org.locationtech.geowave.core.index.Mergeable)5 Value (org.apache.accumulo.core.data.Value)2 Cell (org.apache.hadoop.hbase.Cell)2 IOException (java.io.IOException)1 Key (org.apache.accumulo.core.data.Key)1 PartialKey (org.apache.accumulo.core.data.PartialKey)1 KeyValue (org.apache.hadoop.hbase.KeyValue)1 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)1 Text (org.apache.hadoop.io.Text)1 ByteArray (org.locationtech.geowave.core.index.ByteArray)1 GeoWaveKeyImpl (org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)1 GeoWaveRowImpl (org.locationtech.geowave.core.store.entities.GeoWaveRowImpl)1 GeoWaveValue (org.locationtech.geowave.core.store.entities.GeoWaveValue)1 GeoWaveValueImpl (org.locationtech.geowave.core.store.entities.GeoWaveValueImpl)1