List of usage examples for org.apache.lucene.store IndexOutput writeLong
public void writeLong(long i) throws IOException
From source file:com.bah.lucene.blockcache_v2.CacheDirectoryTest.java
License:Apache License
@Test public void test1() throws IOException { IndexOutput output = _cacheDirectory.createOutput("test.file", IOContext.DEFAULT); output.writeLong(0); output.writeLong(1);// w ww.j ava2 s . c o m output.writeLong(2); output.close(); IndexInput input = _cacheDirectory.openInput("test.file", IOContext.DEFAULT); assertEquals(0, input.readLong()); assertEquals(1, input.readLong()); assertEquals(2, input.readLong()); input.close(); }
From source file:com.browseengine.bobo.geosearch.solo.impl.IDGeoRecordSerializer.java
License:Apache License
@Override public void writeGeoRecord(IndexOutput output, IDGeoRecord record, int recordByteCount) throws IOException { if (record.id.length != recordByteCount - INTERLACE_BYTES) { throw new IllegalArgumentException( "Incorrect number of id bytes given. " + "This is most likely a bug! ExpectedBytes=" + (recordByteCount - INTERLACE_BYTES) + "; receivedBytes=" + record.id.length); }//from w w w.j a va2 s .com output.writeLong(record.highOrder); output.writeInt(record.lowOrder); output.writeBytes(record.id, record.id.length); }
From source file:com.github.lucene.store.jdbc.index.AbstractIndexInputOutputITest.java
License:Apache License
private void insertData() throws IOException { final byte[] test = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; final IndexOutput indexOutput = jdbcDirectory.createOutput("value1", new IOContext()); indexOutput.writeInt(-1);/*from w w w . j av a 2s . c o m*/ indexOutput.writeLong(10); indexOutput.writeInt(0); indexOutput.writeInt(0); indexOutput.writeBytes(test, 8); indexOutput.writeBytes(test, 5); indexOutput.writeByte((byte) 8); indexOutput.writeBytes(new byte[] { 1, 2 }, 2); indexOutput.close(); }
From source file:com.liferay.portal.search.lucene.dump.IndexCommitSerializationUtil.java
License:Open Source License
private static void writeSegmentsGen(Directory directory, long generation) throws IOException { if (_log.isDebugEnabled()) { _log.debug("Writing " + _SEGMENTS_GEN_FILE_NAME + " with generation " + generation); }// www . j a va2s . c om IndexOutput indexOutput = directory.createOutput(_SEGMENTS_GEN_FILE_NAME); try { indexOutput.writeInt(SegmentInfos.FORMAT_LOCKLESS); indexOutput.writeLong(generation); indexOutput.writeLong(generation); } finally { indexOutput.close(); } }
From source file:com.nearinfinity.bloomfilter.bitset.ThreadSafeBitSet.java
License:Apache License
@Override public void write(IndexOutput output) throws IOException { int length = bits.length(); output.writeInt(length);//w w w.ja va 2 s . c o m for (int i = 0; i < length; i++) { output.writeLong(bits.get(i)); } }
From source file:com.nearinfinity.bloomfilter.BloomFilter.java
License:Apache License
public void write(IndexOutput output) throws IOException { output.writeLong(numberOfBitsDivBy2); output.writeLong(elementSize);// www .j a v a 2 s. c o m output.writeLong(Double.doubleToLongBits(probabilityOfFalsePositives)); output.writeInt(hashes); output.writeInt(numberOfBits); bitSet.write(output); }
From source file:com.zimbra.cs.index.LuceneIndexRepair.java
License:Open Source License
private void commit(long gen) throws IOException { IndexOutput output = directory.createOutput(SEGMENTS_GEN); try {// w ww. j av a 2 s .c o m output.writeInt(SegmentInfos.FORMAT_LOCKLESS); output.writeLong(gen); output.writeLong(gen); } finally { output.close(); } directory.sync(Collections.singleton(SEGMENTS_GEN)); }
From source file:org.apache.blur.filter.IndexFileBitSet.java
License:Apache License
public void create(DocIdSetIterator it) throws IOException { String fileName = getFileName(); if (_directory.fileExists(getFileName())) { LOG.warn("Filter [{0}] in directory [{1}] being recreated due to incorrect size.", fileName, _directory);/*from w w w . j av a 2 s . co m*/ _directory.deleteFile(fileName); } IndexOutput output = _directory.createOutput(fileName, IOContext.READ); int index; int currentWordNum = 0; long wordValue = 0; while ((index = it.nextDoc()) < _numBits) { int wordNum = index >> 6; // div 64 if (currentWordNum > wordNum) { throw new IOException("We got a problem here!"); } while (currentWordNum < wordNum) { output.writeLong(wordValue); currentWordNum++; wordValue = 0; } int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; wordValue |= bitmask; } if (_numBits > 0) { int totalWords = (_numBits / 64) + 1; while (currentWordNum < totalWords) { output.writeLong(wordValue); currentWordNum++; wordValue = 0; } } output.close(); }
From source file:org.apache.blur.mapreduce.lib.GenericRecordReader.java
License:Apache License
private static Directory copyFilesLocally(Configuration configuration, Directory dir, String table, Path shardDir, Path localCachePath, Collection<String> files) throws IOException { LOG.info("Copying files need to local cache for faster reads [{0}].", shardDir); Path localShardPath = new Path(new Path(localCachePath, table), shardDir.getName()); HdfsDirectory localDir = new HdfsDirectory(configuration, localShardPath, null, files); for (String name : files) { if (!isValidFileToCache(name)) { continue; }/*from w ww . j a v a2 s .co m*/ LOG.info("Valid file for local copy [{0}].", name); if (!isValid(localDir, dir, name)) { LastModified lastModified = (LastModified) dir; long fileModified = lastModified.getFileModified(name); IndexInput input = dir.openInput(name, IOContext.READONCE); IndexOutput output = localDir.createOutput(name, IOContext.READONCE); output.copyBytes(input, input.length()); output.close(); IndexOutput lastMod = localDir.createOutput(name + LASTMOD, IOContext.DEFAULT); lastMod.writeLong(fileModified); lastMod.close(); } } return localDir; }
From source file:org.apache.blur.store.hdfs.HdfsDirectorySymlinkTest.java
License:Apache License
@Test public void testSymlink() throws IOException { HdfsDirectory dir1 = new HdfsDirectory(_configuration, new Path(_base, "dir1")); IndexOutput output = dir1.createOutput("file1", IOContext.DEFAULT); output.writeLong(12345); output.close();// ww w .j a va 2s.co m assertTrue(dir1.fileExists("file1")); HdfsDirectory dir2 = new HdfsDirectory(_configuration, new Path(_base, "dir2")); dir1.copy(dir2, "file1", "file2", IOContext.DEFAULT); assertTrue(dir2.fileExists("file2")); assertEquals(8, dir2.fileLength("file2")); String[] listAll = dir2.listAll(); assertEquals(1, listAll.length); assertEquals("file2", listAll[0]); IndexInput input = dir2.openInput("file2", IOContext.DEFAULT); assertEquals(12345, input.readLong()); input.close(); dir2.deleteFile("file2"); assertFalse(dir2.fileExists("file2")); assertTrue(dir1.fileExists("file1")); dir2.close(); dir1.close(); }