Changeset 31194 for other-projects/hathitrust/wcsa
- Timestamp:
- 2016-12-12T09:51:07+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/WhitelistBloomFilter.java
r31175 r31194 2 2 3 3 import java.io.BufferedInputStream; 4 import java.io.BufferedOutputStream; 4 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 7 import java.io.FileOutputStream; 5 8 import java.io.IOException; 6 9 import java.io.InputStream; 10 import java.io.OutputStream; 7 11 import java.nio.charset.StandardCharsets; 8 12 import java.nio.file.Files; … … 90 94 return _bloomFilter.mightContain(key); 91 95 } 96 97 public void serializeOut(String filename) 98 { 99 try { 100 FileOutputStream fos = new FileOutputStream(filename); 101 102 BufferedOutputStream bfos = new BufferedOutputStream(fos); 103 104 _bloomFilter.writeTo(bfos); 105 106 bfos.close(); 107 } 108 catch (FileNotFoundException e) { 109 System.err.println("Unable to open Bloom file:" + filename); 110 e.printStackTrace(); 111 } catch (IOException e) { 112 System.err.println("Error reading in Bloom file:" + filename); 113 e.printStackTrace(); 114 } 115 } 116 117 public void serializeIn(String filename) 118 { 119 try { 120 FileInputStream fis = new FileInputStream(filename); 121 122 BufferedInputStream bfis = new BufferedInputStream(fis); 123 124 Funnel<CharSequence> string_funnel = Funnels.stringFunnel(StandardCharsets.UTF_8); 125 _bloomFilter = BloomFilter.readFrom(bfis,string_funnel); 126 127 bfis.close(); 128 } 129 catch (FileNotFoundException e) { 130 System.err.println("Unable to open Bloom file:" + filename); 131 e.printStackTrace(); 132 } catch (IOException e) { 133 System.err.println("Error writing out Bloom file:" + filename); 134 e.printStackTrace(); 135 } 136 } 137 138 92 139 }
Note:
See TracChangeset
for help on using the changeset viewer.