keith-turner commented on code in PR #4852:
URL: https://github.com/apache/accumulo/pull/4852#discussion_r1746185086
##########
server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java:
##########
@@ -395,4 +266,178 @@ public String getViolationDescription(short
violationCode) {
return null;
}
+ private void validateColValLen(ArrayList<Short> violations, ColumnUpdate
columnUpdate) {
+ Text columnFamily = new Text(columnUpdate.getColumnFamily());
+ if (columnUpdate.getValue().length == 0 &&
!(columnFamily.equals(ScanFileColumnFamily.NAME)
+ || columnFamily.equals(LogColumnFamily.NAME))) {
+ addViolation(violations, 6);
+ }
+ }
+
+ private void validateTabletRow(ArrayList<Short> violations, byte[] row) {
+ // check the row, it should contain at least one ";" or end with "<". Row
should also
+ // not be less than AccumuloTable.METADATA.tableId().
+ boolean containsSemiC = false;
+
+ for (byte b : row) {
+ if (b == ';') {
+ containsSemiC = true;
+ }
+
+ if (b == ';' || b == '<') {
+ break;
+ }
+
+ if (!validTableNameChars[0xff & b]) {
+ addIfNotPresent(violations, 4);
+ }
+ }
+
+ if (!containsSemiC) {
+ // see if last row char is <
+ if (row.length == 0 || row[row.length - 1] != '<') {
+ addIfNotPresent(violations, 4);
+ }
+ }
+
+ if (row.length > 0 && row[0] == '!') {
+ if (row.length < 3 || row[1] != '0' || (row[2] != '<' && row[2] != ';'))
{
+ addIfNotPresent(violations, 4);
+ }
+ }
+
+ // ensure row is not less than AccumuloTable.METADATA.tableId()
+ if (new Text(row).compareTo(new
Text(AccumuloTable.METADATA.tableId().canonical())) < 0) {
+ addViolation(violations, 5);
+ }
Review Comment:
Noticed this could be done w/ Arrays.compare if we precompute the metadata
table id as a `byte[]` which would avoid allocating two text objs to do this
comparison. Could be a follow on PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]