Package gnu.trove

Examples of gnu.trove.TIntArrayList


   
      TIntArrayList[] tmpArray = new TIntArrayList[2 + fieldCount];
      final int tmpNT = le.getDocumentFrequency();
      for (int i=0;i<2+fieldCount;i++)
      {
        tmpArray[i] = new TIntArrayList(tmpNT);
      }
     
      numberOfPointersThisIteration += tmpNT;
     
      tmpStorage[j] = tmpArray;
View Full Code Here


  public static int[] intersection(int[] arr1, int[] arr2) {
    TIntHashSet set = new TIntHashSet();
    set.addAll(arr1);
   
    Arrays.sort(arr2);
    TIntArrayList list = new TIntArrayList();
    for (int i : arr2) {
      if (set.contains(i)) {
        list.add(i);
      }
    }
    return list.toNativeArray();
  }
View Full Code Here

    final boolean loadTagInformation = fieldCount > 0;
    //System.err.println("Pointer: " + pointer);
    final int[][] documentTerms = new int[fieldCount+4][];
    for(int i=0;i<fieldCount+3;i++)
      documentTerms[i] = new int[df];
    final TIntArrayList blockids = new TIntArrayList(df); //ideally we'd have TF here
 
    if (loadTagInformation) { //if there are tag information to process
      documentTerms[0][0] = file.readGamma() - 1;
      documentTerms[1][0] = file.readUnary();
      for(int fi=0;fi < fieldCount;fi++)
        documentTerms[2+fi][0] = file.readUnary() -1;
      int blockfreq = documentTerms[fieldCount+2][0] = file.readUnary() - DocumentBlockCountDelta;
      int tmpBlocks[] = new int[blockfreq];
      int previousBlockId = -1;
      for(int j=0;j<blockfreq;j++)
      {
        tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
      }
      blockids.add(tmpBlocks);
     
      for (int i = 1; i < df; i++) {         
        documentTerms[0][i= file.readGamma() + documentTerms[0][i - 1];
        documentTerms[1][i= file.readUnary();
        for(int fi=0;fi < fieldCount;fi++)
          documentTerms[2+fi][i] = file.readUnary() -1;
       
        blockfreq = documentTerms[2+fieldCount][i] = file.readUnary() - DocumentBlockCountDelta;
        tmpBlocks = new int[blockfreq];
        previousBlockId = -1;
        for(int j=0;j<blockfreq;j++)
        {
          tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
        }
        blockids.add(tmpBlocks);
      }
    } else { //no tag information to process         
     
      documentTerms[0][0] = file.readGamma() - 1;
      documentTerms[1][0] = file.readUnary();
     
      int blockfreq = documentTerms[2][0] = file.readUnary() - DocumentBlockCountDelta;
      int tmpBlocks[] = new int[blockfreq];
      int previousBlockId = -1;
      for(int j=0;j<blockfreq;j++)
      {
        tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
      }
      blockids.add(tmpBlocks);
     
      for (int i = 1; i < df; i++) {         
        documentTerms[0][i= file.readGamma() + documentTerms[0][i - 1];
        documentTerms[1][i= file.readUnary();

        blockfreq = documentTerms[2][i] = file.readUnary() - DocumentBlockCountDelta;
        tmpBlocks = new int[blockfreq];
        previousBlockId = -1;
        for(int j=0;j<blockfreq;j++)
        {
          tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
        }
        blockids.add(tmpBlocks);
      }
    }
    documentTerms[documentTerms.length -1] = blockids.toNativeArray();
    return documentTerms;
  }
View Full Code Here

    final boolean loadTagInformation = fieldCount > 0;
   
    final int[][] documentTerms = new int[4+fieldCount][];
    for(int i=0;i<fieldCount+3;i++)
      documentTerms[i] = new int[df];
    final TIntArrayList blockids = new TIntArrayList(df); //ideally we'd have TF here

    try{
      final BitIn file = this.file[pointer.getFileNumber()].readReset(startOffset, startBitOffset);
 
      if (loadTagInformation) { //if there are tag information to process
        //documentTerms[2] = new int[df];
        documentTerms[0][0] = file.readGamma() - 1;       
        documentTerms[1][0] = file.readUnary();
        for(int fi=0;fi < fieldCount;fi++)
          documentTerms[2+fi][0] = file.readUnary() -1;
        int blockfreq = documentTerms[2+fieldCount][0] = file.readUnary() - DocumentBlockCountDelta;
        int tmpBlocks[] = new int[blockfreq];
        int previousBlockId = -1;
        for(int j=0;j<blockfreq;j++)
        {
          tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
        }
        blockids.add(tmpBlocks);
       
        for (int i = 1; i < df; i++) {         
          documentTerms[0][i= file.readGamma() + documentTerms[0][i - 1];
          documentTerms[1][i= file.readUnary();
          for(int fi=0;fi < fieldCount;fi++)
            documentTerms[2+fi][0] = file.readUnary() -1;
          blockfreq = documentTerms[2+fieldCount][i] = file.readUnary() - DocumentBlockCountDelta;
          tmpBlocks = new int[blockfreq];
          previousBlockId = -1;
          for(int j=0;j<blockfreq;j++)
          {
            tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
          }
          blockids.add(tmpBlocks);
        }
      } else { //no tag information to process         
       
        documentTerms[0][0] = file.readGamma() - 1;
        documentTerms[1][0] = file.readUnary();
       
        int blockfreq = documentTerms[2][0] = file.readUnary() - DocumentBlockCountDelta;
        int tmpBlocks[] = new int[blockfreq];
        int previousBlockId = -1;
        for(int j=0;j<blockfreq;j++)
        {
          tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
        }
        blockids.add(tmpBlocks);
       
        for (int i = 1; i < df; i++) {         
          documentTerms[0][i= file.readGamma() + documentTerms[0][i - 1];
          documentTerms[1][i= file.readUnary();

          blockfreq = documentTerms[2][i] = file.readUnary() - DocumentBlockCountDelta;
          tmpBlocks = new int[blockfreq];
          previousBlockId = -1;
          for(int j=0;j<blockfreq;j++)
          {
            tmpBlocks[j] = previousBlockId = file.readGamma() + previousBlockId;
          }
          blockids.add(tmpBlocks);
        }
      }
      documentTerms[documentTerms.length-1] = blockids.toNativeArray();
      return documentTerms;
    } catch (IOException ioe) {
      logger.error("Problem reading block inverted index", ioe);
      return null;
    }
View Full Code Here

    byte[] bytes;
    long byteOffset;
    byte bitOffset;
   
    @Before public void writeOut() throws IOException {
      TIntArrayList ids = new TIntArrayList();
      BufferedReader br = Files.openFileReader("/users/craigm/src/tr3/linksList");
      String line = null;
     
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      NullOutputStream nos = new NullOutputStream();
      BitOutputStream bo_null = new BitOutputStream(nos);
      DirectInvertedDocidOnlyOuptutStream dios = new DirectInvertedDocidOnlyOuptutStream(bo_null);
      BitOutputStream bo = new BitOutputStream(baos);
      if (initial_bitoffset > 0)
        bo.writeBinary(initial_bitoffset, 0);
      int docid = 0;
      while((line = br.readLine())!= null)
      {
        String[] parts = line.split("\\s+");
        for(String p : parts)
          ids.add(Integer.parseInt(p));
        int[] _tmp = ids.toNativeArray();
        byteOffset = bo.getByteOffset();
        bitOffset = bo.getBitOffset();
        BitFilePosition bp = new FilePosition(byteOffset, bitOffset);
        startOffsets.add(bp);
        //System.err.println(_tmp.length + "@{"+byteOffset+","+bitOffset+"}");
       
        List<Posting> postingList = new ArrayList<Posting>();
        IterablePosting ip = new ArrayOfIdsIterablePosting(_tmp);
        while(ip.next() != IterablePosting.EOL)
        {
          postingList.add(ip.asWritablePosting());
        }
        BitIndexPointer diosPointer = dios.writePostings(postingList.iterator());
       
        IDS.add(_tmp);
        ids.clear();
        int previous = -1;
        for(int i : _tmp)
        {
          bo.writeGamma(i - previous);
          previous = i;
View Full Code Here

public class SparseVector {
  TIntArrayList indices;
  TDoubleArrayList values;

  public SparseVector() {
    indices = new TIntArrayList();
    values = new TDoubleArrayList();
  }
View Full Code Here

   */
  public static void mergeSortedArrays(TIntArrayList x1,
                                       TIntArrayList y1,
                                       TIntArrayList x2,
                                       TIntArrayList y2) {
    TIntArrayList newX = new TIntArrayList();
    TIntArrayList newY = new TIntArrayList();

    int i = 0;
    int j = 0;

    while (i < x1.size() && j < x2.size()) {
      if (x1.get(i) < x2.get(j) || (x1.get(i) == x2.get(j) && y1.get(i) < y2.get(j))) {
        newX.add(x1.get(i));
        newY.add(y1.get(i));
        i++;
      }
      else if (x1.get(i) > x2.get(j) || (x1.get(i) == x2.get(j) && y1.get(i) > y2.get(j))) {
        newX.add(x2.get(j));
        newY.add(y2.get(j));
        j++;
      }
      else { //equals
        newX.add(x1.get(i));
        newY.add(y1.get(i));
        i++;
        j++;
      }
    }

    while (i < x1.size()) {
      newX.add(x1.get(i));
      newY.add(y1.get(i));
      i++;
    }

    while (j < x2.size()) {
      newX.add(x2.get(j));
      newY.add(y2.get(j));
      j++;
    }

    x1.clear();
    y1.clear();
    x1.add(newX.toNativeArray());
    y1.add(newY.toNativeArray());
  }
View Full Code Here

      myFreeRecordsList = scanForFreeRecords();
    }
  }

  private TIntArrayList scanForFreeRecords() throws IOException {
    final TIntArrayList result = new TIntArrayList();
    for (int i = 1; i <= getRecordsCount(); i++) {
      if (getSize(i) == -1) {
        result.add(i);
      }
    }
    return result;
  }
View Full Code Here

  }

  private int[] discard(int[] needed, int[] toDiscard, int arrayIndex) {
    myOriginalLengths[arrayIndex] = toDiscard.length;
    int[] sorted1 = createSorted(needed);
    TIntArrayList discarded = new TIntArrayList(toDiscard.length);
    TIntArrayList oldIndecies = new TIntArrayList(toDiscard.length);
    for (int i = 0; i < toDiscard.length; i++) {
      int index = toDiscard[i];
      if (Arrays.binarySearch(sorted1, index) >= 0) {
        discarded.add(index);
        oldIndecies.add(i);
      }
    }
    myOldIndecies[arrayIndex] = oldIndecies.toNativeArray();
    return discarded.toNativeArray();
  }
View Full Code Here

  private void build_T() {
    if (myTBuilt) return;

    myInvT = (Node[])new Object[myGraph.getNodes().size()];
    mySCCs = new TIntArrayList ();

    int size = myGraph.getNodes().size();

    myNodeToTNumber = new LinkedHashMap<Node, Integer>(size);
View Full Code Here

TOP

Related Classes of gnu.trove.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.