Java 类org.apache.hadoop.io.SequenceFile.Metadata 实例源码

项目:hadoop-oss    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop-oss    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
@Test
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hadoop    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:aliyun-oss-hadoop-fs    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:aliyun-oss-hadoop-fs    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
@Test
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:big-c    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:big-c    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hadoop-plus    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop-plus    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hops    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hops    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
@Test
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(GenericTestUtils.getTempPath(
      "recursiveCreateDir")), "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:openimaj    文件:SequenceFileUtility.java   
@SuppressWarnings("unchecked")
private Writer createWriter(Map<String, String> metadata) throws IOException {
    final Metadata md = new Metadata();

    for (final Entry<String, String> e : metadata.entrySet()) {
        md.set(new Text(e.getKey()), new Text(e.getValue()));
    }
    final Class<K> keyClass = (Class<K>) ((ParameterizedType) getClass().getGenericSuperclass())
            .getActualTypeArguments()[0];
    final Class<V> valueClass = (Class<V>) ((ParameterizedType) getClass().getGenericSuperclass())
            .getActualTypeArguments()[1];

    return SequenceFile.createWriter(fileSystem, config, sequenceFilePath, keyClass, valueClass, compressionType,
            new DefaultCodec(), null,
            md);
}
项目:openimaj    文件:MetadataConfiguration.java   
/**
 * Read any metadata stored in the {@link Configuration}.
 *
 * @param conf
 *            the configuration
 * @return the metadata map
 */
public static Metadata getMetadata(Configuration conf) {
    final Metadata metadata = new Metadata();

    final String[] keys = conf.getStrings(META_KEYS);

    if (keys != null) {
        for (final String key : keys) {
            final String value = conf.get(META_PREFIX + key);

            if (value != null)
                metadata.set(new Text(key), new Text(value));
        }
    }

    return metadata;
}
项目:hadoop-TCP    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop-TCP    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hardfs    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hardfs    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hadoop-on-lustre2    文件:TestSequenceFile.java   
private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, 
                                      CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(file, true);
  LOG.info("creating " + count + " records with metadata and with " + compressionType +
           " compression");
  SequenceFile.Writer writer = 
    SequenceFile.createWriter(fs, conf, file, 
                              RandomDatum.class, RandomDatum.class, compressionType, codec, null, metadata);
  RandomDatum.Generator generator = new RandomDatum.Generator(seed);
  for (int i = 0; i < count; i++) {
    generator.next();
    RandomDatum key = generator.getKey();
    RandomDatum value = generator.getValue();

    writer.append(key, value);
  }
  writer.close();
}
项目:hadoop-on-lustre2    文件:TestSequenceFile.java   
public void testRecursiveSeqFileCreate() throws IOException {
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "recursiveCreateDir") , "file");
  boolean createParent = false;

  try {
    SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
        RandomDatum.class, 512, (short) 1, 4096, createParent,
        CompressionType.NONE, null, new Metadata());
    fail("Expected an IOException due to missing parent");
  } catch (IOException ioe) {
    // Expected
  }

  createParent = true;
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, createParent,
      CompressionType.NONE, null, new Metadata());
  // should succeed, fails if exception thrown
}
项目:hadoop-oss    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
  throws IOException {
  LOG.info("reading file: " + file.toString());
  SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
  SequenceFile.Metadata meta = reader.getMetadata(); 
  reader.close();
  return meta;
}
项目:hadoop-oss    文件:TestSequenceFile.java   
private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(sortedFile, true);
  LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
  final WritableComparator comparator = WritableComparator.get(RandomDatum.class);
  SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, RandomDatum.class, RandomDatum.class, conf, metadata);
  sorter.sort(new Path[] { unsortedFile }, sortedFile, false);
}
项目:hadoop-oss    文件:TestSequenceFile.java   
/**
 * Test that makes sure createWriter succeeds on a file that was 
 * already created
 * @throws IOException
 */
@SuppressWarnings("deprecation")
@Test
public void testCreateWriterOnExistingFile() throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "createWriterOnExistingFile") , "file");

  fs.create(name);
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, false,
      CompressionType.NONE, null, new Metadata());
}
项目:hadoop    文件:TestSequenceFile.java   
private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
  throws IOException {
  LOG.info("reading file: " + file.toString());
  SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
  SequenceFile.Metadata meta = reader.getMetadata(); 
  reader.close();
  return meta;
}
项目:hadoop    文件:TestSequenceFile.java   
private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(sortedFile, true);
  LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
  final WritableComparator comparator = WritableComparator.get(RandomDatum.class);
  SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, RandomDatum.class, RandomDatum.class, conf, metadata);
  sorter.sort(new Path[] { unsortedFile }, sortedFile, false);
}
项目:hadoop    文件:TestSequenceFile.java   
/**
 * Test that makes sure createWriter succeeds on a file that was 
 * already created
 * @throws IOException
 */
public void testCreateWriterOnExistingFile() throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "createWriterOnExistingFile") , "file");

  fs.create(name);
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, false,
      CompressionType.NONE, null, new Metadata());
}
项目:ditb    文件:SequenceFileLogReader.java   
/**
 * Call this method after init() has been executed
 * @return whether WAL compression is enabled
 */
