Package org.apache.lucene.facet.encoding

Examples of org.apache.lucene.facet.encoding.IntEncoder.encode()


      HashMap<String,BytesRef> partitionBytes = new HashMap<String,BytesRef>();
      for (Entry<String,IntsRef> e : partitionOrdinals.entrySet()) {
        String name = e.getKey();
        final IntEncoder encoder = partitionEncoder.get(name);
        final BytesRef bytes = new BytesRef(128); // should be enough for most common applications       
        encoder.encode(e.getValue(), bytes);
        partitionBytes.put(name, bytes);
      }
      return partitionBytes;
    }
   
View Full Code Here


    // cover negative numbers;
    BytesRef bytes = new BytesRef(5);
    IntEncoder enc = new VInt8IntEncoder();
    IntsRef values = new IntsRef(1);
    values.ints[values.length++] = -1;
    enc.encode(values, bytes);
   
    IntDecoder dec = enc.createMatchingDecoder();
    values.length = 0;
    dec.decode(bytes, values);
    assertEquals(1, values.length);
View Full Code Here

    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT,
        new MockAnalyzer(random(), MockTokenizer.KEYWORD, false)).setMergePolicy(newLogMergePolicy()));
    BytesRef buf = new BytesRef();
    for (int i = 0; i < data.length; i++) {
      Document doc = new Document();
      encoder.encode(IntsRef.deepCopyOf(data[i]), buf);
      doc.add(new BinaryDocValuesField("f", buf));
      writer.addDocument(doc);
    }
    IndexReader reader = writer.getReader();
    writer.close();
View Full Code Here

        newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
    for (int i = 0; i < data.length; i++) {
      Document doc = new Document();
      if (i == 0) {
        BytesRef buf = new BytesRef();
        encoder.encode(IntsRef.deepCopyOf(data[i]), buf );
        doc.add(new BinaryDocValuesField("f", buf));
      } else {
        doc.add(new BinaryDocValuesField("f", new BytesRef()));
      }
      writer.addDocument(doc);
View Full Code Here

      HashMap<String,BytesRef> partitionBytes = new HashMap<String,BytesRef>();
      for (Entry<String,IntsRef> e : partitionOrdinals.entrySet()) {
        String name = e.getKey();
        final IntEncoder encoder = partitionEncoder.get(name);
        final BytesRef bytes = new BytesRef(128); // should be enough for most common applications       
        encoder.encode(e.getValue(), bytes);
        partitionBytes.put(name, bytes);
      }
      return partitionBytes;
    }
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.