├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── com.pilosa.client ├── pom.xml └── src │ ├── integration-test │ └── java │ │ ├── com │ │ └── pilosa │ │ │ └── client │ │ │ └── IntegrationTest.java │ │ └── integrationtest │ │ ├── CsvFileColumnIteratorIT.java │ │ ├── FileRecordIteratorIT.java │ │ ├── InsecurePilosaClientIT.java │ │ └── PilosaClientIT.java │ ├── internal │ └── public.proto │ ├── main │ ├── java │ │ └── com │ │ │ └── pilosa │ │ │ └── client │ │ │ ├── BoolResult.java │ │ │ ├── ClientOptions.java │ │ │ ├── Cluster.java │ │ │ ├── Column.java │ │ │ ├── ColumnItem.java │ │ │ ├── ColumnIterator.java │ │ │ ├── CountResultItem.java │ │ │ ├── CsvFileColumnIterator.java │ │ │ ├── FieldRow.java │ │ │ ├── FieldValue.java │ │ │ ├── GroupCount.java │ │ │ ├── GroupCountsResult.java │ │ │ ├── ImportOptions.java │ │ │ ├── ImportRequest.java │ │ │ ├── ImportStatusUpdate.java │ │ │ ├── IntResult.java │ │ │ ├── Internal.java │ │ │ ├── NullResult.java │ │ │ ├── PilosaClient.java │ │ │ ├── QueryOptions.java │ │ │ ├── QueryResponse.java │ │ │ ├── QueryResult.java │ │ │ ├── QueryResultType.java │ │ │ ├── RecordIterator.java │ │ │ ├── RowIdentifiersResult.java │ │ │ ├── RowResult.java │ │ │ ├── ShardColumns.java │ │ │ ├── ShardFieldValues.java │ │ │ ├── ShardRecords.java │ │ │ ├── TimeQuantum.java │ │ │ ├── TopNResult.java │ │ │ ├── URI.java │ │ │ ├── Util.java │ │ │ ├── Validator.java │ │ │ ├── ValueCountResult.java │ │ │ ├── Version.java │ │ │ ├── csv │ │ │ ├── ColumnIDValueDeserializer.java │ │ │ ├── ColumnKeyValueDeserializer.java │ │ │ ├── FileRecordIterator.java │ │ │ ├── LineDeserializer.java │ │ │ ├── RowBoolColumnIDDeserializer.java │ │ │ ├── RowBoolColumnKeyDeserializer.java │ │ │ ├── RowIDColumnIDDeserializer.java │ │ │ ├── RowIDColumnKeyDeserializer.java │ │ │ ├── RowKeyColumnIDDeserializer.java │ │ │ └── RowKeyColumnKeyDeserializer.java │ │ │ ├── exceptions │ │ │ ├── HttpConflict.java │ │ │ ├── PilosaException.java │ │ │ ├── PilosaURIException.java │ │ │ └── ValidationException.java │ │ │ ├── orm │ │ │ ├── CacheType.java │ │ │ ├── Field.java │ │ │ ├── FieldOptions.java │ │ │ ├── FieldType.java │ │ │ ├── Index.java │ │ │ ├── IndexOptions.java │ │ │ ├── OptionsOptions.java │ │ │ ├── PqlBaseQuery.java │ │ │ ├── PqlBatchQuery.java │ │ │ ├── PqlQuery.java │ │ │ ├── PqlRowQuery.java │ │ │ ├── PqlRowsQuery.java │ │ │ ├── Record.java │ │ │ ├── Schema.java │ │ │ ├── SerializedQuery.java │ │ │ └── Util.java │ │ │ └── status │ │ │ ├── FieldInfo.java │ │ │ ├── IFieldInfo.java │ │ │ ├── ISchemaInfo.java │ │ │ ├── IndexInfo.java │ │ │ ├── SchemaInfo.java │ │ │ ├── StatusInfo.java │ │ │ ├── StatusNodeInfo.java │ │ │ └── StatusNodeURIInfo.java │ └── resources │ │ └── version.properties │ └── test │ ├── java │ └── com │ │ └── pilosa │ │ └── client │ │ ├── BoolResultTest.java │ │ ├── ClientOptionsTest.java │ │ ├── ClusterTest.java │ │ ├── ColumnItemTest.java │ │ ├── ColumnTest.java │ │ ├── CountResultItemTest.java │ │ ├── FieldRowTest.java │ │ ├── FieldValueTest.java │ │ ├── GroupCountTest.java │ │ ├── GroupCountsResultTest.java │ │ ├── IntResultTest.java │ │ ├── NullResultTest.java │ │ ├── PilosaClientTest.java │ │ ├── QueryRequestTest.java │ │ ├── QueryResponseTest.java │ │ ├── RowIdentifersResultTest.java │ │ ├── RowResultTest.java │ │ ├── ShardColumnsTest.java │ │ ├── ShardFieldValuesTest.java │ │ ├── TimeQuantumTest.java │ │ ├── TopNResultTest.java │ │ ├── URITest.java │ │ ├── UnitTest.java │ │ ├── UtilTest.java │ │ ├── ValidatorTest.java │ │ ├── ValueCountResultTest.java │ │ ├── VersionTest.java │ │ ├── exceptions │ │ ├── PilosURIExceptionTest.java │ │ ├── PilosaExceptionTest.java │ │ └── ValidationExceptionTest.java │ │ ├── orm │ │ ├── CacheTypeTest.java │ │ ├── FieldOptionsTest.java │ │ ├── FieldTest.java │ │ ├── FieldTypeTest.java │ │ ├── IndexOptionsTest.java │ │ ├── IndexTest.java │ │ ├── OptionsOptionsTest.java │ │ ├── OrmTest.java │ │ ├── QueryOptionsTest.java │ │ ├── SchemaTest.java │ │ └── UtilTest.java │ │ └── status │ │ ├── FieldInfoTest.java │ │ └── SchemaInfoTest.java │ └── resources │ ├── column_id-value.csv │ ├── column_key-value.csv │ ├── row_bool-column_id-timestamp.csv │ ├── row_bool-column_id.csv │ ├── row_bool-column_key-timestamp.csv │ ├── row_bool-column_key.csv │ ├── row_id-column_id-custom_timestamp.csv │ ├── row_id-column_id-timestamp.csv │ ├── row_id-column_id.csv │ ├── row_id-column_key-timestamp.csv │ ├── row_id-column_key.csv │ ├── row_key-column_id-timestamp.csv │ ├── row_key-column_id.csv │ ├── row_key-column_key-timestamp.csv │ ├── row_key-column_key.csv │ └── schema1.json ├── docs ├── data-model-queries.md ├── imports.md └── server-interaction.md └── make.cmd /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | com.pilosa.client.iml 3 | .idea 4 | dependency-reduced-pom.xml 5 | target/ 6 | com.pilosa.client/pilosa-client.iml 7 | .classpath 8 | .project 9 | .settings/ 10 | .attach_pid* -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | jdk: 4 | - openjdk7 5 | - oraclejdk8 6 | sudo: required 7 | before_install: 8 | - openssl req -x509 -newkey rsa:4096 -keyout test.pilosa.local.key -out test.pilosa.local.crt -days 3650 -nodes -subj "/C=US/ST=Texas/L=Austin/O=Pilosa/OU=Com/CN=test.pilosa.local" 9 | - wget https://s3.amazonaws.com/build.pilosa.com/pilosa-master-linux-amd64.tar.gz && tar xf pilosa-master-linux-amd64.tar.gz 10 | - ./pilosa-master-linux-amd64/pilosa server --metric.diagnostics=false -d http_data & 11 | - ./pilosa-master-linux-amd64/pilosa server --metric.diagnostics=false -b https://:30101 -d https_data --cluster.disabled --tls.skip-verify --tls.certificate test.pilosa.local.crt --tls.key test.pilosa.local.key & 12 | script: 13 | - PILOSA_BIND="https://:30101" make test-all 14 | - mvn -f com.pilosa.client/pom.xml clean test failsafe:integration-test jacoco:report coveralls:report 15 | 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Please check our [Contributor's Guidelines](https://github.com/pilosa/pilosa/CONTRIBUTING.md). 4 | 5 | 1. Fork this repo and add it as upstream: `git remote add upstream git@github.com:pilosa/java-pilosa.git`. 6 | 2. Make sure all tests pass (use `make test-all`) and be sure that the tests cover all statements in your code (we aim for 100% test coverage). 7 | 3. Commit your code to a feature branch and send a pull request to the `master` branch of our repo. 8 | 9 | ### Running tests 10 | 11 | You can run unit tests with: 12 | ``` 13 | make test 14 | ``` 15 | 16 | And both unit and integration tests with: 17 | ``` 18 | make test-all 19 | ``` 20 | 21 | Check the test coverage: 22 | ``` 23 | make cover 24 | ``` 25 | 26 | ### Generating protobuf classes 27 | 28 | Protobuf classes are already checked in to source control, so this step is only needed when the upstream `public.proto` changes. 29 | 30 | Before running the following step, make sure you have the [Protobuf compiler](https://github.com/google/protobuf) installed: 31 | ``` 32 | make generate 33 | ``` 34 | 35 | ### Generating documentation 36 | 37 | The documentation can be generated using: 38 | ``` 39 | make doc 40 | ``` 41 | 42 | Generated documentation will be saved to `com.pilosa.client/target/apidocs`. 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Pilosa Corp. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 31 | DAMAGE. 32 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: build clean cover doc fast generate test test-all release 3 | 4 | build: 5 | mvn -f com.pilosa.client/pom.xml clean package 6 | 7 | clean: 8 | mvn -f com.pilosa.client/pom.xml clean 9 | 10 | doc: 11 | mvn -f com.pilosa.client/pom.xml javadoc:javadoc 12 | 13 | fast: 14 | mvn -f com.pilosa.client/pom.xml clean package -Dskip.tests=true 15 | 16 | generate: 17 | protoc --java_out=com.pilosa.client/src/main/java/ com.pilosa.client/src/internal/public.proto 18 | 19 | test: 20 | mvn -f com.pilosa.client/pom.xml test 21 | 22 | test-all: 23 | mvn -f com.pilosa.client/pom.xml test && mvn -f com.pilosa.client/pom.xml failsafe:integration-test 24 | 25 | cover: 26 | mvn -f com.pilosa.client/pom.xml clean test failsafe:integration-test jacoco:report 27 | @echo See ./com.pilosa.client/target/site/jacoco/index.html for the coverage report 28 | 29 | release: 30 | mvn -f com.pilosa.client/pom.xml clean deploy -P release 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java Client for Pilosa 2 | 3 | This repo archived Sept 2022 as part of the transition from Pilosa to FeatureBase. 4 | Please contact community[at]featurebase[dot]com with any questions. 5 | 6 | 7 | 8 | 9 | 10 | Javadocs 11 | 12 | 13 | 14 | Java client for Pilosa high performance distributed index. 15 | 16 | ## What's New? 17 | 18 | See: [CHANGELOG](CHANGELOG.md) 19 | 20 | ## Requirements 21 | 22 | * JDK 7 and higher 23 | * Maven 3 and higher 24 | 25 | ## Install 26 | 27 | Add the following dependency in your `pom.xml`: 28 | 29 | ```xml 30 | 31 | 32 | com.pilosa 33 | pilosa-client 34 | 1.4.0 35 | 36 | 37 | ``` 38 | 39 | ## Usage 40 | 41 | ### Quick overview 42 | 43 | Assuming [Pilosa](https://github.com/pilosa/pilosa) server is running at `localhost:10101` (the default): 44 | 45 | ```java 46 | // Create the default client 47 | PilosaClient client = PilosaClient.defaultClient(); 48 | 49 | // Retrieve the schema 50 | Schema schema = client.readSchema(); 51 | 52 | // Create an Index object 53 | Index myindex = schema.index("myindex"); 54 | 55 | // Create a Field object 56 | Field myfield = myindex.field("myfield"); 57 | 58 | // make sure the index and field exists on the server 59 | client.syncSchema(schema); 60 | 61 | // Send a Set query. PilosaException is thrown if execution of the query fails. 62 | client.query(myfield.set(5, 42)); 63 | 64 | // Send a Row query. PilosaException is thrown if execution of the query fails. 65 | QueryResponse response = client.query(myfield.row(5)); 66 | 67 | // Get the result 68 | QueryResult result = response.getResult(); 69 | 70 | // Act on the result 71 | if (result != null) { 72 | List columns = result.getRow().getColumns(); 73 | System.out.println("Got columns: " + columns); 74 | } 75 | 76 | // You can batch queries to improve throughput 77 | response = client.query( 78 | myindex.batchQuery( 79 | myfield.row(5), 80 | myfield.row(10) 81 | ) 82 | ); 83 | for (Object r : response.getResults()) { 84 | // Act on the result 85 | } 86 | ``` 87 | 88 | ## Documentation 89 | 90 | ### Data Model and Queries 91 | 92 | See: [Data Model and Queries](docs/data-model-queries.md) 93 | 94 | ### Executing Queries 95 | 96 | See: [Server Interaction](docs/server-interaction.md) 97 | 98 | ### Importing and Exporting Data 99 | 100 | See: [Importing Data](docs/imports.md) 101 | 102 | ## Contributing 103 | 104 | See: [CONTRIBUTING](CONTRIBUTING.md) 105 | 106 | ## License 107 | 108 | See: [LICENSE](LICENSE) 109 | -------------------------------------------------------------------------------- /com.pilosa.client/src/integration-test/java/com/pilosa/client/IntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | /** 38 | * Assumes the Pilosa server is running at http://localhost:10101 39 | */ 40 | public interface IntegrationTest { 41 | } 42 | -------------------------------------------------------------------------------- /com.pilosa.client/src/internal/public.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package internal; 4 | 5 | option java_package = "com.pilosa.client"; 6 | option java_outer_classname = "Internal"; 7 | 8 | message Row { 9 | repeated uint64 Columns = 1; 10 | repeated string Keys = 3; 11 | repeated Attr Attrs = 2; 12 | } 13 | 14 | message RowIdentifiers { 15 | repeated uint64 Rows = 1; 16 | repeated string Keys = 2; 17 | } 18 | 19 | message Pair { 20 | uint64 ID = 1; 21 | string Key = 3; 22 | uint64 Count = 2; 23 | } 24 | 25 | message FieldRow{ 26 | string Field = 1; 27 | uint64 RowID = 2; 28 | string RowKey = 3; 29 | } 30 | 31 | message GroupCount{ 32 | repeated FieldRow Group = 1; 33 | uint64 Count = 2; 34 | } 35 | 36 | message ValCount { 37 | int64 Val = 1; 38 | int64 Count = 2; 39 | } 40 | 41 | message ColumnAttrSet { 42 | uint64 ID = 1; 43 | string Key = 3; 44 | repeated Attr Attrs = 2; 45 | } 46 | 47 | message Attr { 48 | string Key = 1; 49 | uint64 Type = 2; 50 | string StringValue = 3; 51 | int64 IntValue = 4; 52 | bool BoolValue = 5; 53 | double FloatValue = 6; 54 | } 55 | 56 | message AttrMap { 57 | repeated Attr Attrs = 1; 58 | } 59 | 60 | message QueryRequest { 61 | string Query = 1; 62 | repeated uint64 Shards = 2; 63 | bool ColumnAttrs = 3; 64 | bool Remote = 5; 65 | bool ExcludeRowAttrs = 6; 66 | bool ExcludeColumns = 7; 67 | } 68 | 69 | message QueryResponse { 70 | string Err = 1; 71 | repeated QueryResult Results = 2; 72 | repeated ColumnAttrSet ColumnAttrSets = 3; 73 | } 74 | 75 | message QueryResult { 76 | uint32 Type = 6; 77 | Row Row = 1; 78 | uint64 N = 2; 79 | repeated Pair Pairs = 3; 80 | bool Changed = 4; 81 | ValCount ValCount = 5; 82 | repeated uint64 RowIDs = 7; 83 | repeated GroupCount GroupCounts = 8; 84 | RowIdentifiers RowIdentifiers = 9; 85 | } 86 | 87 | message ImportRequest { 88 | string Index = 1; 89 | string Field = 2; 90 | uint64 Shard = 3; 91 | repeated uint64 RowIDs = 4; 92 | repeated uint64 ColumnIDs = 5; 93 | repeated string RowKeys = 7; 94 | repeated string ColumnKeys = 8; 95 | repeated int64 Timestamps = 6; 96 | } 97 | 98 | message ImportValueRequest { 99 | string Index = 1; 100 | string Field = 2; 101 | uint64 Shard = 3; 102 | repeated uint64 ColumnIDs = 5; 103 | repeated string ColumnKeys = 7; 104 | repeated int64 Values = 6; 105 | } 106 | 107 | message TranslateKeysRequest { 108 | string Index = 1; 109 | string Field = 2; 110 | repeated string Keys = 3; 111 | } 112 | 113 | message TranslateKeysResponse { 114 | repeated uint64 IDs = 3; 115 | } 116 | 117 | message ImportRoaringRequestView { 118 | string Name = 1; 119 | bytes Data = 2; 120 | } 121 | 122 | message ImportRoaringRequest { 123 | bool Clear = 1; 124 | repeated ImportRoaringRequestView views = 2; 125 | } -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/BoolResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.HashCodeBuilder; 38 | 39 | import java.util.List; 40 | 41 | public class BoolResult implements QueryResult { 42 | @Override 43 | public int getType() { 44 | return QueryResultType.BOOL; 45 | } 46 | 47 | @Override 48 | public RowResult getRow() { 49 | return RowResult.defaultResult(); 50 | } 51 | 52 | @Override 53 | public List getCountItems() { 54 | return TopNResult.defaultItems(); 55 | } 56 | 57 | @Override 58 | public long getCount() { 59 | return 0; 60 | } 61 | 62 | @Override 63 | public long getValue() { 64 | return 0; 65 | } 66 | 67 | @Override 68 | public boolean isChanged() { 69 | return this.changed; 70 | } 71 | 72 | @Override 73 | public List getGroupCounts() { 74 | return GroupCountsResult.defaultItems(); 75 | } 76 | 77 | @Override 78 | public RowIdentifiersResult getRowIdentifiers() { 79 | return RowIdentifiersResult.defaultResult(); 80 | } 81 | 82 | @Override 83 | public boolean equals(Object obj) { 84 | if (obj == this) { 85 | return true; 86 | } 87 | if (!(obj instanceof BoolResult)) { 88 | return false; 89 | } 90 | return this.changed == ((BoolResult) obj).changed; 91 | } 92 | 93 | @Override 94 | public int hashCode() { 95 | return new HashCodeBuilder(31, 47) 96 | .append(this.changed) 97 | .toHashCode(); 98 | } 99 | 100 | static BoolResult create(boolean changed) { 101 | BoolResult result = new BoolResult(); 102 | result.changed = changed; 103 | return result; 104 | } 105 | 106 | static BoolResult fromInternal(Internal.QueryResult q) { 107 | return create(q.getChanged()); 108 | } 109 | 110 | private boolean changed; 111 | } 112 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ColumnItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.EqualsBuilder; 38 | import org.apache.commons.lang3.builder.HashCodeBuilder; 39 | 40 | import java.util.Map; 41 | 42 | /** 43 | * Contains data about a column. 44 | *

