Search in sources :

Example 1 with RFileWriter

use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.

the class AccumuloFileOutputFormat method getRecordWriter.

@Override
public RecordWriter<Key, Value> getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress) throws IOException {
    // get the path of the temporary output file
    final Configuration conf = job;
    final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(CLASS, job);
    final String extension = acuConf.get(Property.TABLE_FILE_TYPE);
    final Path file = new Path(getWorkOutputPath(job), getUniqueName(job, "part") + "." + extension);
    final int visCacheSize = FileOutputConfigurator.getVisibilityCacheSize(conf);
    return new RecordWriter<>() {

        RFileWriter out = null;

        @Override
        public void close(Reporter reporter) throws IOException {
            if (out != null)
                out.close();
        }

        @Override
        public void write(Key key, Value value) throws IOException {
            if (out == null) {
                out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)).withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build();
                out.startDefaultLocalityGroup();
            }
            out.append(key, value);
        }
    };
}
Also used : Path(org.apache.hadoop.fs.Path) RecordWriter(org.apache.hadoop.mapred.RecordWriter) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Configuration(org.apache.hadoop.conf.Configuration) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration) Reporter(org.apache.hadoop.mapred.Reporter) RFileWriter(org.apache.accumulo.core.client.rfile.RFileWriter) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 2 with RFileWriter

use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.

the class CryptoTest method testReadNoCryptoWithCryptoConfigured.

@Test
public // This test is to ensure when Crypto is configured that it can read unencrypted files
void testReadNoCryptoWithCryptoConfigured() throws Exception {
    AccumuloConfiguration cryptoOffConf = getAccumuloConfig(ConfigMode.CRYPTO_OFF);
    AccumuloConfiguration cryptoOnConf = getAccumuloConfig(ConfigMode.CRYPTO_ON);
    FileSystem fs = FileSystem.getLocal(hadoopConf);
    ArrayList<Key> keys = testData();
    String file = "target/testFile2.rf";
    fs.delete(new Path(file), true);
    try (RFileWriter writer = RFile.newWriter().to(file).withFileSystem(fs).withTableProperties(cryptoOffConf).build()) {
        Value empty = new Value();
        writer.startDefaultLocalityGroup();
        for (Key key : keys) {
            writer.append(key, empty);
        }
    }
    Scanner iter = RFile.newScanner().from(file).withFileSystem(fs).withTableProperties(cryptoOnConf).build();
    ArrayList<Key> keysRead = new ArrayList<>();
    iter.forEach(e -> keysRead.add(e.getKey()));
    assertEquals(keys, keysRead);
}
Also used : Path(org.apache.hadoop.fs.Path) Scanner(org.apache.accumulo.core.client.Scanner) FileSystem(org.apache.hadoop.fs.FileSystem) RFileWriter(org.apache.accumulo.core.client.rfile.RFileWriter) Value(org.apache.accumulo.core.data.Value) ArrayList(java.util.ArrayList) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with RFileWriter

use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.

the class AccumuloFileOutputFormat method getRecordWriter.

@Override
public RecordWriter<Key, Value> getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress) {
    // get the path of the temporary output file
    final Configuration conf = job;
    final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(AccumuloFileOutputFormat.class, job);
    final String extension = acuConf.get(Property.TABLE_FILE_TYPE);
    final Path file = new Path(getWorkOutputPath(job), getUniqueName(job, "part") + "." + extension);
    final int visCacheSize = ConfiguratorBase.getVisibilityCacheSize(conf);
    return new RecordWriter<>() {

        RFileWriter out = null;

        @Override
        public void close(Reporter reporter) throws IOException {
            if (out != null)
                out.close();
        }

        @Override
        public void write(Key key, Value value) throws IOException {
            if (out == null) {
                out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)).withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build();
                out.startDefaultLocalityGroup();
            }
            out.append(key, value);
        }
    };
}
Also used : Path(org.apache.hadoop.fs.Path) RecordWriter(org.apache.hadoop.mapred.RecordWriter) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Reporter(org.apache.hadoop.mapred.Reporter) RFileWriter(org.apache.accumulo.core.client.rfile.RFileWriter) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 4 with RFileWriter

