@@ -546,7 +546,7 @@ public void importRowKeyColumnIDTest() throws IOException {
546546 LineDeserializer deserializer = new RowKeyColumnIDDeserializer ();
547547 RecordIterator iterator = csvRecordIterator ("row_key-column_id.csv" , deserializer );
548548 FieldOptions fieldOptions = FieldOptions .builder ()
549- .keys (true )
549+ .setKeys (true )
550550 .build ();
551551 Field field = this .index .field ("importfield-rowkey-colid" , fieldOptions );
552552 client .ensureField (field );
@@ -567,6 +567,37 @@ public void importRowKeyColumnIDTest() throws IOException {
567567 }
568568 }
569569
570+ @ Test
571+ public void fastImportRowKeyColumnIDTest () throws IOException {
572+ try (PilosaClient client = this .getClient ()) {
573+ LineDeserializer deserializer = new RowKeyColumnIDDeserializer ();
574+ RecordIterator iterator = csvRecordIterator ("row_key-column_id.csv" , deserializer );
575+ FieldOptions fieldOptions = FieldOptions .builder ()
576+ .setKeys (true )
577+ .build ();
578+ Field field = this .index .field ("importfield-rowkey-colid" , fieldOptions );
579+ client .ensureField (field );
580+ ImportOptions importOptions = ImportOptions .builder ()
581+ .setRoaring (true )
582+ .setTranslateKeys (true )
583+ .build ();
584+ client .importField (field , iterator , importOptions );
585+ PqlBatchQuery bq = index .batchQuery (
586+ field .row ("one" ),
587+ field .row ("five" ),
588+ field .row ("three" )
589+ );
590+ QueryResponse response = client .query (bq );
591+
592+ List <Long > target = Arrays .asList (10L , 20L , 41L );
593+ List <QueryResult > results = response .getResults ();
594+ for (int i = 0 ; i < results .size (); i ++) {
595+ RowResult br = results .get (i ).getRow ();
596+ assertEquals (target .get (i ), br .getColumns ().get (0 ));
597+ }
598+ }
599+ }
600+
570601 @ Test
571602 public void importRowKeyColumnKeyTest () throws IOException {
572603 try (PilosaClient client = this .getClient ()) {
@@ -644,7 +675,7 @@ public void importRoaringTest() throws IOException {
644675 @ Test
645676 public void importRoaringTimeFieldTest () throws IOException {
646677 try (PilosaClient client = this .getClient ()) {
647- RecordIterator iterator = StaticColumnIterator .columnsWithIDs ();
678+ RecordIterator iterator = StaticColumnIteratorWithTimestamp .columnsWithIDs ();
648679 FieldOptions fieldOptions = FieldOptions .builder ()
649680 .fieldTime (TimeQuantum .YEAR_MONTH_DAY_HOUR )
650681 .build ();
@@ -736,14 +767,14 @@ public void importFieldValuesWithKeysTest() throws IOException {
736767 RecordIterator iterator = StaticColumnIterator .fieldValuesWithKeys ();
737768 FieldOptions options = FieldOptions .builder ()
738769 .fieldInt (0 , 100 )
739- .keys (true )
770+ .setKeys (true )
740771 .build ();
741772 Field field = this .keyIndex .field ("importvaluefieldkeys" , options );
742773 client .ensureField (field );
743774 client .importField (field , iterator );
744775
745776 FieldOptions options2 = FieldOptions .builder ()
746- .keys (true )
777+ .setKeys (true )
747778 .build ();
748779 Field field2 = this .keyIndex .field ("importvaluefieldkeys-set" , options2 );
749780 client .ensureField (field2 );
@@ -765,7 +796,6 @@ public void importTestWithBatch() throws IOException {
765796 Field field = this .index .field ("importfield" );
766797 client .ensureField (field );
767798 ImportOptions options = ImportOptions .builder ().
768- setStrategy (ImportOptions .Strategy .BATCH ).
769799 setBatchSize (3 ).
770800 setThreadCount (1 ).
771801 build ();
@@ -848,8 +878,6 @@ public void run() {
848878 ImportOptions options = ImportOptions .builder ()
849879 .setBatchSize (100000 )
850880 .setThreadCount (2 )
851- .setStrategy (ImportOptions .Strategy .TIMEOUT )
852- .setTimeoutMs (5 )
853881 .build ();
854882 client .importField (field , iterator , options , statusQueue );
855883 monitorThread .interrupt ();
@@ -873,7 +901,6 @@ public void run() {
873901 this .client .ensureField (field );
874902
875903 ImportOptions options = ImportOptions .builder ()
876- .setStrategy (ImportOptions .Strategy .BATCH )
877904 .setBatchSize (500 )
878905 .setThreadCount (1 )
879906 .build ();
@@ -920,7 +947,6 @@ public void run() {
920947 this .client .ensureField (field );
921948
922949 ImportOptions options = ImportOptions .builder ()
923- .setStrategy (ImportOptions .Strategy .BATCH )
924950 .setBatchSize (1_000 )
925951 .setThreadCount (1 )
926952 .build ();
@@ -1109,6 +1135,25 @@ public void warningResponseTest() throws IOException, InterruptedException {
11091135 }
11101136 }
11111137
1138+ @ Test
1139+ public void translateRowKeysTest () throws IOException {
1140+ try (PilosaClient client = getClient ()) {
1141+ FieldOptions options = FieldOptions .builder ()
1142+ .setKeys (true )
1143+ .build ();
1144+ Field field = this .index .field ("translate-rowkey-field" , options );
1145+ client .syncSchema (this .schema );
1146+ client .query (this .index .batchQuery (
1147+ field .set ("key1" , 10 ),
1148+ field .set ("key2" , 1000 )
1149+ ));
1150+
1151+ List <Long > rowIDs = client .translateKeys (field , Arrays .asList ("key1" , "key2" ));
1152+ List <Long > target = Arrays .asList (1L , 2L );
1153+ assertEquals (target , rowIDs );
1154+ }
1155+ }
1156+
11121157 @ Test (expected = PilosaException .class )
11131158 public void importFailNot200 () throws IOException {
11141159 HttpServer server = runImportFailsHttpServer ();
@@ -1556,9 +1601,6 @@ private PilosaClient getClient() {
15561601 String bindAddress = getBindAddress ();
15571602 Cluster cluster = Cluster .withHost (URI .address (bindAddress ));
15581603 ClientOptions .Builder optionsBuilder = ClientOptions .builder ();
1559- if (isLegacyModeOff ()) {
1560- optionsBuilder .setLegacyMode (false );
1561- }
15621604 long shardWidth = getShardWidth ();
15631605 if (shardWidth > 0 ) {
15641606 optionsBuilder .setShardWidth (shardWidth );
@@ -1574,11 +1616,6 @@ private String getBindAddress() {
15741616 return bindAddress ;
15751617 }
15761618
1577- private boolean isLegacyModeOff () {
1578- String legacyModeOffStr = System .getenv ("LEGACY_MODE_OFF" );
1579- return legacyModeOffStr != null && legacyModeOffStr .equals ("true" );
1580- }
1581-
15821619 private long getShardWidth () {
15831620 String shardWidthStr = System .getenv ("SHARD_WIDTH" );
15841621 return (shardWidthStr == null ) ? 0 : Long .parseLong (shardWidthStr );
@@ -1617,6 +1654,66 @@ public static StaticColumnIterator fieldValuesWithKeys() {
16171654 }
16181655
16191656 private StaticColumnIterator (boolean keys , boolean intValues ) {
1657+ this .records = new ArrayList <>(3 );
1658+ if (keys ) {
1659+ if (intValues ) {
1660+ this .records .add (FieldValue .create ("ten" , 7 ));
1661+ this .records .add (FieldValue .create ("seven" , 1 ));
1662+ } else {
1663+ this .records .add (Column .create ("ten" , "five" ));
1664+ this .records .add (Column .create ("two" , "three" ));
1665+ this .records .add (Column .create ("seven" , "one" ));
1666+
1667+ }
1668+ } else {
1669+ if (intValues ) {
1670+ this .records .add (FieldValue .create (10 , 7 ));
1671+ this .records .add (FieldValue .create (7 , 1 ));
1672+ } else {
1673+ this .records .add (Column .create (10 , 5 ));
1674+ this .records .add (Column .create (2 , 3 ));
1675+ this .records .add (Column .create (7 , 1 ));
1676+ }
1677+ }
1678+ }
1679+
1680+ @ Override
1681+ public boolean hasNext () {
1682+ return this .index < this .records .size ();
1683+ }
1684+
1685+ @ Override
1686+ public Record next () {
1687+ return this .records .get (index ++);
1688+ }
1689+
1690+ @ Override
1691+ public void remove () {
1692+ // We have this just to avoid compilation problems on JDK 7
1693+ }
1694+ }
1695+
1696+ class StaticColumnIteratorWithTimestamp implements RecordIterator {
1697+ private List <Record > records ;
1698+ private int index = 0 ;
1699+
1700+ public static StaticColumnIteratorWithTimestamp columnsWithIDs () {
1701+ return new StaticColumnIteratorWithTimestamp (false , false );
1702+ }
1703+
1704+ public static StaticColumnIteratorWithTimestamp columnsWithKeys () {
1705+ return new StaticColumnIteratorWithTimestamp (true , false );
1706+ }
1707+
1708+ public static StaticColumnIteratorWithTimestamp fieldValuesWithIDs () {
1709+ return new StaticColumnIteratorWithTimestamp (false , true );
1710+ }
1711+
1712+ public static StaticColumnIteratorWithTimestamp fieldValuesWithKeys () {
1713+ return new StaticColumnIteratorWithTimestamp (true , true );
1714+ }
1715+
1716+ private StaticColumnIteratorWithTimestamp (boolean keys , boolean intValues ) {
16201717 this .records = new ArrayList <>(3 );
16211718 if (keys ) {
16221719 if (intValues ) {
0 commit comments