Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet


          {
            hs.add((float) values.getDouble(k));
          }
          break;
        case RelevanceJSONConstants.TYPENUMBER_SET_LONG:
          hs = new LongOpenHashSet();
          for (int k = 0; k < values.length(); k++)
          {
            hs.add(values.getLong(k));
          }
          break;
View Full Code Here


    }

    LOG.info("collection: " + collectionPath);
    LOG.info("index: " + indexPath);

    LongOpenHashSet deletes = null;
    if (cmdline.hasOption(DELETES_OPTION)) {
      deletes = new LongOpenHashSet();
      File deletesFile = new File(cmdline.getOptionValue(DELETES_OPTION));
      if (!deletesFile.exists()) {
        System.err.println("Error: " + deletesFile + " does not exist!");
        System.exit(-1);
      }
      LOG.info("Reading deletes from " + deletesFile);
     
      FileInputStream fin = new FileInputStream(deletesFile);
      byte[] ignoreBytes = new byte[2];
      fin.read(ignoreBytes); // "B", "Z" bytes from commandline tools
      BufferedReader br = new BufferedReader(new InputStreamReader(new CBZip2InputStream(fin)));

      String s;
      while ((s = br.readLine()) != null) {
        if (s.contains("\t")) {
          deletes.add(Long.parseLong(s.split("\t")[0]));
        } else {
          deletes.add(Long.parseLong(s));
        }
      }
      br.close();
      fin.close();
      LOG.info("Read " + deletes.size() + " tweetids from deletes file.");
    }

    long maxId = Long.MAX_VALUE;
    if (cmdline.hasOption(MAX_ID_OPTION)) {
      maxId = Long.parseLong(cmdline.getOptionValue(MAX_ID_OPTION));
      LOG.info("index: " + maxId);
    }
   
    long startTime = System.currentTimeMillis();
    File file = new File(collectionPath);
    if (!file.exists()) {
      System.err.println("Error: " + file + " does not exist!");
      System.exit(-1);
    }

    StatusStream stream = new JsonStatusCorpusReader(file);

    Directory dir = FSDirectory.open(new File(indexPath));
    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, IndexStatuses.ANALYZER);
    config.setOpenMode(OpenMode.CREATE);

    IndexWriter writer = new IndexWriter(dir, config);
    int cnt = 0;
    Status status;
    try {
      while ((status = stream.next()) != null) {
        if (status.getText() == null) {
          continue;
        }

        // Skip deletes tweetids.
        if (deletes != null && deletes.contains(status.getId())) {
          continue;
        }

        if (status.getId() > maxId) {
          continue;
View Full Code Here

    object.collectValueSpecifications(valueSpecifications);
    object.convertValueSpecifications(map.getIdentifiers(valueSpecifications));
  }

  public static void resolveIdentifiers(final IdentifierMap map, final IdentifierEncodedValueSpecifications object) {
    final LongSet identifiers = new LongOpenHashSet();
    object.collectIdentifiers(identifiers);
    object.convertIdentifiers(map.getValueSpecifications(identifiers));
  }
View Full Code Here

    BerkeleyDBIdentifierMap idSource = new BerkeleyDBIdentifierMap(dbEnvironment, fudgeContext);
    idSource.start();

    Map<String, Long> identifiers = new HashMap<String, Long>();
    LongSet seenIdentifiers = new LongOpenHashSet();
    for (int i = 0; i < 10; i++) {
      String valueName = "value-" + i;
      ValueSpecification valueSpec = getValueSpec(valueName);
      long identifier = idSource.getIdentifier(valueSpec);
      assertFalse(seenIdentifiers.contains(identifier));
      seenIdentifiers.add(identifier);
      identifiers.put(valueName, identifier);
    }

    for (int j = 0; j < 5; j++) {
      Long2ObjectMap<ValueSpecification> valueSpecs = idSource.getValueSpecifications(seenIdentifiers);
      assertEquals(seenIdentifiers.size(), valueSpecs.size());
      for (int i = 0; i < 10; i++) {
        String valueName = "value-" + i;
        ValueSpecification valueSpec = getValueSpec(valueName);
        long identifier = idSource.getIdentifier(valueSpec);
        long existingIdentifier = identifiers.get(valueName);
View Full Code Here

    }
  }

  @Test
  public void testUIDDocIdSet() throws IOException {
    LongOpenHashSet uidset = new LongOpenHashSet();
    int count = 100;
    Random rand = new Random();
    int id;
    for (int i = 0; i < count; ++i) {
      do {
        id = rand.nextInt();
      } while (id == ZoieSegmentReader.DELETED_UID || uidset.contains(id));
      uidset.add(id);
    }

    long[] uidArray = uidset.toLongArray();

    final long[] even = new long[uidArray.length / 2];
    int[] ans = new int[even.length];
    for (int i = 0; i < even.length; ++i) {
      even[i] = uidArray[i * 2];
 
View Full Code Here

  public LongSet getDelDocs() {
    return _delDocs;
  }

  public synchronized void clearDeletes() {
    _delDocs = new LongOpenHashSet();
  }
View Full Code Here

      throw new ZoieException("trying to consume to null index");
    }
    Long2ObjectMap<List<IndexingReq>> addList = new Long2ObjectOpenHashMap<List<IndexingReq>>();
    String version = idx.getVersion(); // current version

    LongSet delSet = new LongOpenHashSet();

    try {
      for (DataEvent<ZoieIndexable> evt : events) {
        if (evt == null) continue;
        version = version == null ? evt.getVersion() : (_versionComparator.compare(version,
          evt.getVersion()) < 0 ? evt.getVersion() : version);

        // interpret and get get the indexable instance
        ZoieIndexable indexable = evt.getData();
        if (indexable == null || indexable.isSkip()) continue;

        long uid = indexable.getUID();
        delSet.add(uid);
        addList.remove(uid);
        if (!(indexable.isDeleted() || evt.isDelete())) // update event
        {
          try {
            IndexingReq[] reqs = indexable.buildIndexingReqs();
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.LongOpenHashSet

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.