static boolean isWALCompressionEnabled(final Metadata metadata) {
  // Check version is >= VERSION?
  Text txt = metadata.get(WAL_VERSION_KEY);
  if (txt == null || Integer.parseInt(txt.toString()) < COMPRESSION_VERSION) {
    return false;
  }
  // Now check that compression type is present.  Currently only one value.
  txt = metadata.get(WAL_COMPRESSION_TYPE_KEY);
  return txt != null && txt.equals(DICTIONARY_COMPRESSION_TYPE);
}
项目:ditb    文件:SequenceFileLogWriter.java   
/**
 * Create sequence file Metadata for our WAL file with version and compression
 * type (if any).
 * @param conf
 * @param compress
 * @return Metadata instance.
 */
private static Metadata createMetadata(final Configuration conf,
    final boolean compress) {
  TreeMap<Text, Text> metaMap = new TreeMap<Text, Text>();
  metaMap.put(WAL_VERSION_KEY, new Text("1"));
  if (compress) {
    // Currently we only do one compression type.
    metaMap.put(WAL_COMPRESSION_TYPE_KEY, DICTIONARY_COMPRESSION_TYPE);
  }
  return new Metadata(metaMap);
}
项目:aliyun-oss-hadoop-fs    文件:TestSequenceFile.java   
@SuppressWarnings("deprecation")
private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
  throws IOException {
  LOG.info("reading file: " + file.toString());
  SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
  SequenceFile.Metadata meta = reader.getMetadata(); 
  reader.close();
  return meta;
}
项目:aliyun-oss-hadoop-fs    文件:TestSequenceFile.java   
private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(sortedFile, true);
  LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
  final WritableComparator comparator = WritableComparator.get(RandomDatum.class);
  SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, RandomDatum.class, RandomDatum.class, conf, metadata);
  sorter.sort(new Path[] { unsortedFile }, sortedFile, false);
}
项目:aliyun-oss-hadoop-fs    文件:TestSequenceFile.java   
/**
 * Test that makes sure createWriter succeeds on a file that was 
 * already created
 * @throws IOException
 */
@SuppressWarnings("deprecation")
@Test
public void testCreateWriterOnExistingFile() throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "createWriterOnExistingFile") , "file");

  fs.create(name);
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, false,
      CompressionType.NONE, null, new Metadata());
}
项目:big-c    文件:TestSequenceFile.java   
private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
  throws IOException {
  LOG.info("reading file: " + file.toString());
  SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
  SequenceFile.Metadata meta = reader.getMetadata(); 
  reader.close();
  return meta;
}
项目:big-c    文件:TestSequenceFile.java   
private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(sortedFile, true);
  LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
  final WritableComparator comparator = WritableComparator.get(RandomDatum.class);
  SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, RandomDatum.class, RandomDatum.class, conf, metadata);
  sorter.sort(new Path[] { unsortedFile }, sortedFile, false);
}
项目:big-c    文件:TestSequenceFile.java   
/**
 * Test that makes sure createWriter succeeds on a file that was 
 * already created
 * @throws IOException
 */
public void testCreateWriterOnExistingFile() throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.getLocal(conf);
  Path name = new Path(new Path(System.getProperty("test.build.data","."),
      "createWriterOnExistingFile") , "file");

  fs.create(name);
  SequenceFile.createWriter(fs, conf, name, RandomDatum.class,
      RandomDatum.class, 512, (short) 1, 4096, false,
      CompressionType.NONE, null, new Metadata());
}
项目:LCIndex-HBase-0.94.16    文件:SequenceFileLogWriter.java   
/**
 * Create sequence file Metadata for our WAL file with version and compression
 * type (if any).
 * @param conf
 * @param compress
 * @return Metadata instance.
 */
private static Metadata createMetadata(final Configuration conf,
    final boolean compress) {
  TreeMap<Text, Text> metaMap = new TreeMap<Text, Text>();
  metaMap.put(WAL_VERSION_KEY, WAL_VERSION);
  if (compress) {
    // Currently we only do one compression type.
    metaMap.put(WAL_COMPRESSION_TYPE_KEY, DICTIONARY_COMPRESSION_TYPE);
  }
  return new Metadata(metaMap);
}
项目:LCIndex-HBase-0.94.16    文件:SequenceFileLogWriter.java   
/**
 * Call this method after init() has been executed
 * 
 * @return whether WAL compression is enabled
 */
static boolean isWALCompressionEnabled(final Metadata metadata) {
  // Check version is >= VERSION?
  Text txt = metadata.get(WAL_VERSION_KEY);
  if (txt == null || Integer.parseInt(txt.toString()) < COMPRESSION_VERSION) {
    return false;
  }
  // Now check that compression type is present.  Currently only one value.
  txt = metadata.get(WAL_COMPRESSION_TYPE_KEY);
  return txt != null && txt.equals(DICTIONARY_COMPRESSION_TYPE);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSequenceFile.java   
private SequenceFile.Metadata readMetadata(FileSystem fs, Path file)
  throws IOException {
  LOG.info("reading file: " + file.toString());
  SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, conf);
  SequenceFile.Metadata meta = reader.getMetadata(); 
  reader.close();
  return meta;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSequenceFile.java   
private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, SequenceFile.Metadata metadata)
  throws IOException {
  fs.delete(sortedFile, true);
  LOG.info("sorting: " + unsortedFile + " to: " + sortedFile);
  final WritableComparator comparator = WritableComparator.get(RandomDatum.class);
  SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, comparator, RandomDatum.class, RandomDatum.class, conf, metadata);
  sorter.sort(new Path[] { unsortedFile }, sortedFile, false);
}