Search in sources :

Example 26 with BytesRef

use of org.apache.lucene.util.BytesRef in project crate by crate.

the class CopyAnalyzerTest method testCopyFromPartitionedTablePARTITIONKeywordValidArgs.

@Test
public void testCopyFromPartitionedTablePARTITIONKeywordValidArgs() throws Exception {
    CopyFromAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) from '/some/distant/file.ext'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).ident();
    assertThat(analysis.partitionIdent(), equalTo(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 27 with BytesRef

use of org.apache.lucene.util.BytesRef in project crate by crate.

the class CopyAnalyzerTest method testCopyToFileWithPartitionClause.

@Test
public void testCopyToFileWithPartitionClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) to directory '/blah'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 28 with BytesRef

use of org.apache.lucene.util.BytesRef in project crate by crate.

the class CopyAnalyzerTest method testCopyFromFileUriArray.

@Test
public void testCopyFromFileUriArray() throws Exception {
    Object[] files = $("/f1.json", "/f2.json");
    CopyFromAnalyzedStatement copyFrom = e.analyze("copy users from ?", new Object[] { files });
    assertThat(copyFrom.uri(), isLiteral($(new BytesRef("/f1.json"), new BytesRef("/f2.json")), new ArrayType(DataTypes.STRING)));
}
Also used : ArrayType(io.crate.types.ArrayType) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 29 with BytesRef

use of org.apache.lucene.util.BytesRef in project crate by crate.

the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndWhereClause.

@Test
public void testCopyToWithPartitionIdentAndWhereClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) where id = 1 to directory '/tmp/foo'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
    assertThat(querySpec.where().query(), isFunction("op_="));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 30 with BytesRef

use of org.apache.lucene.util.BytesRef in project crate by crate.

the class CopyAnalyzerTest method testCopyToWithPartitionInWhereClause.

@Test
public void testCopyToWithPartitionInWhereClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted where date = 1395874800000 to directory '/tmp/foo'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
    assertThat(analysis.overwrites().size(), is(1));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

BytesRef (org.apache.lucene.util.BytesRef)1448 Document (org.apache.lucene.document.Document)409 Directory (org.apache.lucene.store.Directory)370 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)266 ArrayList (java.util.ArrayList)186 Test (org.junit.Test)182 SortedDocValuesField (org.apache.lucene.document.SortedDocValuesField)164 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)152 Term (org.apache.lucene.index.Term)123 Analyzer (org.apache.lucene.analysis.Analyzer)121 IndexReader (org.apache.lucene.index.IndexReader)121 TermsEnum (org.apache.lucene.index.TermsEnum)116 SortedSetDocValuesField (org.apache.lucene.document.SortedSetDocValuesField)110 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)105 IOException (java.io.IOException)103 Field (org.apache.lucene.document.Field)101 StringField (org.apache.lucene.document.StringField)100 CrateUnitTest (io.crate.test.integration.CrateUnitTest)95 TextField (org.apache.lucene.document.TextField)94 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)87