@@ -512,7 +512,7 @@ public Result get(final Get get) throws IOException {
512
512
if (get .getFamilyMap ().keySet () == null || get .getFamilyMap ().keySet ().isEmpty ()) {
513
513
// check nothing, use table group;
514
514
} else {
515
- checkFamilyViolation (get .getFamilyMap ().keySet ());
515
+ checkFamilyViolation (get .getFamilyMap ().keySet (), false );
516
516
}
517
517
518
518
ServerCallable <Result > serverCallable = new ServerCallable <Result >(configuration ,
@@ -590,7 +590,7 @@ public ResultScanner getScanner(final Scan scan) throws IOException {
590
590
if (scan .getFamilyMap ().keySet ().isEmpty ()) {
591
591
// check nothing, use table group;
592
592
} else {
593
- checkFamilyViolation (scan .getFamilyMap ().keySet ());
593
+ checkFamilyViolation (scan .getFamilyMap ().keySet (), false );
594
594
}
595
595
596
596
//be careful about the packet size ,may the packet exceed the max result size ,leading to error
@@ -681,7 +681,7 @@ private void doPut(List<Put> puts) throws IOException {
681
681
int n = 0 ;
682
682
for (Put put : puts ) {
683
683
validatePut (put );
684
- checkFamilyViolation (put .getFamilyMap ().keySet ());
684
+ checkFamilyViolation (put .getFamilyMap ().keySet (), true );
685
685
writeBuffer .add (put );
686
686
currentWriteBufferSize += put .heapSize ();
687
687
@@ -778,7 +778,7 @@ private void innerDelete(Delete delete) throws IOException {
778
778
BatchOperationResult results = null ;
779
779
780
780
try {
781
- checkFamilyViolation (delete .getFamilyMap ().keySet ());
781
+ checkFamilyViolation (delete .getFamilyMap ().keySet (), false );
782
782
if (delete .getFamilyMap ().isEmpty ()) {
783
783
// For a Delete operation without any qualifiers, we construct a DeleteFamily request.
784
784
// The server then performs the operation on all column families.
@@ -801,7 +801,7 @@ private void innerDelete(Delete delete) throws IOException {
801
801
} else {
802
802
for (Map .Entry <byte [], List <KeyValue >> entry : delete .getFamilyMap ().entrySet ()) {
803
803
BatchOperation batch = buildBatchOperation (
804
- getTargetTableName (tableNameString , Bytes .toString (entry .getKey ())),
804
+ getTargetTableName (tableNameString , Bytes .toString (entry .getKey ()), configuration ),
805
805
entry .getValue (), false , null );
806
806
results = batch .execute ();
807
807
}
@@ -830,7 +830,7 @@ private void innerDelete(Delete delete) throws IOException {
830
830
831
831
@ Override
832
832
public void delete (Delete delete ) throws IOException {
833
- checkFamilyViolation (delete .getFamilyMap ().keySet ());
833
+ checkFamilyViolation (delete .getFamilyMap ().keySet (), false );
834
834
innerDelete (delete );
835
835
}
836
836
@@ -1419,7 +1419,7 @@ private ObHTableFilter buildObHTableFilter(Filter filter, TimeRange timeRange, i
1419
1419
ObHTableFilter obHTableFilter = new ObHTableFilter ();
1420
1420
1421
1421
if (filter != null ) {
1422
- obHTableFilter .setFilterString (HBaseFilterUtils .toParseableString (filter ). getBytes () );
1422
+ obHTableFilter .setFilterString (HBaseFilterUtils .toParseableString (filter ));
1423
1423
}
1424
1424
1425
1425
if (timeRange != null ) {
@@ -1459,7 +1459,7 @@ private ObHTableFilter buildObHTableFilter(String filterString, TimeRange timeRa
1459
1459
ObHTableFilter obHTableFilter = new ObHTableFilter ();
1460
1460
1461
1461
if (filterString != null ) {
1462
- obHTableFilter .setFilterString (filterString . getBytes () );
1462
+ obHTableFilter .setFilterString (filterString );
1463
1463
}
1464
1464
1465
1465
if (timeRange != null ) {
@@ -1753,9 +1753,15 @@ private ObTableQueryAndMutateRequest buildObTableQueryAndMutateRequest(ObTableQu
1753
1753
return request ;
1754
1754
}
1755
1755
1756
- public static void checkFamilyViolation (Collection <byte []> families ) {
1756
+ public static void checkFamilyViolation (Collection <byte []> families , boolean check_empty_family ) {
1757
+ if (check_empty_family && (families == null || families .isEmpty ())) {
1758
+ throw new FeatureNotSupportedException ("family is empty" );
1759
+ }
1760
+
1757
1761
for (byte [] family : families ) {
1758
- if (isBlank (Bytes .toString (family ))) {
1762
+ if (family == null || family .length == 0 ) {
1763
+ throw new IllegalArgumentException ("family is empty" );
1764
+ } else if (isBlank (Bytes .toString (family ))) {
1759
1765
throw new IllegalArgumentException ("family is blank" );
1760
1766
}
1761
1767
}
@@ -1765,7 +1771,7 @@ public static void checkFamilyViolation(Collection<byte[]> families) {
1765
1771
// This method is currently only used for append and increment operations.
1766
1772
// It restricts these two methods to use multi-column family operations.
1767
1773
// Note: After completing operations on multiple column families, they are deleted using the method described above.
1768
- private void checkFamilyViolationForOneFamily (Collection <byte []> families ) {
1774
+ public static void checkFamilyViolationForOneFamily (Collection <byte []> families ) {
1769
1775
if (families == null || families .size () == 0 ) {
1770
1776
throw new FeatureNotSupportedException ("family is empty." );
1771
1777
}
@@ -1774,7 +1780,9 @@ private void checkFamilyViolationForOneFamily(Collection<byte[]> families) {
1774
1780
throw new FeatureNotSupportedException ("multi family is not supported yet." );
1775
1781
}
1776
1782
for (byte [] family : families ) {
1777
- if (isBlank (Bytes .toString (family ))) {
1783
+ if (family == null || family .length == 0 ) {
1784
+ throw new IllegalArgumentException ("family is empty" );
1785
+ } else if (isBlank (Bytes .toString (family ))) {
1778
1786
throw new IllegalArgumentException ("family is blank" );
1779
1787
}
1780
1788
}
0 commit comments