twdsilva commented on a change in pull request #428: PHOENIX-374: Enable access
to dynamic columns in * or cf.* selection
URL: https://github.com/apache/phoenix/pull/428#discussion_r253674244
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java
##########
@@ -76,6 +97,87 @@ public static void serializeIntoScan(Scan scan, int
thresholdBytes, int limit, L
}
}
+ @Override
+ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
+ MiniBatchOperationInProgress<Mutation> miniBatchOp) throws
IOException {
+ try {
+ preBatchMutateWithExceptions(miniBatchOp);
+ } catch(Throwable t) {
+ // Wrap all exceptions in an IOException to prevent region server
crashes
+ throw ServerUtil.createIOException("Unable to Put cells
corresponding to dynamic" +
+ "column metadata for " +
+
c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString(), t);
+ }
+ }
+
+ /**
+ * In case we are supporting exposing dynamic columns for wildcard
queries, which is based on
+ * the client-side config
+ * {@link
org.apache.phoenix.query.QueryServices#WILDCARD_QUERY_DYNAMIC_COLS_ATTRIB},
+ * we previously set attributes on the Put mutations where the key is the
column family and
+ * the value is the serialized list of dynamic columns.
+ * Here we iterate over all Put mutations and add metadata for the list of
dynamic columns for
+ * each column family in its own cell under reserved qualifiers. See
PHOENIX-374
+ * @param miniBatchOp batch of mutations getting applied to region
+ * @throws IOException If an I/O error occurs when parsing protobuf
+ */
+ private void
preBatchMutateWithExceptions(MiniBatchOperationInProgress<Mutation> miniBatchOp)
+ throws IOException {
+ for (int i = 0; i < miniBatchOp.size(); i++) {
+ Mutation m = miniBatchOp.getOperation(i);
+ // There is at max 1 extra Put (for dynamic column shadow cells)
per original Put
+ Put dynColShadowCellsPut = null;
+ if (m instanceof Put && !Bytes.equals(m.getAttribute(
Review comment:
Older clients won't have this attribute set on the mutation and it will
enter this loop, IMO its better to invert this flag.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services