45 | * Column data is returned from {@link QueryResponse#getColumns()} method. 46 | * They are only returned if {@link QueryOptions.Builder#setColumnAttributes(boolean)} was set to true. 47 | * 48 | * @see Data Model 49 | * @see Query Language 50 | */ 51 | public final class ColumnItem { 52 | private long id; 53 | private Map attributes; 54 | 55 | ColumnItem() { 56 | } 57 | 58 | ColumnItem(long id, Map attributes) { 59 | this.id = id; 60 | this.attributes = attributes; 61 | } 62 | 63 | static ColumnItem fromInternal(Internal.ColumnAttrSet column) { 64 | return new ColumnItem(column.getID(), Util.protobufAttrsToMap(column.getAttrsList())); 65 | } 66 | 67 | /** 68 | * Returns column ID 69 | * 70 | * @return column ID 71 | */ 72 | public long getID() { 73 | return this.id; 74 | } 75 | 76 | public Map getAttributes() { 77 | return this.attributes; 78 | } 79 | 80 | @Override 81 | public String toString() { 82 | return String.format("ColumnItem(id=%d, attrs=%s)", this.id, this.attributes); 83 | } 84 | 85 | @Override 86 | public int hashCode() { 87 | return new HashCodeBuilder(31, 47) 88 | .append(this.id) 89 | .append(this.attributes) 90 | .toHashCode(); 91 | } 92 | 93 | @Override 94 | public boolean equals(Object obj) { 95 | if (!(obj instanceof ColumnItem)) { 96 | return false; 97 | } 98 | if (obj == this) { 99 | return true; 100 | } 101 | ColumnItem rhs = (ColumnItem) obj; 102 | return new EqualsBuilder() 103 | .append(this.id, rhs.id) 104 | .append(this.attributes, rhs.attributes) 105 | .isEquals(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ColumnIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import java.util.Iterator; 38 | 39 | public interface ColumnIterator extends Iterator { 40 | } 41 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/FieldRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.EqualsBuilder; 38 | import org.apache.commons.lang3.builder.HashCodeBuilder; 39 | 40 | public final class FieldRow { 41 | public static FieldRow create(String fieldName, long rowID) { 42 | return new FieldRow(fieldName, rowID, ""); 43 | } 44 | public static FieldRow create(String fieldName, String rowKey) { 45 | return new FieldRow(fieldName, 0, rowKey); 46 | } 47 | 48 | public String getFieldName() { 49 | return this.fieldName; 50 | } 51 | 52 | public long getRowID() { 53 | return this.rowID; 54 | } 55 | 56 | public String getRowKey() { 57 | return this.rowKey; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | if (obj == this) { 63 | return true; 64 | } 65 | if (!(obj instanceof FieldRow)) { 66 | return false; 67 | } 68 | FieldRow rhs = (FieldRow) obj; 69 | return new EqualsBuilder() 70 | .append(this.fieldName, rhs.fieldName) 71 | .append(this.rowID, rhs.rowID) 72 | .append(this.rowKey, rhs.rowKey) 73 | .isEquals(); 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return new HashCodeBuilder(31, 47) 79 | .append(this.fieldName) 80 | .append(this.rowID) 81 | .append(this.rowKey) 82 | .toHashCode(); 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return String.format("FieldRow(field=%s, rowID=%d, rowKey=%s)", 88 | this.fieldName, this.rowID, this.rowKey); 89 | } 90 | 91 | static FieldRow fromInternal(Internal.FieldRow q) { 92 | return new FieldRow(q.getField(), q.getRowID(), q.getRowKey()); 93 | } 94 | 95 | private FieldRow(String fieldName, long rowID, String rowKey) { 96 | this.fieldName = fieldName; 97 | this.rowID = rowID; 98 | this.rowKey = rowKey; 99 | } 100 | 101 | private final String fieldName; 102 | private final long rowID; 103 | private final String rowKey; 104 | } 105 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/GroupCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.EqualsBuilder; 38 | import org.apache.commons.lang3.builder.HashCodeBuilder; 39 | 40 | import java.util.ArrayList; 41 | import java.util.List; 42 | 43 | public final class GroupCount { 44 | public static GroupCount create(List groups, long count) { 45 | return new GroupCount(groups, count); 46 | } 47 | 48 | public final List getGroups() { 49 | return this.groups; 50 | } 51 | 52 | public long getCount() { 53 | return this.count; 54 | } 55 | 56 | @Override 57 | public boolean equals(Object obj) { 58 | if (obj == this) { 59 | return true; 60 | } 61 | if (!(obj instanceof GroupCount)) { 62 | return false; 63 | } 64 | GroupCount rhs = (GroupCount) obj; 65 | return new EqualsBuilder() 66 | .append(this.groups, rhs.groups) 67 | .append(this.count, rhs.count) 68 | .isEquals(); 69 | } 70 | 71 | @Override 72 | public int hashCode() { 73 | return new HashCodeBuilder(31, 47) 74 | .append(this.groups) 75 | .append(this.count) 76 | .toHashCode(); 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | StringBuilder builder = new StringBuilder(); 82 | for (FieldRow fieldRow : this.groups) { 83 | builder.append(fieldRow.toString()); 84 | } 85 | return String.format("GroupCount(groups=[%s], count=%d)", 86 | builder.toString(), this.count); 87 | } 88 | 89 | static GroupCount fromInternal(Internal.GroupCount q) { 90 | List fieldRows = new ArrayList<>(q.getGroupCount()); 91 | for (Internal.FieldRow fieldRow : q.getGroupList()) { 92 | fieldRows.add(FieldRow.fromInternal(fieldRow)); 93 | } 94 | return new GroupCount(fieldRows, q.getCount()); 95 | } 96 | 97 | private GroupCount(List groups, long count) { 98 | this.groups = groups; 99 | this.count = count; 100 | } 101 | 102 | private final List groups; 103 | private final long count; 104 | } 105 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/GroupCountsResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | 40 | public final class GroupCountsResult implements QueryResult { 41 | public static GroupCountsResult create(final List items) { 42 | return new GroupCountsResult(items); 43 | } 44 | 45 | @Override 46 | public int getType() { 47 | return QueryResultType.GROUP_COUNTS; 48 | } 49 | 50 | @Override 51 | public RowResult getRow() { 52 | return RowResult.defaultResult(); 53 | } 54 | 55 | @Override 56 | public List getCountItems() { 57 | return TopNResult.defaultItems(); 58 | } 59 | 60 | @Override 61 | public long getCount() { 62 | return 0; 63 | } 64 | 65 | @Override 66 | public long getValue() { 67 | return 0; 68 | } 69 | 70 | @Override 71 | public boolean isChanged() { 72 | return false; 73 | } 74 | 75 | @Override 76 | public List getGroupCounts() { 77 | return this.items; 78 | } 79 | 80 | @Override 81 | public RowIdentifiersResult getRowIdentifiers() { 82 | return RowIdentifiersResult.defaultResult(); 83 | } 84 | 85 | @Override 86 | public boolean equals(Object obj) { 87 | if (obj == this) { 88 | return true; 89 | } 90 | if (!(obj instanceof GroupCountsResult)) { 91 | return false; 92 | } 93 | GroupCountsResult rhs = (GroupCountsResult) obj; 94 | return this.items.equals(rhs.items); 95 | } 96 | 97 | @Override 98 | public int hashCode() { 99 | return this.items.hashCode(); 100 | } 101 | 102 | static GroupCountsResult fromInternal(Internal.QueryResult q) { 103 | List items = new ArrayList<>(q.getGroupCountsCount()); 104 | for (Internal.GroupCount item : q.getGroupCountsList()) { 105 | items.add(GroupCount.fromInternal(item)); 106 | } 107 | return new GroupCountsResult(items); 108 | } 109 | 110 | static List defaultItems() { 111 | return defaultItems; 112 | } 113 | 114 | private GroupCountsResult(final List items) { 115 | this.items = items; 116 | } 117 | 118 | private static List defaultItems = new ArrayList<>(0); 119 | private final List items; 120 | } 121 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ImportRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.orm.Field; 38 | import org.apache.http.Header; 39 | import org.apache.http.message.BasicHeader; 40 | 41 | import static com.pilosa.client.PilosaClient.PQL_VERSION; 42 | 43 | class ImportRequest { 44 | ImportRequest(final String path, final byte[] payload, final String contentType) { 45 | this.path = path; 46 | this.payload = payload; 47 | this.contentType = contentType; 48 | } 49 | 50 | static ImportRequest createCSVImport(final Field field, final byte[] payload, boolean clear) { 51 | String clearStr = clear ? "?clear=true" : ""; 52 | String path = String.format("/index/%s/field/%s/import%s", field.getIndex().getName(), field.getName(), clearStr); 53 | return new ImportRequest(path, payload, "application/x-protobuf"); 54 | } 55 | 56 | static ImportRequest createRoaringImport(final Field field, long shard, final byte[] payload, boolean clear) { 57 | String clearStr = clear ? "?clear=true" : ""; 58 | String path = String.format("/index/%s/field/%s/import-roaring/%d%s", 59 | field.getIndex().getName(), field.getName(), shard, clearStr); 60 | return new ImportRequest(path, payload, "application/x-protobuf"); 61 | } 62 | 63 | String getPath() { 64 | return this.path; 65 | } 66 | 67 | byte[] getPayload() { 68 | return this.payload; 69 | } 70 | 71 | Header[] getHeaders() { 72 | return new Header[]{ 73 | new BasicHeader("Content-Type", this.contentType), 74 | new BasicHeader("Accept", "application/x-protobuf"), 75 | new BasicHeader("PQL-Version", PQL_VERSION) 76 | }; 77 | } 78 | 79 | protected final String path; 80 | protected final String contentType; 81 | protected final byte[] payload; 82 | } 83 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ImportStatusUpdate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | public class ImportStatusUpdate { 38 | public long getThreadID() { 39 | return this.threadID; 40 | } 41 | 42 | public long getShard() { 43 | return this.shard; 44 | } 45 | 46 | public long getImportedCount() { 47 | return this.importedCount; 48 | } 49 | 50 | public long getTimeMs() { 51 | return this.timeMs; 52 | } 53 | 54 | public String toString() { 55 | return String.format("thread:%d imported:%d columns for shard:%d in:%d ms", 56 | this.threadID, this.importedCount, this.shard, this.timeMs); 57 | } 58 | 59 | ImportStatusUpdate(final long threadID, final long shard, final long importedCount, final long timeMs) { 60 | this.threadID = threadID; 61 | this.shard = shard; 62 | this.importedCount = importedCount; 63 | this.timeMs = timeMs; 64 | } 65 | 66 | private final long threadID; 67 | private final long shard; 68 | private final long importedCount; 69 | private final long timeMs; 70 | } -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/IntResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.HashCodeBuilder; 38 | 39 | import java.util.List; 40 | 41 | public class IntResult implements QueryResult { 42 | @Override 43 | public int getType() { 44 | return QueryResultType.INT; 45 | } 46 | 47 | @Override 48 | public RowResult getRow() { 49 | return RowResult.defaultResult(); 50 | } 51 | 52 | @Override 53 | public List getCountItems() { 54 | return TopNResult.defaultItems(); 55 | } 56 | 57 | @Override 58 | public long getCount() { 59 | return this.count; 60 | } 61 | 62 | @Override 63 | public long getValue() { 64 | return 0; 65 | } 66 | 67 | @Override 68 | public boolean isChanged() { 69 | return false; 70 | } 71 | 72 | @Override 73 | public List getGroupCounts() { 74 | return GroupCountsResult.defaultItems(); 75 | } 76 | 77 | @Override 78 | public RowIdentifiersResult getRowIdentifiers() { 79 | return RowIdentifiersResult.defaultResult(); 80 | } 81 | 82 | @Override 83 | public boolean equals(Object obj) { 84 | if (obj == this) { 85 | return true; 86 | } 87 | if (!(obj instanceof IntResult)) { 88 | return false; 89 | } 90 | return this.count == ((IntResult) obj).count; 91 | } 92 | 93 | @Override 94 | public int hashCode() { 95 | return new HashCodeBuilder(31, 47) 96 | .append(this.count) 97 | .toHashCode(); 98 | } 99 | 100 | static IntResult create(long count) { 101 | IntResult result = new IntResult(); 102 | result.count = count; 103 | return result; 104 | } 105 | 106 | static IntResult fromInternal(Internal.QueryResult q) { 107 | return IntResult.create(q.getN()); 108 | } 109 | 110 | private long count; 111 | } 112 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/NullResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import java.util.List; 38 | 39 | public class NullResult implements QueryResult { 40 | @Override 41 | public int getType() { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public RowResult getRow() { 47 | return RowResult.defaultResult(); 48 | } 49 | 50 | @Override 51 | public List getCountItems() { 52 | return TopNResult.defaultItems(); 53 | } 54 | 55 | @Override 56 | public long getCount() { 57 | return 0; 58 | } 59 | 60 | @Override 61 | public long getValue() { 62 | return 0; 63 | } 64 | 65 | @Override 66 | public boolean isChanged() { 67 | return false; 68 | } 69 | 70 | @Override 71 | public List getGroupCounts() { 72 | return GroupCountsResult.defaultItems(); 73 | } 74 | 75 | @Override 76 | public RowIdentifiersResult getRowIdentifiers() { 77 | return RowIdentifiersResult.defaultResult(); 78 | } 79 | 80 | static NullResult defaultResult() { 81 | return defaultResult; 82 | } 83 | 84 | static { 85 | defaultResult = new NullResult(); 86 | } 87 | 88 | private NullResult() { 89 | } 90 | 91 | private static NullResult defaultResult; 92 | } 93 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/QueryResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import java.util.List; 38 | 39 | public interface QueryResult { 40 | int getType(); 41 | 42 | RowResult getRow(); 43 | 44 | List getCountItems(); 45 | 46 | long getCount(); 47 | 48 | long getValue(); 49 | 50 | boolean isChanged(); 51 | 52 | List getGroupCounts(); 53 | 54 | RowIdentifiersResult getRowIdentifiers(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/QueryResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | 38 | public class QueryResultType { 39 | public final static int NIL = 0; 40 | public final static int ROW = 1; 41 | public final static int PAIRS = 2; 42 | public final static int VAL_COUNT = 3; 43 | public final static int INT = 4; 44 | public final static int BOOL = 5; 45 | public final static int ROW_IDS = 6; // this is not used by the client 46 | public final static int GROUP_COUNTS = 7; 47 | public final static int ROW_IDENTIFIERS = 8; 48 | } 49 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/RecordIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.orm.Record; 38 | 39 | import java.util.Iterator; 40 | 41 | public interface RecordIterator extends Iterator { 42 | } 43 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ShardRecords.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.orm.Record; 38 | 39 | public interface ShardRecords { 40 | long getShard(); 41 | 42 | String getIndexName(); 43 | 44 | boolean isIndexKeys(); 45 | 46 | boolean isFieldKeys(); 47 | 48 | int size(); 49 | 50 | void add(Record record); 51 | 52 | void clear(); 53 | 54 | ImportRequest toImportRequest(); 55 | } 56 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.exceptions.PilosaException; 38 | 39 | import java.util.HashMap; 40 | import java.util.List; 41 | import java.util.Map; 42 | 43 | final class Util { 44 | static final int PROTOBUF_STRING_TYPE = 1; 45 | static final int PROTOBUF_INT_TYPE = 2; 46 | static final int PROTOBUF_BOOL_TYPE = 3; 47 | static final int PROTOBUF_DOUBLE_TYPE = 4; 48 | 49 | static Map protobufAttrsToMap(List attrList) { 50 | Map attrs = new HashMap<>(attrList.size()); 51 | for (Internal.Attr attr : attrList) { 52 | Object value; 53 | switch ((int) attr.getType()) { 54 | case PROTOBUF_STRING_TYPE: 55 | value = attr.getStringValue(); 56 | break; 57 | case PROTOBUF_INT_TYPE: 58 | value = attr.getIntValue(); 59 | break; 60 | case PROTOBUF_BOOL_TYPE: 61 | value = attr.getBoolValue(); 62 | break; 63 | case PROTOBUF_DOUBLE_TYPE: 64 | value = attr.getFloatValue(); 65 | break; 66 | default: 67 | throw new PilosaException("Unknown attribute type: " + attr.getType()); 68 | } 69 | attrs.put(attr.getKey(), value); 70 | } 71 | return attrs; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/ValueCountResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.commons.lang3.builder.EqualsBuilder; 38 | import org.apache.commons.lang3.builder.HashCodeBuilder; 39 | 40 | import java.util.List; 41 | 42 | public class ValueCountResult implements QueryResult { 43 | @Override 44 | public int getType() { 45 | return QueryResultType.VAL_COUNT; 46 | } 47 | 48 | @Override 49 | public RowResult getRow() { 50 | return RowResult.defaultResult(); 51 | } 52 | 53 | @Override 54 | public List getCountItems() { 55 | return TopNResult.defaultItems(); 56 | } 57 | 58 | @Override 59 | public long getCount() { 60 | return this.count; 61 | } 62 | 63 | @Override 64 | public long getValue() { 65 | return this.value; 66 | } 67 | 68 | @Override 69 | public boolean isChanged() { 70 | return false; 71 | } 72 | 73 | @Override 74 | public List getGroupCounts() { 75 | return GroupCountsResult.defaultItems(); 76 | } 77 | 78 | @Override 79 | public RowIdentifiersResult getRowIdentifiers() { 80 | return RowIdentifiersResult.defaultResult(); 81 | } 82 | 83 | @Override 84 | public boolean equals(Object obj) { 85 | if (obj == this) { 86 | return true; 87 | } 88 | if (!(obj instanceof ValueCountResult)) { 89 | return false; 90 | } 91 | ValueCountResult rhs = (ValueCountResult) obj; 92 | return new EqualsBuilder() 93 | .append(this.value, rhs.value) 94 | .append(this.count, rhs.count) 95 | .isEquals(); 96 | } 97 | 98 | @Override 99 | public int hashCode() { 100 | return new HashCodeBuilder(31, 47) 101 | .append(this.value) 102 | .append(this.count) 103 | .toHashCode(); 104 | } 105 | 106 | static ValueCountResult create(long sum, long count) { 107 | ValueCountResult result = new ValueCountResult(); 108 | result.value = sum; 109 | result.count = count; 110 | return result; 111 | } 112 | 113 | static ValueCountResult fromInternal(Internal.QueryResult q) { 114 | Internal.ValCount obj = q.getValCount(); 115 | return create(obj.getVal(), obj.getCount()); 116 | } 117 | 118 | private long value; 119 | private long count; 120 | } 121 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import java.io.IOException; 38 | import java.io.InputStream; 39 | import java.util.Properties; 40 | 41 | @SuppressWarnings("WeakerAccess") 42 | public final class Version { 43 | @SuppressWarnings("WeakerAccess") 44 | Version() { 45 | } 46 | 47 | @SuppressWarnings("WeakerAccess") 48 | public static String getVersion() { 49 | return Version.properties.getProperty("version"); 50 | } 51 | 52 | @SuppressWarnings("WeakerAccess") 53 | public static String getBuildTime() { 54 | return Version.properties.getProperty("build.time"); 55 | } 56 | 57 | static { 58 | Version version = new Version(); 59 | InputStream resourceAsStream = version.getClass().getResourceAsStream("/version.properties"); 60 | Version.properties = loadProperties(resourceAsStream); 61 | } 62 | 63 | static Properties loadProperties(InputStream src) { 64 | Properties props = new Properties(); 65 | try { 66 | props.load(src); 67 | } catch (IOException e) { 68 | props.setProperty("version", "0.0.0"); 69 | props.setProperty("build.time", "2016-11-01 09:00:00"); 70 | } 71 | return props; 72 | } 73 | 74 | private static Properties properties; 75 | } 76 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/ColumnIDValueDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.FieldValue; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class ColumnIDValueDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | long columnID = Long.valueOf(fields[0]); 44 | long value = Long.valueOf(fields[1]); 45 | return FieldValue.create(columnID, value); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/ColumnKeyValueDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.FieldValue; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class ColumnKeyValueDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | String columnKey = fields[0]; 44 | long value = Long.valueOf(fields[1]); 45 | return FieldValue.create(columnKey, value); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/LineDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.exceptions.PilosaException; 38 | import com.pilosa.client.orm.Record; 39 | 40 | import java.text.ParseException; 41 | import java.text.SimpleDateFormat; 42 | import java.util.Date; 43 | import java.util.TimeZone; 44 | 45 | public abstract class LineDeserializer { 46 | abstract Record deserialize(String[] fields); 47 | 48 | public void setTimestampFormat(SimpleDateFormat format) { 49 | this.timestampFormat = format; 50 | if (this.timestampFormat != null) { 51 | this.timestampFormat.setTimeZone(TimeZone.getTimeZone("GMT")); 52 | } 53 | } 54 | 55 | protected long parseTimestamp(final String s) { 56 | if (this.timestampFormat == null) { 57 | return Long.parseLong(s); 58 | } 59 | try { 60 | Date date = this.timestampFormat.parse(s); 61 | return date.getTime() / 1000; 62 | } catch (ParseException ex) { 63 | throw new PilosaException(String.format("Error parsing timestamp: %s", s), ex); 64 | } 65 | } 66 | 67 | public LineDeserializer() { 68 | this.setTimestampFormat(defaultTimestampFormat); 69 | } 70 | 71 | protected final static SimpleDateFormat defaultTimestampFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss"); 72 | protected SimpleDateFormat timestampFormat = null; 73 | } 74 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowBoolColumnIDDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowBoolColumnIDDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | boolean rowBool = Long.valueOf(fields[0]) == 1; 44 | long columnID = Long.valueOf(fields[1]); 45 | if (fields.length < 3) { 46 | return Column.create(rowBool, columnID); 47 | } 48 | return Column.create(rowBool, columnID, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowBoolColumnKeyDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowBoolColumnKeyDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | boolean rowBool = Long.valueOf(fields[0]) == 1; 44 | String columnKey = fields[1]; 45 | if (fields.length < 3) { 46 | return Column.create(rowBool, columnKey); 47 | } 48 | return Column.create(rowBool, columnKey, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowIDColumnIDDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowIDColumnIDDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | long rowID = Long.valueOf(fields[0]); 44 | long columnID = Long.valueOf(fields[1]); 45 | if (fields.length < 3) { 46 | return Column.create(rowID, columnID); 47 | } 48 | return Column.create(rowID, columnID, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowIDColumnKeyDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowIDColumnKeyDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | long rowID = Long.valueOf(fields[0]); 44 | String columnKey = fields[1]; 45 | if (fields.length < 3) { 46 | return Column.create(rowID, columnKey); 47 | } 48 | return Column.create(rowID, columnKey, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowKeyColumnIDDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowKeyColumnIDDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | String rowKey = fields[0]; 44 | long columnID = Long.valueOf(fields[1]); 45 | if (fields.length < 3) { 46 | return Column.create(rowKey, columnID); 47 | } 48 | return Column.create(rowKey, columnID, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/csv/RowKeyColumnKeyDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.csv; 36 | 37 | import com.pilosa.client.Column; 38 | import com.pilosa.client.orm.Record; 39 | 40 | public class RowKeyColumnKeyDeserializer extends LineDeserializer { 41 | @Override 42 | Record deserialize(String[] fields) { 43 | String rowKey = fields[0]; 44 | String columnKey = fields[1]; 45 | if (fields.length < 3) { 46 | return Column.create(rowKey, columnKey); 47 | } 48 | return Column.create(rowKey, columnKey, parseTimestamp(fields[2])); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/exceptions/HttpConflict.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | public class HttpConflict extends PilosaException { 38 | } 39 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/exceptions/PilosaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | public class PilosaException extends RuntimeException { 38 | public PilosaException() { 39 | } 40 | 41 | public PilosaException(String message) { 42 | super(message); 43 | } 44 | 45 | public PilosaException(String message, Throwable t) { 46 | super(message, t); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/exceptions/PilosaURIException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | public class PilosaURIException extends PilosaException { 38 | @SuppressWarnings("WeakerAccess") 39 | public PilosaURIException() { 40 | super(); 41 | } 42 | 43 | public PilosaURIException(String message) { 44 | super(message); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/exceptions/ValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | public class ValidationException extends PilosaException { 38 | public ValidationException() { 39 | super(); 40 | } 41 | 42 | public ValidationException(String message) { 43 | super(message); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/CacheType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.exceptions.ValidationException; 38 | 39 | public enum CacheType { 40 | DEFAULT(""), 41 | LRU("lru"), 42 | RANKED("ranked"), 43 | NONE("none"); 44 | 45 | CacheType(String value) { 46 | this.value = value; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return this.value; 52 | } 53 | 54 | /** 55 | * Converts a string to the corresponding CacheType. 56 | * 57 | * @param s the string to be converted 58 | * @return a CacheType object 59 | */ 60 | public static CacheType fromString(String s) { 61 | switch (s) { 62 | case "": 63 | return CacheType.DEFAULT; 64 | case "lru": 65 | return CacheType.LRU; 66 | case "ranked": 67 | return CacheType.RANKED; 68 | case "none": 69 | return CacheType.NONE; 70 | } 71 | throw new ValidationException(String.format("Invalid cache type string: %s", s)); 72 | } 73 | 74 | private final String value; 75 | } 76 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/FieldType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.exceptions.ValidationException; 38 | 39 | public enum FieldType { 40 | DEFAULT(""), 41 | SET("set"), 42 | TIME("time"), 43 | INT("int"), 44 | MUTEX("mutex"), 45 | BOOL("bool"); 46 | 47 | FieldType(String value) { 48 | this.value = value; 49 | } 50 | 51 | public static FieldType fromString(String s) { 52 | switch (s) { 53 | case "": 54 | return FieldType.DEFAULT; 55 | case "set": 56 | return FieldType.SET; 57 | case "time": 58 | return FieldType.TIME; 59 | case "int": 60 | return FieldType.INT; 61 | case "mutex": 62 | return FieldType.MUTEX; 63 | case "bool": 64 | return FieldType.BOOL; 65 | } 66 | throw new ValidationException(String.format("Invalid field type string: %s", s)); 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return this.value; 72 | } 73 | 74 | private final String value; 75 | } 76 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/PqlBaseQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | public class PqlBaseQuery implements PqlQuery { 38 | SerializedQuery query; 39 | private Index index = null; 40 | 41 | PqlBaseQuery(String pql) { 42 | this(pql, null); 43 | } 44 | 45 | PqlBaseQuery(String pql, Index index) { 46 | this.query = new SerializedQuery(pql, false); 47 | this.index = index; 48 | } 49 | 50 | public Index getIndex() { 51 | return this.index; 52 | } 53 | 54 | public SerializedQuery serialize() { 55 | return this.query; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/PqlQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | public interface PqlQuery { 38 | Index getIndex(); 39 | 40 | /** 41 | * @return the query in a form consumable by {@link com.pilosa.client.PilosaClient} 42 | */ 43 | SerializedQuery serialize(); 44 | } 45 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/PqlRowQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | @SuppressWarnings("WeakerAccess") 38 | public class PqlRowQuery extends PqlBaseQuery { 39 | PqlRowQuery(String pql) { 40 | super(pql); 41 | } 42 | 43 | PqlRowQuery(String pql, Index index) { 44 | super(pql, index); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/PqlRowsQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | public class PqlRowsQuery extends PqlBaseQuery { 38 | PqlRowsQuery(String pql, Index index) { 39 | super(pql, index); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/Record.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | public interface Record extends Comparable { 38 | long shard(final long shardWidth); 39 | 40 | boolean isDefault(); 41 | } 42 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/SerializedQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | public class SerializedQuery { 38 | public SerializedQuery(String query, boolean writeKeys) { 39 | this.query = query; 40 | this.writeKeys = writeKeys; 41 | } 42 | 43 | public String getQuery() { 44 | return this.query; 45 | } 46 | 47 | public boolean isWriteKeys() { 48 | return this.writeKeys; 49 | } 50 | 51 | public void setWriteKeys(boolean writeKeys) { 52 | this.writeKeys = writeKeys; 53 | } 54 | 55 | private String query; 56 | private boolean writeKeys; 57 | } 58 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/orm/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.fasterxml.jackson.core.JsonProcessingException; 38 | import com.fasterxml.jackson.databind.ObjectMapper; 39 | import com.pilosa.client.Validator; 40 | import com.pilosa.client.exceptions.PilosaException; 41 | import org.apache.commons.lang3.StringUtils; 42 | 43 | import java.util.ArrayList; 44 | import java.util.List; 45 | import java.util.Map; 46 | 47 | final class Util { 48 | Util() { 49 | } 50 | 51 | static String createAttributesString(ObjectMapper mapper, Map attributes) { 52 | try { 53 | List kvs = new ArrayList<>(attributes.size()); 54 | for (Map.Entry item : attributes.entrySet()) { 55 | // TODO: make key use its own validator 56 | Validator.ensureValidLabel(item.getKey()); 57 | kvs.add(String.format("%s=%s", item.getKey(), mapper.writeValueAsString(item.getValue()))); 58 | } 59 | return StringUtils.join(kvs, ","); 60 | } catch (JsonProcessingException ex) { 61 | throw new PilosaException("Error while converting values", ex); 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/IFieldInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.pilosa.client.orm.FieldOptions; 38 | 39 | public interface IFieldInfo { 40 | FieldOptions getOptions(); 41 | 42 | String getName(); 43 | } 44 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/ISchemaInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import java.util.List; 38 | 39 | interface ISchemaInfo { 40 | List getIndexes(); 41 | } 42 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/IndexInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.fasterxml.jackson.annotation.JsonProperty; 38 | import com.pilosa.client.orm.IndexOptions; 39 | 40 | import java.util.ArrayList; 41 | import java.util.List; 42 | 43 | public class IndexInfo { 44 | IndexInfo() { 45 | } 46 | 47 | @JsonProperty("name") 48 | public String getName() { 49 | return this.name; 50 | } 51 | 52 | void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | @JsonProperty("fields") 57 | public List getFields() { 58 | return this.fields; 59 | } 60 | 61 | public void setFields(List fields) { 62 | this.fields = fields; 63 | } 64 | 65 | @JsonProperty("options") 66 | public IndexOptions getIndexOptions() { 67 | return this.indexOptions; 68 | } 69 | 70 | @JsonProperty("shardWidth") 71 | public long getShardWidth() { 72 | return this.shardWidth; 73 | } 74 | 75 | private String name; 76 | private List fields = new ArrayList<>(); 77 | private IndexOptions indexOptions; 78 | private long shardWidth; 79 | } 80 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/SchemaInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.fasterxml.jackson.annotation.JsonProperty; 38 | import com.fasterxml.jackson.databind.DeserializationFeature; 39 | import com.fasterxml.jackson.databind.ObjectMapper; 40 | 41 | import java.io.IOException; 42 | import java.io.InputStream; 43 | import java.util.ArrayList; 44 | import java.util.List; 45 | 46 | public final class SchemaInfo implements ISchemaInfo { 47 | public static SchemaInfo fromInputStream(InputStream src) throws IOException { 48 | return mapper.readValue(src, SchemaInfo.class); 49 | } 50 | 51 | @JsonProperty("indexes") 52 | public List getIndexes() { 53 | return this.indexes; 54 | } 55 | 56 | void setIndexes(List indexes) { 57 | if (indexes == null) { 58 | this.indexes = new ArrayList<>(); 59 | return; 60 | } 61 | this.indexes = indexes; 62 | } 63 | 64 | static { 65 | ObjectMapper m = new ObjectMapper(); 66 | m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 67 | mapper = m; 68 | } 69 | 70 | private final static ObjectMapper mapper; 71 | private List indexes = new ArrayList<>(); 72 | } 73 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/StatusInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.fasterxml.jackson.annotation.JsonProperty; 38 | import com.fasterxml.jackson.databind.DeserializationFeature; 39 | import com.fasterxml.jackson.databind.ObjectMapper; 40 | 41 | import java.io.IOException; 42 | import java.io.InputStream; 43 | import java.util.List; 44 | 45 | public class StatusInfo { 46 | public static StatusInfo fromInputStream(InputStream src) throws IOException { 47 | return mapper.readValue(src, StatusInfo.class); 48 | } 49 | 50 | 51 | @JsonProperty("nodes") 52 | public void setNodes(List nodes) { 53 | this.nodes = nodes; 54 | } 55 | 56 | public StatusNodeInfo getCoordinatorNode() { 57 | for (StatusNodeInfo node : this.nodes) { 58 | if (node.isCoordinator()) { 59 | return node; 60 | } 61 | } 62 | return null; 63 | } 64 | 65 | static { 66 | ObjectMapper m = new ObjectMapper(); 67 | m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 68 | mapper = m; 69 | } 70 | 71 | 72 | private final static ObjectMapper mapper; 73 | private List nodes; 74 | } 75 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/StatusNodeInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.fasterxml.jackson.annotation.JsonProperty; 38 | 39 | public class StatusNodeInfo { 40 | 41 | @JsonProperty("uri") 42 | public StatusNodeURIInfo getUri() { 43 | return this.uri; 44 | } 45 | 46 | public void setUri(StatusNodeURIInfo uri) { 47 | this.uri = uri; 48 | } 49 | 50 | @JsonProperty("isCoordinator") 51 | public boolean isCoordinator() { 52 | return this.coordinator; 53 | } 54 | 55 | public void setCoordinator(boolean coordinator) { 56 | this.coordinator = coordinator; 57 | } 58 | 59 | private StatusNodeURIInfo uri; 60 | private boolean coordinator; 61 | } 62 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/java/com/pilosa/client/status/StatusNodeURIInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.fasterxml.jackson.annotation.JsonProperty; 38 | 39 | public class StatusNodeURIInfo { 40 | 41 | @JsonProperty("scheme") 42 | public String getScheme() { 43 | return this.scheme; 44 | } 45 | 46 | public void setScheme(String scheme) { 47 | this.scheme = scheme; 48 | } 49 | 50 | @JsonProperty("host") 51 | public String getHost() { 52 | return this.host; 53 | } 54 | 55 | public void setHost(String host) { 56 | this.host = host; 57 | } 58 | 59 | @JsonProperty("port") 60 | public int getPort() { 61 | return this.port; 62 | } 63 | 64 | public void setPort(int port) { 65 | this.port = port; 66 | } 67 | 68 | private String scheme; 69 | private String host; 70 | private int port; 71 | } 72 | -------------------------------------------------------------------------------- /com.pilosa.client/src/main/resources/version.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Pilosa Corp. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # 3. Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived 17 | # from this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | # DAMAGE. 33 | # 34 | version=${project.version} 35 | build.time=${timestamp} -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/BoolResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import static junit.framework.TestCase.assertFalse; 41 | import static org.junit.Assert.assertEquals; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class BoolResultTest { 46 | @Test 47 | public void testCreateBoolResult() { 48 | BoolResult result = BoolResult.create(true); 49 | assertEquals(QueryResultType.BOOL, result.getType()); 50 | assertEquals(RowResult.defaultResult(), result.getRow()); 51 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 52 | assertEquals(0L, result.getCount()); 53 | assertEquals(0L, result.getValue()); 54 | assertEquals(true, result.isChanged()); 55 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 56 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 57 | } 58 | 59 | @Test 60 | public void testEquals() { 61 | BoolResult result1 = BoolResult.create(true); 62 | BoolResult result2 = BoolResult.create(true); 63 | boolean e = result1.equals(result2); 64 | assertTrue(e); 65 | } 66 | 67 | @Test 68 | public void testEqualsFailsWithOtherObject() { 69 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 70 | boolean e = (new BoolResult()).equals(0); 71 | assertFalse(e); 72 | } 73 | 74 | @Test 75 | public void testEqualsSameObject() { 76 | BoolResult result = new BoolResult(); 77 | assertEquals(result, result); 78 | } 79 | 80 | @Test 81 | public void testHashCode() { 82 | BoolResult result1 = BoolResult.create(false); 83 | BoolResult result2 = BoolResult.create(false); 84 | assertEquals(result1.hashCode(), result2.hashCode()); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/ClientOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.apache.http.ssl.SSLContextBuilder; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import javax.net.ssl.SSLContext; 42 | import java.security.KeyManagementException; 43 | import java.security.NoSuchAlgorithmException; 44 | 45 | import static org.junit.Assert.assertEquals; 46 | 47 | @Category(UnitTest.class) 48 | public class ClientOptionsTest { 49 | @Test 50 | public void testCreateDefaults() { 51 | ClientOptions options = ClientOptions.builder().build(); 52 | assertEquals(10, options.getConnectionPoolSizePerRoute()); 53 | assertEquals(100, options.getConnectionPoolTotalSize()); 54 | assertEquals(30000, options.getConnectTimeout()); 55 | assertEquals(300000, options.getSocketTimeout()); 56 | assertEquals(3, options.getRetryCount()); 57 | } 58 | 59 | @Test 60 | public void testCreate() throws KeyManagementException, NoSuchAlgorithmException { 61 | SSLContext sslContext = new SSLContextBuilder().build(); 62 | ClientOptions options = ClientOptions.builder() 63 | .setConnectionPoolSizePerRoute(2) 64 | .setConnectionPoolTotalSize(50) 65 | .setConnectTimeout(100) 66 | .setSocketTimeout(1000) 67 | .setRetryCount(5) 68 | .setSslContext(sslContext) 69 | .setShardWidth(1024) 70 | .build(); 71 | assertEquals(2, options.getConnectionPoolSizePerRoute()); 72 | assertEquals(50, options.getConnectionPoolTotalSize()); 73 | assertEquals(100, options.getConnectTimeout()); 74 | assertEquals(1000, options.getSocketTimeout()); 75 | assertEquals(5, options.getRetryCount()); 76 | assertEquals(sslContext, options.getSslContext()); 77 | assertEquals(1024, options.getShardWidth()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/FieldRowTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import static org.junit.Assert.assertEquals; 41 | import static org.junit.Assert.assertFalse; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class FieldRowTest { 46 | @Test 47 | public void testFieldRow() { 48 | FieldRow f = FieldRow.create("f1", 42); 49 | assertEquals("f1", f.getFieldName()); 50 | assertEquals(42, f.getRowID()); 51 | assertEquals("", f.getRowKey()); 52 | assertEquals("FieldRow(field=f1, rowID=42, rowKey=)", f.toString()); 53 | 54 | f = FieldRow.create("f1", "forty-two"); 55 | assertEquals("f1", f.getFieldName()); 56 | assertEquals(0, f.getRowID()); 57 | assertEquals("forty-two", f.getRowKey()); 58 | assertEquals("FieldRow(field=f1, rowID=0, rowKey=forty-two)", f.toString()); 59 | } 60 | 61 | @Test 62 | public void testEquals() { 63 | FieldRow f = FieldRow.create("f1", 42); 64 | assertTrue(f.equals(f)); 65 | assertFalse(f.equals(new Integer(42))); 66 | } 67 | 68 | @Test 69 | public void testHashCode() { 70 | FieldRow f1 = FieldRow.create("f1", 42); 71 | FieldRow f2 = FieldRow.create("f1", 42); 72 | assertEquals(f1.hashCode(), f2.hashCode()); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/GroupCountTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import java.util.Collections; 41 | import java.util.List; 42 | 43 | import static org.junit.Assert.assertEquals; 44 | import static org.junit.Assert.assertFalse; 45 | import static org.junit.Assert.assertTrue; 46 | 47 | @Category(UnitTest.class) 48 | public class GroupCountTest { 49 | @Test 50 | public void testGroupCount() { 51 | List groups = Collections.singletonList(FieldRow.create("f1", 42)); 52 | GroupCount g = GroupCount.create(groups, 10); 53 | assertEquals(Collections.singletonList(FieldRow.create("f1", 42)), 54 | g.getGroups()); 55 | assertEquals(10, g.getCount()); 56 | assertEquals("GroupCount(groups=[FieldRow(field=f1, rowID=42, rowKey=)], count=10)", 57 | g.toString()); 58 | } 59 | 60 | @Test 61 | public void testEquals() { 62 | List groups = Collections.singletonList(FieldRow.create("f1", 42)); 63 | GroupCount g = GroupCount.create(groups, 10); 64 | assertTrue(g.equals(g)); 65 | assertFalse(g.equals(new Integer(10))); 66 | 67 | } 68 | 69 | @Test 70 | public void testHashCode() { 71 | List groups = Collections.singletonList(FieldRow.create("f1", 42)); 72 | GroupCount g1 = GroupCount.create(groups, 10); 73 | GroupCount g2 = GroupCount.create(groups, 10); 74 | assertEquals(g1.hashCode(), g2.hashCode()); 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/GroupCountsResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import java.util.ArrayList; 41 | import java.util.Collections; 42 | import java.util.List; 43 | 44 | import static org.junit.Assert.assertEquals; 45 | import static org.junit.Assert.assertFalse; 46 | import static org.junit.Assert.assertTrue; 47 | 48 | @Category(UnitTest.class) 49 | public class GroupCountsResultTest { 50 | @Test 51 | public void testCreateGroupCountsResult() { 52 | GroupCountsResult result = createSampleResult(); 53 | assertEquals(QueryResultType.GROUP_COUNTS, result.getType()); 54 | assertEquals(0, result.getCount()); 55 | assertEquals(RowResult.defaultResult(), result.getRow()); 56 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 57 | assertEquals(0L, result.getCount()); 58 | assertEquals(0L, result.getValue()); 59 | assertEquals(false, result.isChanged()); 60 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 61 | } 62 | 63 | @Test 64 | public void testEquals() { 65 | GroupCountsResult r1 = createSampleResult(); 66 | GroupCountsResult r2 = createSampleResult(); 67 | assertTrue(r1.equals(r1)); 68 | assertTrue(r1.equals(r2)); 69 | assertFalse(r1.equals(new Integer(10))); 70 | } 71 | 72 | @Test 73 | public void testHashCode() { 74 | assertEquals(createSampleResult().hashCode(), createSampleResult().hashCode()); 75 | } 76 | 77 | private GroupCountsResult createSampleResult() { 78 | List groups = Collections.singletonList(FieldRow.create("f1", 42)); 79 | List items = new ArrayList<>(); 80 | items.add(GroupCount.create(groups, 10)); 81 | return GroupCountsResult.create(items); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/IntResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import static junit.framework.TestCase.assertFalse; 41 | import static org.junit.Assert.assertEquals; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class IntResultTest { 46 | @Test 47 | public void testCreateIntResult() { 48 | IntResult result = IntResult.create(55); 49 | assertEquals(QueryResultType.INT, result.getType()); 50 | assertEquals(RowResult.defaultResult(), result.getRow()); 51 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 52 | assertEquals(55L, result.getCount()); 53 | assertEquals(0L, result.getValue()); 54 | assertEquals(false, result.isChanged()); 55 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 56 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 57 | } 58 | 59 | @Test 60 | public void testEquals() { 61 | IntResult result1 = IntResult.create(33); 62 | IntResult result2 = IntResult.create(33); 63 | boolean e = result1.equals(result2); 64 | assertTrue(e); 65 | } 66 | 67 | @Test 68 | public void testEqualsFailsWithOtherObject() { 69 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 70 | boolean e = (new IntResult()).equals(0); 71 | assertFalse(e); 72 | } 73 | 74 | @Test 75 | public void testEqualsSameObject() { 76 | IntResult result = IntResult.create(6); 77 | assertEquals(result, result); 78 | } 79 | 80 | @Test 81 | public void testHashCode() { 82 | IntResult result1 = IntResult.create(22); 83 | IntResult result2 = IntResult.create(22); 84 | assertEquals(result1.hashCode(), result2.hashCode()); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/NullResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import static junit.framework.TestCase.assertFalse; 41 | import static org.junit.Assert.assertEquals; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class NullResultTest { 46 | @Test 47 | public void testCreateNullResult() { 48 | NullResult result = NullResult.defaultResult(); 49 | assertEquals(QueryResultType.NIL, result.getType()); 50 | assertEquals(RowResult.defaultResult(), result.getRow()); 51 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 52 | assertEquals(0L, result.getCount()); 53 | assertEquals(0L, result.getValue()); 54 | assertEquals(false, result.isChanged()); 55 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 56 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 57 | } 58 | 59 | @Test 60 | public void testEquals() { 61 | NullResult result1 = NullResult.defaultResult(); 62 | NullResult result2 = NullResult.defaultResult(); 63 | boolean e = result1.equals(result2); 64 | assertTrue(e); 65 | } 66 | 67 | @Test 68 | public void testEqualsFailsWithOtherObject() { 69 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 70 | boolean e = (NullResult.defaultResult()).equals(0); 71 | assertFalse(e); 72 | } 73 | 74 | @Test 75 | public void testHashCode() { 76 | NullResult result1 = NullResult.defaultResult(); 77 | NullResult result2 = NullResult.defaultResult(); 78 | assertEquals(result1.hashCode(), result2.hashCode()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/QueryRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.orm.Index; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import static org.junit.Assert.assertEquals; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class QueryRequestTest { 46 | @Test 47 | public void testProtobuf() { 48 | QueryRequest qr = QueryRequest.withIndex(Index.create("somedb")); 49 | qr.setQuery("Range(id=1, field='foo', start='2016-01-01T13:00', end='2017-01-01T14:00')"); 50 | qr.setRetrieveColumnAttributes(true); 51 | Internal.QueryRequest request = qr.toProtobuf(); 52 | assertEquals("Range(id=1, field='foo', start='2016-01-01T13:00', end='2017-01-01T14:00')", request.getQuery()); 53 | assertTrue(request.getColumnAttrs()); 54 | } 55 | 56 | @Test 57 | public void testGetQuery() { 58 | QueryRequest qr = QueryRequest.withIndex(Index.create("mydb")); 59 | qr.setQuery("SetBit(id=1, field='the-field', col_id=556"); 60 | assertEquals("SetBit(id=1, field='the-field', col_id=556", qr.getQuery()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/QueryResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.exceptions.PilosaException; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import static org.junit.Assert.assertNull; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class QueryResponseTest { 46 | @Test 47 | public void testDefaultConstructor() { 48 | QueryResponse response = new QueryResponse(); 49 | assertTrue(response.isSuccess()); 50 | assertNull(response.getErrorMessage()); 51 | } 52 | 53 | @Test 54 | public void testNoResult() { 55 | QueryResponse response = new QueryResponse(); 56 | assertNull(response.getResult()); 57 | assertNull(response.getColumns()); 58 | } 59 | 60 | @Test(expected = PilosaException.class) 61 | public void testUnknownType() { 62 | Internal.QueryResult result = Internal.QueryResult.newBuilder() 63 | .setType(999) 64 | .build(); 65 | Internal.QueryResponse response = Internal.QueryResponse.newBuilder() 66 | .addResults(result) 67 | .build(); 68 | PilosaClient client = PilosaClient.defaultClient(); 69 | QueryResponse r = new QueryResponse(); 70 | r.parseQueryResponse(response); 71 | } 72 | 73 | @Test 74 | public void testQueryResultNew() { 75 | // This test is just for coveralls 76 | QueryResultType t = new QueryResultType(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/RowIdentifersResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import java.util.Arrays; 41 | 42 | import static org.junit.Assert.assertEquals; 43 | 44 | @Category(UnitTest.class) 45 | public class RowIdentifersResultTest { 46 | @Test 47 | public void createRowIdentifiersResultTest() { 48 | RowIdentifiersResult result = RowIdentifiersResult.withIDs(Arrays.asList(1L, 2L, 3L)); 49 | assertEquals(QueryResultType.ROW_IDENTIFIERS, result.getType()); 50 | assertEquals(0, result.getCount()); 51 | assertEquals(RowResult.defaultResult(), result.getRow()); 52 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 53 | assertEquals(0L, result.getCount()); 54 | assertEquals(0L, result.getValue()); 55 | assertEquals(false, result.isChanged()); 56 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 57 | assertEquals(RowIdentifiersResult.withIDs(Arrays.asList(1L, 2L, 3L)), 58 | result.getRowIdentifiers()); 59 | } 60 | 61 | @Test 62 | public void testHashCode() { 63 | RowIdentifiersResult result = RowIdentifiersResult.withIDs(Arrays.asList(1L, 2L, 3L)); 64 | assertEquals(result.hashCode(), result.hashCode()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/TimeQuantumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.exceptions.ValidationException; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import java.util.HashMap; 42 | import java.util.Map; 43 | 44 | import static org.junit.Assert.assertEquals; 45 | 46 | @Category(UnitTest.class) 47 | public class TimeQuantumTest { 48 | @Test 49 | public void testGetStringValue() { 50 | Map vs = getTargetMap(); 51 | for (Map.Entry e : vs.entrySet()) { 52 | assertEquals(e.getValue(), e.getKey().toString()); 53 | } 54 | } 55 | 56 | @Test 57 | public void testFromString() { 58 | Map vs = getTargetMap(); 59 | for (Map.Entry e : vs.entrySet()) { 60 | assertEquals(TimeQuantum.fromString(e.getValue()), e.getKey()); 61 | } 62 | } 63 | 64 | @Test(expected = ValidationException.class) 65 | public void testFromStringInvalidString() { 66 | TimeQuantum.fromString("INV"); 67 | } 68 | 69 | private Map getTargetMap() { 70 | Map vs = new HashMap<>(); 71 | vs.put(TimeQuantum.YEAR_MONTH_DAY_HOUR, "YMDH"); 72 | vs.put(TimeQuantum.YEAR_MONTH_DAY, "YMD"); 73 | vs.put(TimeQuantum.YEAR_MONTH, "YM"); 74 | vs.put(TimeQuantum.YEAR, "Y"); 75 | vs.put(TimeQuantum.MONTH_DAY_HOUR, "MDH"); 76 | vs.put(TimeQuantum.MONTH_DAY, "MD"); 77 | vs.put(TimeQuantum.MONTH, "M"); 78 | vs.put(TimeQuantum.DAY, "D"); 79 | vs.put(TimeQuantum.DAY_HOUR, "DH"); 80 | vs.put(TimeQuantum.HOUR, "H"); 81 | vs.put(TimeQuantum.NONE, ""); 82 | return vs; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/TopNResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import java.util.ArrayList; 41 | import java.util.List; 42 | 43 | import static junit.framework.TestCase.assertFalse; 44 | import static org.junit.Assert.assertEquals; 45 | import static org.junit.Assert.assertTrue; 46 | 47 | @Category(UnitTest.class) 48 | public class TopNResultTest { 49 | @Test 50 | public void testCreateTopNResult() { 51 | TopNResult result = createSampleResult(); 52 | List items = result.getCountItems(); 53 | assertEquals(1, items.size()); 54 | assertEquals(QueryResultType.PAIRS, result.getType()); 55 | List targetItems = new ArrayList<>(); 56 | targetItems.add(CountResultItem.create(5, "", 10)); 57 | assertEquals(RowResult.defaultResult(), result.getRow()); 58 | assertEquals(targetItems, result.getCountItems()); 59 | assertEquals(0L, result.getCount()); 60 | assertEquals(0L, result.getValue()); 61 | assertEquals(false, result.isChanged()); 62 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 63 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 64 | } 65 | 66 | @Test 67 | public void testEquals() { 68 | TopNResult result1 = createSampleResult(); 69 | TopNResult result2 = createSampleResult(); 70 | boolean e = result1.equals(result2); 71 | assertTrue(e); 72 | } 73 | 74 | @Test 75 | public void testEqualsFailsWithOtherObject() { 76 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 77 | boolean e = (new TopNResult()).equals(0); 78 | assertFalse(e); 79 | } 80 | 81 | @Test 82 | public void testEqualsSameObject() { 83 | TopNResult result = createSampleResult(); 84 | assertEquals(result, result); 85 | } 86 | 87 | @Test 88 | public void testHashCode() { 89 | TopNResult result1 = createSampleResult(); 90 | TopNResult result2 = createSampleResult(); 91 | assertEquals(result1.hashCode(), result2.hashCode()); 92 | } 93 | 94 | private TopNResult createSampleResult() { 95 | List items = new ArrayList<>(); 96 | items.add(CountResultItem.create(5, "", 10)); 97 | return TopNResult.create(items); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/UnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | public interface UnitTest { 38 | } 39 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/UtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import com.pilosa.client.exceptions.PilosaException; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import java.util.ArrayList; 42 | import java.util.List; 43 | import java.util.Map; 44 | 45 | import static com.pilosa.client.Util.protobufAttrsToMap; 46 | import static org.junit.Assert.assertEquals; 47 | 48 | @Category(UnitTest.class) 49 | public class UtilTest { 50 | @Test 51 | public void protobufAttrsToMapTest() { 52 | List attrs = new ArrayList<>(3); 53 | attrs.add(Internal.Attr.newBuilder() 54 | .setType(Util.PROTOBUF_STRING_TYPE) 55 | .setKey("stringval") 56 | .setStringValue("somestr") 57 | .build()); 58 | attrs.add(Internal.Attr.newBuilder() 59 | .setType(Util.PROTOBUF_INT_TYPE) 60 | .setKey("intval") 61 | .setIntValue(5) 62 | .build()); 63 | attrs.add(Internal.Attr.newBuilder() 64 | .setType(Util.PROTOBUF_BOOL_TYPE) 65 | .setKey("boolval") 66 | .setBoolValue(true) 67 | .build()); 68 | attrs.add(Internal.Attr.newBuilder() 69 | .setKey("doubleval") 70 | .setType(Util.PROTOBUF_DOUBLE_TYPE) 71 | .setFloatValue(123.5678) 72 | .build()); 73 | Map m = protobufAttrsToMap(attrs); 74 | assertEquals(4, m.size()); 75 | assertEquals("somestr", m.get("stringval")); 76 | assertEquals(5L, m.get("intval")); 77 | assertEquals(true, m.get("boolval")); 78 | assertEquals(123.5678, m.get("doubleval")); 79 | } 80 | 81 | @Test(expected = PilosaException.class) 82 | public void protobufAttrsToMapFailsTest() { 83 | List attrs = new ArrayList<>(3); 84 | attrs.add(Internal.Attr.newBuilder() 85 | .setType(9) 86 | .setKey("stringval") 87 | .setStringValue("somestr") 88 | .build()); 89 | protobufAttrsToMap(attrs); 90 | } 91 | 92 | @Test 93 | public void createUtilTest() { 94 | // this test is required only to get 100% coverage 95 | new Util(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/ValueCountResultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import static junit.framework.TestCase.assertFalse; 41 | import static org.junit.Assert.assertEquals; 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class ValueCountResultTest { 46 | @Test 47 | public void testCreateSumCountResult() { 48 | ValueCountResult result = ValueCountResult.create(20, 10); 49 | assertEquals(QueryResultType.VAL_COUNT, result.getType()); 50 | assertEquals(RowResult.defaultResult(), result.getRow()); 51 | assertEquals(TopNResult.defaultItems(), result.getCountItems()); 52 | assertEquals(10, result.getCount()); 53 | assertEquals(20L, result.getValue()); 54 | assertEquals(false, result.isChanged()); 55 | assertEquals(GroupCountsResult.defaultItems(), result.getGroupCounts()); 56 | assertEquals(RowIdentifiersResult.defaultResult(), result.getRowIdentifiers()); 57 | } 58 | 59 | @Test 60 | public void testEquals() { 61 | ValueCountResult result1 = ValueCountResult.create(33, 5); 62 | ValueCountResult result2 = ValueCountResult.create(33, 5); 63 | boolean e = result1.equals(result2); 64 | assertTrue(e); 65 | } 66 | 67 | @Test 68 | public void testEqualsFailsWithOtherObject() { 69 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 70 | boolean e = (new ValueCountResult()).equals(0); 71 | assertFalse(e); 72 | } 73 | 74 | @Test 75 | public void testEqualsSameObject() { 76 | ValueCountResult result = ValueCountResult.create(6, 3); 77 | assertEquals(result, result); 78 | } 79 | 80 | @Test 81 | public void testHashCode() { 82 | ValueCountResult result1 = ValueCountResult.create(22, 7); 83 | ValueCountResult result2 = ValueCountResult.create(22, 7); 84 | assertEquals(result1.hashCode(), result2.hashCode()); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/VersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client; 36 | 37 | import org.junit.Test; 38 | import org.junit.experimental.categories.Category; 39 | 40 | import java.io.IOException; 41 | import java.io.InputStream; 42 | import java.util.Properties; 43 | 44 | import static org.junit.Assert.assertEquals; 45 | import static org.junit.Assert.assertNotEquals; 46 | 47 | @Category(UnitTest.class) 48 | public class VersionTest { 49 | @Test 50 | public void testVersionLoaded() { 51 | assertNotEquals("0.0.0", Version.getVersion()); 52 | assertNotEquals("2016-11-01 09:00:00", Version.getBuildTime()); 53 | } 54 | 55 | @Test 56 | public void testLoadPropertiesFailure() { 57 | InputStream inputStream = new InputStream() { 58 | @Override 59 | public int read() throws IOException { 60 | throw new IOException(); 61 | } 62 | }; 63 | Properties props = Version.loadProperties(inputStream); 64 | assertEquals("0.0.0", props.getProperty("version")); 65 | assertEquals("2016-11-01 09:00:00", props.getProperty("build.time")); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/exceptions/PilosURIExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import static org.junit.Assert.assertEquals; 42 | 43 | @Category(UnitTest.class) 44 | public class PilosURIExceptionTest { 45 | @Test 46 | public void createPilosaURIException() { 47 | try { 48 | throw new PilosaURIException(); 49 | } catch (PilosaURIException ex) { 50 | assertEquals(null, ex.getMessage()); 51 | } 52 | 53 | try { 54 | throw new PilosaURIException("malformed URI"); 55 | } catch (PilosaURIException ex) { 56 | assertEquals("malformed URI", ex.getMessage()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/exceptions/PilosaExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import static org.junit.Assert.assertEquals; 42 | 43 | @Category(UnitTest.class) 44 | public class PilosaExceptionTest { 45 | @Test 46 | public void createPilosaException() { 47 | try { 48 | throw new PilosaException(); 49 | } catch (PilosaException ex) { 50 | assertEquals(null, ex.getMessage()); 51 | } 52 | 53 | try { 54 | throw new PilosaException("no exception"); 55 | } catch (PilosaException ex) { 56 | assertEquals("no exception", ex.getMessage()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/exceptions/ValidationExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.exceptions; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import static org.junit.Assert.assertEquals; 42 | 43 | @Category(UnitTest.class) 44 | public class ValidationExceptionTest { 45 | @Test 46 | public void createValidationExceptionTest() { 47 | try { 48 | throw new ValidationException(); 49 | } catch (ValidationException ex) { 50 | assertEquals(null, ex.getMessage()); 51 | } 52 | 53 | try { 54 | throw new ValidationException("invalid thing"); 55 | } catch (ValidationException ex) { 56 | assertEquals("invalid thing", ex.getMessage()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/CacheTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import com.pilosa.client.exceptions.ValidationException; 39 | import org.junit.Test; 40 | import org.junit.experimental.categories.Category; 41 | 42 | import static org.junit.Assert.assertEquals; 43 | 44 | @Category(UnitTest.class) 45 | public class CacheTypeTest { 46 | @Test 47 | public void fromStringTest() { 48 | assertEquals(CacheType.DEFAULT, CacheType.fromString("")); 49 | assertEquals(CacheType.LRU, CacheType.fromString("lru")); 50 | assertEquals(CacheType.RANKED, CacheType.fromString("ranked")); 51 | } 52 | 53 | @Test(expected = ValidationException.class) 54 | public void fromStringFailsTest() { 55 | CacheType.fromString("foo"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/FieldTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.TimeQuantum; 38 | import com.pilosa.client.UnitTest; 39 | import com.pilosa.client.exceptions.ValidationException; 40 | import org.junit.Before; 41 | import org.junit.Test; 42 | import org.junit.experimental.categories.Category; 43 | 44 | import static org.junit.Assert.assertEquals; 45 | import static org.junit.Assert.assertFalse; 46 | 47 | @Category(UnitTest.class) 48 | public class FieldTest { 49 | 50 | @Before 51 | public void setUp() { 52 | Schema schema = Schema.defaultSchema(); 53 | this.index = schema.index("test-index"); 54 | } 55 | 56 | @Test(expected = ValidationException.class) 57 | public void checkValidatorWasCalledTest() { 58 | Field field = this.index.field("a:b"); 59 | } 60 | 61 | @Test 62 | public void testEqualsFailsWithOtherObject() { 63 | @SuppressWarnings("EqualsBetweenInconvertibleTypes") 64 | boolean e = this.index.field("foo").equals("foo"); 65 | assertFalse(e); 66 | } 67 | 68 | @Test 69 | public void testEqualsSameObject() { 70 | Field field = this.index.field("some-field"); 71 | assertEquals(field, field); 72 | } 73 | 74 | @Test 75 | public void testHashCode() { 76 | FieldOptions options1 = FieldOptions.builder() 77 | .fieldTime(TimeQuantum.YEAR_MONTH_DAY) 78 | .build(); 79 | FieldOptions options2 = FieldOptions.builder() 80 | .fieldTime(TimeQuantum.YEAR_MONTH_DAY) 81 | .build(); 82 | Field field1 = this.index.field("field1", options1); 83 | Field field2 = this.index.field("field2", options2); 84 | assertEquals(field1.hashCode(), field2.hashCode()); 85 | } 86 | 87 | private Index index; 88 | } 89 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/FieldTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import com.pilosa.client.exceptions.ValidationException; 39 | import org.junit.Test; 40 | import org.junit.experimental.categories.Category; 41 | 42 | import static org.junit.Assert.assertEquals; 43 | 44 | @Category(UnitTest.class) 45 | public class FieldTypeTest { 46 | 47 | @Test 48 | public void testFromString() { 49 | assertEquals(FieldType.SET, FieldType.fromString("set")); 50 | assertEquals(FieldType.INT, FieldType.fromString("int")); 51 | assertEquals(FieldType.TIME, FieldType.fromString("time")); 52 | assertEquals(FieldType.MUTEX, FieldType.fromString("mutex")); 53 | assertEquals(FieldType.BOOL, FieldType.fromString("bool")); 54 | assertEquals(FieldType.DEFAULT, FieldType.fromString("")); 55 | } 56 | 57 | @Test(expected = ValidationException.class) 58 | public void testInvalidFromString() { 59 | FieldType.fromString("none"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/OptionsOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import org.junit.Test; 38 | 39 | import static org.junit.Assert.assertArrayEquals; 40 | import static org.junit.Assert.assertTrue; 41 | 42 | public class OptionsOptionsTest { 43 | @Test 44 | public void testOptions() { 45 | OptionsOptions opts = OptionsOptions.builder() 46 | .setColumnAttrs(true) 47 | .setExcludeColumns(true) 48 | .setExcludeRowAttrs(true) 49 | .setShards(5, 10) 50 | .build(); 51 | assertTrue(opts.isColumnAttrs()); 52 | assertTrue(opts.isExcludeColumns()); 53 | assertTrue(opts.isExcludeRowAttrs()); 54 | assertArrayEquals(new long[]{5, 10}, opts.getShards()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/QueryOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.QueryOptions; 38 | import com.pilosa.client.UnitTest; 39 | import org.junit.Test; 40 | import org.junit.experimental.categories.Category; 41 | 42 | import static org.junit.Assert.assertTrue; 43 | 44 | @Category(UnitTest.class) 45 | public class QueryOptionsTest { 46 | @Test 47 | public void testCreateQueryOptions() { 48 | QueryOptions options = QueryOptions.builder() 49 | .setColumnAttributes(true) 50 | .build(); 51 | assertTrue(options.isColumns()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/orm/UtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.orm; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | @Category(UnitTest.class) 42 | public class UtilTest { 43 | @Test 44 | public void createPqlTest() { 45 | // this test is required only to get 100% coverage 46 | new Util(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/status/FieldInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | @Category(UnitTest.class) 42 | public class FieldInfoTest { 43 | @Test 44 | public void testFieldMeta() { 45 | FieldMeta meta = new FieldMeta(); 46 | // setCacheType ignores the validation error 47 | meta.setCacheType("foo"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/java/com/pilosa/client/status/SchemaInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Pilosa Corp. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of the copyright holder nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 20 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32 | * DAMAGE. 33 | */ 34 | 35 | package com.pilosa.client.status; 36 | 37 | import com.pilosa.client.UnitTest; 38 | import org.junit.Test; 39 | import org.junit.experimental.categories.Category; 40 | 41 | import java.util.ArrayList; 42 | 43 | import static org.junit.Assert.assertEquals; 44 | 45 | @Category(UnitTest.class) 46 | public class SchemaInfoTest { 47 | @Test 48 | public void emptyIndexesTest() { 49 | SchemaInfo si = new SchemaInfo(); 50 | si.setIndexes(null); 51 | assertEquals(new ArrayList(), si.getIndexes()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/column_id-value.csv: -------------------------------------------------------------------------------- 1 | 10,-100 2 | 20,0 3 | 41,200 -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/column_key-value.csv: -------------------------------------------------------------------------------- 1 | ten,-100 2 | twenty,0 3 | forty-one,200 -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_bool-column_id-timestamp.csv: -------------------------------------------------------------------------------- 1 | 1,10,683793200 2 | 0,20,683793300 3 | 1,41,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_bool-column_id.csv: -------------------------------------------------------------------------------- 1 | 1,10 2 | 0,20 3 | 1,41 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_bool-column_key-timestamp.csv: -------------------------------------------------------------------------------- 1 | 1,ten,683793200 2 | 0,twenty,683793300 3 | 1,forty-one,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_bool-column_key.csv: -------------------------------------------------------------------------------- 1 | 1,ten 2 | 0,twenty 3 | 1,forty-one -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_id-column_id-custom_timestamp.csv: -------------------------------------------------------------------------------- 1 | 1,10,1991-09-02T06:33:20 2 | 5,20,1991-09-02T06:35:00 3 | 3,41,1991-09-02T06:36:25 4 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_id-column_id-timestamp.csv: -------------------------------------------------------------------------------- 1 | 1,10,683793200 2 | 5,20,683793300 3 | 3,41,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_id-column_id.csv: -------------------------------------------------------------------------------- 1 | 1,10 2 | 5,20 3 | 3,41 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_id-column_key-timestamp.csv: -------------------------------------------------------------------------------- 1 | 1,ten,683793200 2 | 5,twenty,683793300 3 | 3,forty-one,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_id-column_key.csv: -------------------------------------------------------------------------------- 1 | 1,ten 2 | 5,twenty 3 | 3,forty-one 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_key-column_id-timestamp.csv: -------------------------------------------------------------------------------- 1 | one,10,683793200 2 | five,20,683793300 3 | three,41,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_key-column_id.csv: -------------------------------------------------------------------------------- 1 | one,10 2 | five,20 3 | three,41 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_key-column_key-timestamp.csv: -------------------------------------------------------------------------------- 1 | one,ten,683793200 2 | five,twenty,683793300 3 | three,forty-one,683793385 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/row_key-column_key.csv: -------------------------------------------------------------------------------- 1 | one,ten 2 | five,twenty 3 | three,forty-one 4 | 5 | 6 | -------------------------------------------------------------------------------- /com.pilosa.client/src/test/resources/schema1.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [ 3 | { 4 | "name": "mi", 5 | "fields": [ 6 | { 7 | "name": "mf10", 8 | "options": { 9 | "type": "time", 10 | "cacheType": "lru", 11 | "cacheSize": 50000, 12 | "timeQuantum": "YMD" 13 | } 14 | } 15 | ], 16 | "options": { 17 | "keys": true 18 | } 19 | }, 20 | { 21 | "name": "mix" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /make.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM default target is test 4 | if "%1" == "" ( 5 | goto :test 6 | ) 7 | 8 | 2>NUL call :%1 9 | if errorlevel 1 ( 10 | echo Unknown target: %1 11 | ) 12 | 13 | goto :end 14 | 15 | :build 16 | mvn -f com.pilosa.client/pom.xml clean package 17 | goto :end 18 | 19 | :clean 20 | mvn -f com.pilosa.client/pom.xml clean 21 | goto :end 22 | 23 | :cover 24 | mvn -f com.pilosa.client/pom.xml clean test failsafe:integration-test jacoco:report 25 | goto :end 26 | 27 | :doc 28 | mvn -f com.pilosa.client/pom.xml javadoc:javadoc 29 | goto :end 30 | 31 | :generate 32 | echo Generating protobuf code is not supported on this platform. 33 | goto :end 34 | 35 | :test 36 | mvn -f com.pilosa.client/pom.xml test 37 | goto :end 38 | 39 | :test-all 40 | mvn -f com.pilosa.client/pom.xml test failsafe:integration-test 41 | goto :end 42 | 43 | :end 44 | --------------------------------------------------------------------------------