Package org.elasticsearch.common.trove.list.array

Examples of org.elasticsearch.common.trove.list.array.TIntArrayList


    TIntArrayList locations;
    List<GetResponse> responses;
    List<MultiGetResponse.Failure> failures;

    MultiGetShardResponse() {
        locations = new TIntArrayList();
        responses = new ArrayList<GetResponse>();
        failures = new ArrayList<MultiGetResponse.Failure>();
    }
View Full Code Here


        failures.add(failure);
    }

    @Override public void readFrom(StreamInput in) throws IOException {
        int size = in.readVInt();
        locations = new TIntArrayList(size);
        responses = new ArrayList<GetResponse>(size);
        failures = new ArrayList<MultiGetResponse.Failure>(size);
        for (int i = 0; i < size; i++) {
            locations.add(in.readVInt());
            if (in.readBoolean()) {
View Full Code Here

    public PortsRange(String portRange) {
        this.portRange = portRange;
    }

    public int[] ports() throws NumberFormatException {
        final TIntArrayList ports = new TIntArrayList();
        iterate(new PortCallback() {
            @Override public boolean onPortNumber(int portNumber) {
                ports.add(portNumber);
                return false;
            }
        });
        return ports.toArray(new int[ports.size()]);
    }
View Full Code Here

    }

    MultiGetShardRequest(String index, int shardId) {
        super(index);
        this.shardId = shardId;
        locations = new TIntArrayList();
        types = new ArrayList<String>();
        ids = new ArrayList<String>();
        fields = new ArrayList<String[]>();
    }
View Full Code Here

    }

    @Override public void readFrom(StreamInput in) throws IOException {
        super.readFrom(in);
        int size = in.readVInt();
        locations = new TIntArrayList(size);
        types = new ArrayList<String>(size);
        ids = new ArrayList<String>(size);
        fields = new ArrayList<String[]>(size);
        for (int i = 0; i < size; i++) {
            locations.add(in.readVInt());
View Full Code Here

         super(ordinalsNoPerDoc,STORAGE_SIZE);
      }
   }

   protected TIntArrayList collectOrdinals(MultiValueOrdinalArray a,int docId) {
      final TIntArrayList ol = new TIntArrayList();
      a.forEachOrdinalInDoc(docId, new FieldData.OrdinalInDocProc() {
         @Override
         public void onOrdinal(int docId, int ordinal) {
            ol.add(ordinal);
         }
      });
      return ol;
   }
View Full Code Here

      smallMultiValueOrdinalArray a = getSmallMultiValueOrdinalArray(ordinalsPerDoc);

      for (int doc=0;doc<ordinalsPerDoc.size();doc++) {
         assertThat(collectOrdinals(a, doc),
                 equalTo(new TIntArrayList(ordinalsPerDoc.get(doc))));
      }
   }
View Full Code Here

      MAX_STORAGE_SIZE_SHIFT = shift;

      ArrayList<int[]> storageArrays = new ArrayList<int[]>();

      TIntArrayList curStorageArray = new TIntArrayList(MAX_STORAGE_SIZE);
      int curStorageArrayIndex = 0;

      // Two things about this:
      // 1) First array must start with 1 as 0 pointer means no value.
      // 2) Always points to the next usable place
      int curOffsetWithInStorage = 1;
      curStorageArray.add(Integer.MIN_VALUE); // first place is wasted.
      int maxDoc = ordinalsNoPerDoc.length;

      firstLevel = new int[maxDoc];

      for (int curDoc = 0; curDoc < maxDoc; curDoc++) {

         int curOrdinalNoForDoc = ordinalsNoPerDoc[curDoc];

         switch (curOrdinalNoForDoc) {
            case 0:
            case 1:
               break; // nothing to do ordinals will fit in the firstLevel array
            default:


               if ((curOffsetWithInStorage + curOrdinalNoForDoc) > MAX_STORAGE_SIZE) {
                  if (curOrdinalNoForDoc > MAX_STORAGE_SIZE - 1) {
                     throw new ElasticSearchException(
                             String.format("Number of values for doc %s has a exceeded the maximum allowed " +
                                     "(got %s values, max %s)",
                                     curDoc, curOrdinalNoForDoc, MAX_STORAGE_SIZE - 1));
                  }

                  curStorageArrayIndex++;
                  logger.debug("Allocating a new storage array. {} so far.", curStorageArrayIndex);

                  storageArrays.add(curStorageArray.toArray());
                  curOffsetWithInStorage = 1; // for pointer consistency waste a slot.
                  curStorageArray.clear(MAX_STORAGE_SIZE);
                  curStorageArray.add(Integer.MIN_VALUE); // first place is wasted.
               }


               for (int i=0;i< curOrdinalNoForDoc; i++curStorageArray.add(0); // reserve space.

               firstLevel[curDoc] = -((curStorageArrayIndex << MAX_STORAGE_SIZE_SHIFT) + curOffsetWithInStorage);

               curOffsetWithInStorage += curOrdinalNoForDoc; // make space for the ordinals.
         }
      }

      // all done. populate final storage space
      this.storageArrays = new int[storageArrays.size() + 1][];
      for (int i = 0; i < storageArrays.size(); i++) {
         this.storageArrays[i] = storageArrays.get(i);
      }
      this.storageArrays[storageArrays.size()] = curStorageArray.toArray();

      logger.debug("Ordinal array loaded. {} docs, {} secondary storage arrays. Memory signature: {}KB",
              this.firstLevel.length, this.storageArrays.length, computeSizeInBytes() / 1024);
   }
View Full Code Here

        // This avoids having to read, copy and store multiple BytesRefs containing the same distinct field values.

        while(_distinctFieldIter.hasNext()) {
            // TODO this causes two conversions if the field's numeric
            final BytesRef unsafe = _distinctFieldIter.next();
            TIntArrayList timestampList = _occurrences.get(unsafe);
            if(timestampList == null) {
                final BytesRef safe = BytesRef.deepCopyOf(unsafe);
                timestampList = new TIntArrayList();
                _occurrences.put(safe, timestampList);
            }

            // To reduce memory usage, we store all timestamps at second resolution for now
            while(hasNextTimestamp()) {
                final long time = nextTimestamp();
                timestampList.add((int) (time / 1000));
            }

            // Reset timestamp iterator for this doc
            // TODO make this a standalone CollectableIterator like _distinctFieldIter
            super.collect(doc);
View Full Code Here

    @Override
    public InternalFacet build(final String facetName) {
        // This is where we invert the distinct value->timestamp map to build the actual facet object
        final ExtTLongObjectHashMap<DistinctCountPayload> counts = CacheRecycler.popLongObjectMap();
        for(final BytesRef fieldVal : _occurrences.keySet()) {
            final TIntArrayList timestampList = _occurrences.get(fieldVal);
            final int timestampCount = timestampList.size();
            for(int i = 0; i < timestampCount; i++) {
                final long timestampSecs = timestampList.get(i);
                // Convert back to milliseconds resolution
                final long timestamp = timestampSecs * 1000;
                DistinctCountPayload payload = counts.get(timestamp);
                if(payload == null) {
                    payload = new DistinctCountPayload(_exactThreshold);
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.trove.list.array.TIntArrayList

Copyright © 2018 www.massapicom. 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.