@@ -266,6 +266,18 @@ private void ensureCapacity(final int minCapacity) {
266
266
}
267
267
}
268
268
269
+ private void appendTag (long tag ) {
270
+ if (tag <= 255 ) {
271
+ ensureCapacity (1 +1 );
272
+ addUnchecked ((byte ) 0xee );
273
+ append (tag , 1 );
274
+ } else {
275
+ ensureCapacity (1 +8 );
276
+ addUnchecked ((byte ) 0xef );
277
+ append (tag , LONG_BYTES );
278
+ }
279
+ }
280
+
269
281
public VPackBuilder add (final ValueType value ) throws VPackBuilderException {
270
282
return addInternal (VALUE_TYPE , value );
271
283
}
@@ -425,12 +437,180 @@ public VPackBuilder add(final String attribute, final VPackSlice value) throws V
425
437
return addInternal (attribute , VPACK , value );
426
438
}
427
439
440
+ public VPackBuilder addTagged (final long tag , final ValueType value ) throws VPackBuilderException {
441
+ return addInternal (tag , VALUE_TYPE , value );
442
+ }
443
+
444
+ public VPackBuilder addTagged (final long tag , final ValueType value , final boolean unindexed ) throws VPackBuilderException {
445
+ return addInternal (tag , VALUE , new Value (value , unindexed ));
446
+ }
447
+
448
+ public VPackBuilder addTagged (final long tag , final Boolean value ) throws VPackBuilderException {
449
+ return addInternal (tag , BOOLEAN , value );
450
+ }
451
+
452
+ public VPackBuilder addTagged (final long tag , final Double value ) throws VPackBuilderException {
453
+ return addInternal (tag , DOUBLE , value );
454
+ }
455
+
456
+ public VPackBuilder addTagged (final long tag , final Float value ) throws VPackBuilderException {
457
+ return addInternal (tag , FLOAT , value );
458
+ }
459
+
460
+ public VPackBuilder addTagged (final long tag , final BigDecimal value ) throws VPackBuilderException {
461
+ return addInternal (tag , BIG_DECIMAL , value );
462
+ }
463
+
464
+ public VPackBuilder addTagged (final long tag , final Long value ) throws VPackBuilderException {
465
+ return addInternal (tag , LONG , value );
466
+ }
467
+
468
+ public VPackBuilder addTagged (final long tag , final Long value , final ValueType type ) throws VPackBuilderException {
469
+ return addInternal (tag , VALUE , new Value (value , type ));
470
+ }
471
+
472
+ public VPackBuilder addTagged (final long tag , final Integer value ) throws VPackBuilderException {
473
+ return addInternal (tag , INTEGER , value );
474
+ }
475
+
476
+ public VPackBuilder addTagged (final long tag , final Short value ) throws VPackBuilderException {
477
+ return addInternal (tag , SHORT , value );
478
+ }
479
+
480
+ public VPackBuilder addTagged (final long tag , final BigInteger value ) throws VPackBuilderException {
481
+ return addInternal (tag , BIG_INTEGER , value );
482
+ }
483
+
484
+ public VPackBuilder addTagged (final long tag , final BigInteger value , final ValueType type ) throws VPackBuilderException {
485
+ return addInternal (tag , VALUE , new Value (value , type ));
486
+ }
487
+
488
+ public VPackBuilder addTagged (final long tag , final Date value ) throws VPackBuilderException {
489
+ return addInternal (tag , DATE , value );
490
+ }
491
+
492
+ public VPackBuilder addTagged (final long tag , final java .sql .Date value ) throws VPackBuilderException {
493
+ return addInternal (tag , SQL_DATE , value );
494
+ }
495
+
496
+ public VPackBuilder addTagged (final long tag , final java .sql .Timestamp value ) throws VPackBuilderException {
497
+ return addInternal (tag , SQL_TIMESTAMP , value );
498
+ }
499
+
500
+ public VPackBuilder addTagged (final long tag , final String value ) throws VPackBuilderException {
501
+ return addInternal (tag , STRING , value );
502
+ }
503
+
504
+ public VPackBuilder addTagged (final long tag , final Character value ) throws VPackBuilderException {
505
+ return addInternal (tag , CHARACTER , value );
506
+ }
507
+
508
+ public VPackBuilder addTagged (final long tag , final byte [] value ) throws VPackBuilderException {
509
+ return addInternal (tag , BYTE_ARRAY , value );
510
+ }
511
+
512
+ public VPackBuilder addTagged (final long tag , final VPackSlice value ) throws VPackBuilderException {
513
+ return addInternal (tag , VPACK , value );
514
+ }
515
+
516
+ public VPackBuilder addTagged (final String attribute , final long tag , final ValueType value ) throws VPackBuilderException {
517
+ return addInternal (attribute , tag , VALUE_TYPE , value );
518
+ }
519
+
520
+ public VPackBuilder addTagged (final String attribute , final long tag , final ValueType value , final boolean unindexed )
521
+ throws VPackBuilderException {
522
+ return addInternal (attribute , tag , VALUE , new Value (value , unindexed ));
523
+ }
524
+
525
+ public VPackBuilder addTagged (final String attribute , final long tag , final Boolean value ) throws VPackBuilderException {
526
+ return addInternal (attribute , tag , BOOLEAN , value );
527
+ }
528
+
529
+ public VPackBuilder addTagged (final String attribute , final long tag , final Double value ) throws VPackBuilderException {
530
+ return addInternal (attribute , tag , DOUBLE , value );
531
+ }
532
+
533
+ public VPackBuilder addTagged (final String attribute , final long tag , final Float value ) throws VPackBuilderException {
534
+ return addInternal (attribute , tag , FLOAT , value );
535
+ }
536
+
537
+ public VPackBuilder addTagged (final String attribute , final long tag , final BigDecimal value ) throws VPackBuilderException {
538
+ return addInternal (attribute , tag , BIG_DECIMAL , value );
539
+ }
540
+
541
+ public VPackBuilder addTagged (final String attribute , final long tag , final Long value ) throws VPackBuilderException {
542
+ return addInternal (attribute , tag , LONG , value );
543
+ }
544
+
545
+ public VPackBuilder addTagged (final String attribute , final long tag , final Long value , final ValueType type )
546
+ throws VPackBuilderException {
547
+ return addInternal (attribute , tag , VALUE , new Value (value , type ));
548
+ }
549
+
550
+ public VPackBuilder addTagged (final String attribute , final long tag , final Integer value ) throws VPackBuilderException {
551
+ return addInternal (attribute , tag , INTEGER , value );
552
+ }
553
+
554
+ public VPackBuilder addTagged (final String attribute , final long tag , final Short value ) throws VPackBuilderException {
555
+ return addInternal (attribute , tag , SHORT , value );
556
+ }
557
+
558
+ public VPackBuilder addTagged (final String attribute , final long tag , final Byte value ) throws VPackBuilderException {
559
+ return addInternal (attribute , tag , BYTE , value );
560
+ }
561
+
562
+ public VPackBuilder addTagged (final String attribute , final long tag , final BigInteger value ) throws VPackBuilderException {
563
+ return addInternal (attribute , tag , BIG_INTEGER , value );
564
+ }
565
+
566
+ public VPackBuilder addTagged (final String attribute , final long tag , final BigInteger value , final ValueType type )
567
+ throws VPackBuilderException {
568
+ return addInternal (attribute , tag , VALUE , new Value (value , type ));
569
+ }
570
+
571
+ public VPackBuilder addTagged (final String attribute , final long tag , final String value ) throws VPackBuilderException {
572
+ return addInternal (attribute , tag , STRING , value );
573
+ }
574
+
575
+ public VPackBuilder addTagged (final String attribute , final long tag , final Character value ) throws VPackBuilderException {
576
+ return addInternal (attribute , tag , CHARACTER , value );
577
+ }
578
+
579
+ public VPackBuilder addTagged (final String attribute , final long tag , final Date value ) throws VPackBuilderException {
580
+ return addInternal (attribute , tag , DATE , value );
581
+ }
582
+
583
+ public VPackBuilder addTagged (final String attribute , final long tag , final java .sql .Date value ) throws VPackBuilderException {
584
+ return addInternal (attribute , tag , SQL_DATE , value );
585
+ }
586
+
587
+ public VPackBuilder addTagged (final String attribute , final long tag , final java .sql .Timestamp value ) throws VPackBuilderException {
588
+ return addInternal (attribute , tag , SQL_TIMESTAMP , value );
589
+ }
590
+
591
+ public VPackBuilder addTagged (final String attribute , final long tag , final byte [] value ) throws VPackBuilderException {
592
+ return addInternal (attribute , tag , BYTE_ARRAY , value );
593
+ }
594
+
595
+ public VPackBuilder addTagged (final String attribute , final long tag , final VPackSlice value ) throws VPackBuilderException {
596
+ return addInternal (attribute , tag , VPACK , value );
597
+ }
598
+
428
599
private <T > VPackBuilder addInternal (final Appender <T > appender , final T value ) throws VPackBuilderException {
600
+ return addInternal (0 , appender , value );
601
+ }
602
+
603
+ private <T > VPackBuilder addInternal (final long tag , final Appender <T > appender , final T value ) throws VPackBuilderException {
429
604
boolean haveReported = false ;
430
605
if (!stack .isEmpty () && !keyWritten ) {
431
606
reportAdd ();
432
607
haveReported = true ;
433
608
}
609
+
610
+ if (tag != 0 ) {
611
+ appendTag (tag );
612
+ }
613
+
434
614
try {
435
615
if (value == null ) {
436
616
appendNull ();
@@ -449,6 +629,11 @@ private <T> VPackBuilder addInternal(final Appender<T> appender, final T value)
449
629
450
630
private <T > VPackBuilder addInternal (final String attribute , final Appender <T > appender , final T value )
451
631
throws VPackBuilderException {
632
+ return addInternal (attribute , 0 , appender , value );
633
+ }
634
+
635
+ private <T > VPackBuilder addInternal (final String attribute , final long tag , final Appender <T > appender , final T value )
636
+ throws VPackBuilderException {
452
637
if (attribute != null ) {
453
638
boolean haveReported = false ;
454
639
if (!stack .isEmpty ()) {
@@ -466,10 +651,12 @@ private <T> VPackBuilder addInternal(final String attribute, final Appender<T> a
466
651
if (VPackSlice .attributeTranslator != null ) {
467
652
final VPackSlice translate = VPackSlice .attributeTranslator .translate (attribute );
468
653
if (translate != null ) {
469
- final byte [] trValue = translate .getRawVPack ();
470
- ensureCapacity (size + trValue .length );
471
- for (byte b : trValue ) {
472
- addUnchecked (b );
654
+ final byte [] trValue = translate .getBuffer ();
655
+ int trValueLength = translate .getByteSize ();
656
+ int trValueStart = translate .getStart ();
657
+ ensureCapacity (size + trValueLength );
658
+ for (int i = 0 ; i < trValueLength ; i ++) {
659
+ addUnchecked (trValue [i +trValueStart ]);
473
660
}
474
661
keyWritten = true ;
475
662
if (value == null ) {
@@ -483,6 +670,11 @@ private <T> VPackBuilder addInternal(final String attribute, final Appender<T> a
483
670
}
484
671
STRING .append (this , attribute );
485
672
keyWritten = true ;
673
+
674
+ if (tag != 0 ) {
675
+ appendTag (tag );
676
+ }
677
+
486
678
if (value == null ) {
487
679
appendNull ();
488
680
} else {
@@ -646,10 +838,11 @@ private void appendBinary(final byte[] value) {
646
838
}
647
839
648
840
private void appendVPack (final VPackSlice value ) {
649
- final byte [] vpack = value .getRawVPack ();
650
- ensureCapacity (size + vpack .length );
651
- System .arraycopy (vpack , 0 , buffer , size , vpack .length );
652
- size += vpack .length ;
841
+ final byte [] vpack = value .getBuffer ();
842
+ int length = value .getByteSize ();
843
+ ensureCapacity (size + length );
844
+ System .arraycopy (vpack , value .getStart (), buffer , size , length );
845
+ size += length ;
653
846
}
654
847
655
848
private void addArray (final boolean unindexed ) {
0 commit comments