/** * for an immutable index, use a normal collection statistics, never changes */ protected void loadStatistics() { // calculate fields int fieldCount = 0; if (this.hasIndexStructure("inverted")) { fieldCount = Integer.parseInt(properties.getProperty( "index.inverted.fields.count", "0")); } else if (this.hasIndexStructure("direct")) { fieldCount = Integer.parseInt(properties.getProperty( "index.direct.fields.count", "0")); } final long[] tokensF = new long[fieldCount]; for (int fi = 0; fi < fieldCount; fi++) { tokensF[fi] = Long.parseLong(properties.getProperty("num.field." + fi + ".Tokens", "0")); } // create collection statistics structureCache.put( "collectionstatistics", new CollectionStatistics(Integer.parseInt(properties .getProperty("num.Documents", "0")), Integer .parseInt(properties.getProperty("num.Terms", "0")), Long.parseLong(properties .getProperty("num.Tokens", "0")), Long .parseLong(properties.getProperty( "num.Pointers", "0")), tokensF)); }
/** * for an immutable index, use a normal collection statistics, never changes */ protected void loadStatistics() { // calculate fields int fieldCount = 0; if (this.hasIndexStructure("inverted")) { fieldCount = Integer.parseInt(properties.getProperty( "index.inverted.fields.count", "0")); } else if (this.hasIndexStructure("direct")) { fieldCount = Integer.parseInt(properties.getProperty( "index.direct.fields.count", "0")); } final long[] tokensF = new long[fieldCount]; for (int fi = 0; fi < fieldCount; fi++) { tokensF[fi] = Long.parseLong(properties.getProperty("num.field." + fi + ".Tokens", "0")); } // create collection statistics structureCache.put( "collectionstatistics", new CollectionStatistics(Integer.parseInt(properties .getProperty("num.Documents", "0")), Integer .parseInt(properties.getProperty("num.Terms", "0")), Long.parseLong(properties .getProperty("num.Tokens", "0")), Long .parseLong(properties.getProperty( "num.Pointers", "0")), tokensF)); }
@Override public void setCollectionStatistics(CollectionStatistics _cs) { super.setCollectionStatistics(_cs); int fieldCount = _cs.getNumberOfFields(); if (fieldCount < 1) throw new IllegalStateException("Fields must be 1 or more"); long tokens = 0; final long[] tokensf = _cs.getFieldTokens(); for(int fieldId : activeFieldIds) { tokens += tokensf[fieldId]; } super.numberOfTokens = tokens; super.averageDocumentLength = (double)tokens / (double)_cs.getNumberOfDocuments(); basicModel.setCollectionStatistics( new CollectionStatistics(_cs.getNumberOfDocuments(), _cs.getNumberOfUniqueTerms(), tokens, _cs.getNumberOfPointers(), new long[0])); }
@Override public void setCollectionStatistics(CollectionStatistics _cs) { super.setCollectionStatistics(_cs); int fieldCount = _cs.getNumberOfFields(); if (fieldCount < 1) throw new IllegalStateException("Fields must be 1 or more"); long tokens = 0; final long[] tokensf = _cs.getFieldTokens(); for(int fieldId : activeFieldIds) { tokens += tokensf[fieldId]; } super.numberOfTokens = tokens; super.averageDocumentLength = (double)tokens / (double)_cs.getNumberOfDocuments(); basicModel.setCollectionStatistics( new CollectionStatistics(_cs.getNumberOfDocuments(), _cs.getNumberOfUniqueTerms(), tokens, _cs.getNumberOfPointers(), new long[0])); }
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
CollectionStatistics collStats = new CollectionStatistics(); collStats.readFields(in); frs.setCollectionStatistics(collStats);
@Test public void testWritable() throws Exception { CollectionStatistics cs1 = new CollectionStatistics(5, 6, 7, 8, new long[]{2}); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); cs1.write(dos); dos.flush(); final byte[] bytes = baos.toByteArray(); assertTrue(bytes.length > 0); CollectionStatistics cs2 = new CollectionStatistics(); cs2.readFields(new DataInputStream(new ByteArrayInputStream(bytes))); assertEquals(cs1.getNumberOfDocuments(), cs2.getNumberOfDocuments()); assertEquals(cs1.getNumberOfUniqueTerms(), cs2.getNumberOfUniqueTerms()); assertEquals(cs1.getNumberOfPointers(), cs2.getNumberOfPointers()); assertEquals(cs1.getNumberOfTokens(), cs2.getNumberOfTokens()); assertEquals(cs1.getAverageDocumentLength(), cs2.getAverageDocumentLength(), 0.0d); //TODO: test fields }
IndexUtil.forceStructure(index, "collectionstatistics", new CollectionStatistics(numdocs, 50, 20000, 100, new long[0]));
final FatCandidateResultSet input = new FatCandidateResultSet( l, new CollectionStatistics(5, 5, 5, 5, new long[0]), new String[]{"a"}, new EntryStatistics[]{new BasicLexiconEntry(5, 20, 25)},