use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.

the class AccumuloFileOutputFormat method getRecordWriter.

@Override
public RecordWriter<Key, Value> getRecordWriter(TaskAttemptContext context) throws IOException {
    // get the path of the temporary output file
    final Configuration conf = context.getConfiguration();
    final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(AccumuloFileOutputFormat.class, context.getConfiguration());
    final String extension = acuConf.get(Property.TABLE_FILE_TYPE);
    final Path file = this.getDefaultWorkFile(context, "." + extension);
    final int visCacheSize = ConfiguratorBase.getVisibilityCacheSize(conf);
    return new RecordWriter<>() {

        RFileWriter out = null;

        @Override
        public void close(TaskAttemptContext context) throws IOException {
            if (out != null)
                out.close();
        }

        @Override
        public void write(Key key, Value value) throws IOException {
            if (out == null) {
                out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)).withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build();
                out.startDefaultLocalityGroup();
            }
            out.append(key, value);
        }
    };
}
Also used : Path(org.apache.hadoop.fs.Path) RecordWriter(org.apache.hadoop.mapreduce.RecordWriter) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Configuration(org.apache.hadoop.conf.Configuration) RFileWriter(org.apache.accumulo.core.client.rfile.RFileWriter) Value(org.apache.accumulo.core.data.Value) TaskAttemptContext(org.apache.hadoop.mapreduce.TaskAttemptContext) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 5 with RFileWriter

use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.

the class AccumuloFileOutputFormat method getRecordWriter.

@Override
public RecordWriter<Key, Value> getRecordWriter(TaskAttemptContext context) throws IOException {
    // get the path of the temporary output file
    final Configuration conf = context.getConfiguration();
    final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(CLASS, context.getConfiguration());
    final String extension = acuConf.get(Property.TABLE_FILE_TYPE);
    final Path file = this.getDefaultWorkFile(context, "." + extension);
    final int visCacheSize = FileOutputConfigurator.getVisibilityCacheSize(conf);
    return new RecordWriter<>() {

        RFileWriter out = null;

        @Override
        public void close(TaskAttemptContext context) throws IOException {
            if (out != null)
                out.close();
        }

        @Override
        public void write(Key key, Value value) throws IOException {
            if (out == null) {
                out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)).withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build();
                out.startDefaultLocalityGroup();
            }
            out.append(key, value);
        }
    };
}
Also used : Path(org.apache.hadoop.fs.Path) RecordWriter(org.apache.hadoop.mapreduce.RecordWriter) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Configuration(org.apache.hadoop.conf.Configuration) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration) RFileWriter(org.apache.accumulo.core.client.rfile.RFileWriter) Value(org.apache.accumulo.core.data.Value) TaskAttemptContext(org.apache.hadoop.mapreduce.TaskAttemptContext) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Aggregations

RFileWriter (org.apache.accumulo.core.client.rfile.RFileWriter)7 Path (org.apache.hadoop.fs.Path)7 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)6 Key (org.apache.accumulo.core.data.Key)6 Value (org.apache.accumulo.core.data.Value)6 Configuration (org.apache.hadoop.conf.Configuration)4 ArrayList (java.util.ArrayList)2 Scanner (org.apache.accumulo.core.client.Scanner)2 SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 RecordWriter (org.apache.hadoop.mapred.RecordWriter)2 Reporter (org.apache.hadoop.mapred.Reporter)2 RecordWriter (org.apache.hadoop.mapreduce.RecordWriter)2 TaskAttemptContext (org.apache.hadoop.mapreduce.TaskAttemptContext)2 Test (org.junit.jupiter.api.Test)2 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)1 Summary (org.apache.accumulo.core.client.summary.Summary)1