@@ -80,11 +80,14 @@ public class Tablet {
8080 /** MeasurementId->indexOf({@link MeasurementSchema}) */
8181 private final Map <String , Integer > measurementIndex ;
8282
83- private long [] timestamps ;
83+ /** Timestamps in this {@link Tablet} */
84+ public long [] timestamps ;
8485
85- private Object [] values ;
86+ /** Each object is a primitive type array, which represents values of one measurement */
87+ public Object [] values ;
8688
87- private BitMap [] bitMaps ;
89+ /** Each {@link BitMap} represents the existence of each value in the current column. */
90+ public BitMap [] bitMaps ;
8891
8992 /**
9093 * For compatibility with the usage of directly modifying Tablet content through public fields.
@@ -289,7 +292,6 @@ public void initBitMaps() {
289292 public void addTimestamp (int rowIndex , long timestamp ) {
290293 timestamps [rowIndex ] = timestamp ;
291294 this .rowSize = Math .max (this .rowSize , rowIndex + 1 );
292- initBitMapsWithApiUsage ();
293295 }
294296
295297 public void addValue (final String measurementId , final int rowIndex , final Object value ) {
@@ -411,10 +413,6 @@ public void addValue(int rowIndex, String measurement, int val) {
411413
412414 @ TsFileApi
413415 public void addValue (int rowIndex , int columnIndex , int val ) {
414- if (!(values [columnIndex ] instanceof int [])) {
415- throw new IllegalArgumentException (
416- "The data type of column index " + columnIndex + " is not INT32" );
417- }
418416 final int [] sensor = (int []) values [columnIndex ];
419417 sensor [rowIndex ] = val ;
420418 updateBitMap (rowIndex , columnIndex , false );
@@ -428,10 +426,6 @@ public void addValue(int rowIndex, String measurement, long val) {
428426
429427 @ TsFileApi
430428 public void addValue (int rowIndex , int columnIndex , long val ) {
431- if (!(values [columnIndex ] instanceof long [])) {
432- throw new IllegalArgumentException (
433- "The data type of column index " + columnIndex + " is not INT64/TIMESTAMP" );
434- }
435429 final long [] sensor = (long []) values [columnIndex ];
436430 sensor [rowIndex ] = val ;
437431 updateBitMap (rowIndex , columnIndex , false );
@@ -445,10 +439,6 @@ public void addValue(int rowIndex, String measurement, float val) {
445439
446440 @ TsFileApi
447441 public void addValue (int rowIndex , int columnIndex , float val ) {
448- if (!(values [columnIndex ] instanceof float [])) {
449- throw new IllegalArgumentException (
450- "The data type of column index " + columnIndex + " is not FLOAT" );
451- }
452442 final float [] sensor = (float []) values [columnIndex ];
453443 sensor [rowIndex ] = val ;
454444 updateBitMap (rowIndex , columnIndex , false );
@@ -462,10 +452,6 @@ public void addValue(int rowIndex, String measurement, double val) {
462452
463453 @ TsFileApi
464454 public void addValue (int rowIndex , int columnIndex , double val ) {
465- if (!(values [columnIndex ] instanceof double [])) {
466- throw new IllegalArgumentException (
467- "The data type of column index " + columnIndex + " is not DOUBLE" );
468- }
469455 final double [] sensor = (double []) values [columnIndex ];
470456 sensor [rowIndex ] = val ;
471457 updateBitMap (rowIndex , columnIndex , false );
@@ -479,10 +465,6 @@ public void addValue(int rowIndex, String measurement, boolean val) {
479465
480466 @ TsFileApi
481467 public void addValue (int rowIndex , int columnIndex , boolean val ) {
482- if (!(values [columnIndex ] instanceof boolean [])) {
483- throw new IllegalArgumentException (
484- "The data type of column index " + columnIndex + " is not BOOLEAN" );
485- }
486468 final boolean [] sensor = (boolean []) values [columnIndex ];
487469 sensor [rowIndex ] = val ;
488470 updateBitMap (rowIndex , columnIndex , false );
@@ -496,10 +478,6 @@ public void addValue(int rowIndex, String measurement, String val) {
496478
497479 @ TsFileApi
498480 public void addValue (int rowIndex , int columnIndex , String val ) {
499- if (!(values [columnIndex ] instanceof Binary [])) {
500- throw new IllegalArgumentException (
501- "The data type of column index " + columnIndex + " is not TEXT/STRING/BLOB" );
502- }
503481 final Binary [] sensor = (Binary []) values [columnIndex ];
504482 sensor [rowIndex ] = new Binary (val , TSFileConfig .STRING_CHARSET );
505483 updateBitMap (rowIndex , columnIndex , false );
@@ -513,10 +491,6 @@ public void addValue(int rowIndex, String measurement, byte[] val) {
513491
514492 @ TsFileApi
515493 public void addValue (int rowIndex , int columnIndex , byte [] val ) {
516- if (!(values [columnIndex ] instanceof Binary [])) {
517- throw new IllegalArgumentException (
518- "The data type of column index " + columnIndex + " is not TEXT/STRING/BLOB" );
519- }
520494 final Binary [] sensor = (Binary []) values [columnIndex ];
521495 sensor [rowIndex ] = new Binary (val );
522496 updateBitMap (rowIndex , columnIndex , false );
@@ -530,10 +504,6 @@ public void addValue(int rowIndex, String measurement, LocalDate val) {
530504
531505 @ TsFileApi
532506 public void addValue (int rowIndex , int columnIndex , LocalDate val ) {
533- if (!(values [columnIndex ] instanceof LocalDate [])) {
534- throw new IllegalArgumentException (
535- "The data type of column index " + columnIndex + " is not DATE" );
536- }
537507 final LocalDate [] sensor = (LocalDate []) values [columnIndex ];
538508 sensor [rowIndex ] = val ;
539509 updateBitMap (rowIndex , columnIndex , false );
@@ -551,15 +521,6 @@ private int getColumnIndexByMeasurement(String measurement) {
551521 }
552522
553523 private void updateBitMap (int rowIndex , int columnIndex , boolean mark ) {
554- initBitMapsWithApiUsage ();
555- if (mark ) {
556- bitMaps [columnIndex ].mark (rowIndex );
557- } else {
558- bitMaps [columnIndex ].unmark (rowIndex );
559- }
560- }
561-
562- private void initBitMapsWithApiUsage () {
563524 if (bitMaps == null ) {
564525 initBitMaps ();
565526 }
@@ -569,6 +530,11 @@ private void initBitMapsWithApiUsage() {
569530 bitMap .markAll ();
570531 }
571532 }
533+ if (mark ) {
534+ bitMaps [columnIndex ].mark (rowIndex );
535+ } else {
536+ bitMaps [columnIndex ].unmark (rowIndex );
537+ }
572538 }
573539
574540 public List <IMeasurementSchema > getSchemas () {
@@ -1229,34 +1195,6 @@ public void setRowSize(int rowSize) {
12291195 this .rowSize = rowSize ;
12301196 }
12311197
1232- public long getTimestamp (int i ) {
1233- return timestamps [i ];
1234- }
1235-
1236- public long [] getTimestamps () {
1237- return timestamps ;
1238- }
1239-
1240- public void setTimestamps (long [] timestamps ) {
1241- this .timestamps = timestamps ;
1242- }
1243-
1244- public Object [] getValues () {
1245- return values ;
1246- }
1247-
1248- public void setValues (Object [] values ) {
1249- this .values = values ;
1250- }
1251-
1252- public BitMap [] getBitMaps () {
1253- return bitMaps ;
1254- }
1255-
1256- public void setBitMaps (BitMap [] bitMaps ) {
1257- this .bitMaps = bitMaps ;
1258- }
1259-
12601198 public enum ColumnCategory {
12611199 TAG ,
12621200 FIELD ,
@@ -1309,13 +1247,4 @@ public void setTableName(String tableName) {
13091247 public List <ColumnCategory > getColumnTypes () {
13101248 return columnCategories ;
13111249 }
1312-
1313- public boolean isSorted () {
1314- for (int i = 1 ; i < rowSize ; i ++) {
1315- if (timestamps [i ] < timestamps [i - 1 ]) {
1316- return false ;
1317- }
1318- }
1319- return true ;
1320- }
13211250}
0 commit comments