Search in sources :

Example 6 with CharSource

use of com.google.common.io.CharSource in project druid by druid-io.

the class MultiSegmentSelectQueryTest method setup.

@BeforeClass
public static void setup() throws IOException {
    CharSource v_0112 = CharSource.wrap(StringUtils.join(V_0112, "\n"));
    CharSource v_0113 = CharSource.wrap(StringUtils.join(V_0113, "\n"));
    CharSource v_override = CharSource.wrap(StringUtils.join(V_OVERRIDE, "\n"));
    IncrementalIndex index0 = TestIndex.loadIncrementalIndex(newIndex("2011-01-12T00:00:00.000Z"), v_0112);
    IncrementalIndex index1 = TestIndex.loadIncrementalIndex(newIndex("2011-01-13T00:00:00.000Z"), v_0113);
    IncrementalIndex index2 = TestIndex.loadIncrementalIndex(newIndex("2011-01-12T04:00:00.000Z"), v_override);
    segment0 = new IncrementalIndexSegment(index0, makeIdentifier(index0, "v1"));
    segment1 = new IncrementalIndexSegment(index1, makeIdentifier(index1, "v1"));
    segment_override = new IncrementalIndexSegment(index2, makeIdentifier(index2, "v2"));
    VersionedIntervalTimeline<String, Segment> timeline = new VersionedIntervalTimeline(StringComparators.LEXICOGRAPHIC);
    timeline.add(index0.getInterval(), "v1", new SingleElementPartitionChunk(segment0));
    timeline.add(index1.getInterval(), "v1", new SingleElementPartitionChunk(segment1));
    timeline.add(index2.getInterval(), "v2", new SingleElementPartitionChunk(segment_override));
    segmentIdentifiers = Lists.newArrayList();
    for (TimelineObjectHolder<String, ?> holder : timeline.lookup(new Interval("2011-01-12/2011-01-14"))) {
        segmentIdentifiers.add(makeIdentifier(holder.getInterval(), holder.getVersion()));
    }
    runner = QueryRunnerTestHelper.makeFilteringQueryRunner(timeline, factory);
}
Also used : CharSource(com.google.common.io.CharSource) IncrementalIndex(io.druid.segment.incremental.IncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) VersionedIntervalTimeline(io.druid.timeline.VersionedIntervalTimeline) DataSegment(io.druid.timeline.DataSegment) Segment(io.druid.segment.Segment) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) SingleElementPartitionChunk(io.druid.timeline.partition.SingleElementPartitionChunk) Interval(org.joda.time.Interval) BeforeClass(org.junit.BeforeClass)

Example 7 with CharSource

use of com.google.common.io.CharSource in project druid by druid-io.

the class TimeBoundaryQueryRunnerTest method getCustomRunner.

private QueryRunner getCustomRunner() throws IOException {
    CharSource v_0112 = CharSource.wrap(StringUtils.join(V_0112, "\n"));
    CharSource v_0113 = CharSource.wrap(StringUtils.join(V_0113, "\n"));
    IncrementalIndex index0 = TestIndex.loadIncrementalIndex(newIndex("2011-01-12T00:00:00.000Z"), v_0112);
    IncrementalIndex index1 = TestIndex.loadIncrementalIndex(newIndex("2011-01-14T00:00:00.000Z"), v_0113);
    segment0 = new IncrementalIndexSegment(index0, makeIdentifier(index0, "v1"));
    segment1 = new IncrementalIndexSegment(index1, makeIdentifier(index1, "v1"));
    VersionedIntervalTimeline<String, Segment> timeline = new VersionedIntervalTimeline(StringComparators.LEXICOGRAPHIC);
    timeline.add(index0.getInterval(), "v1", new SingleElementPartitionChunk(segment0));
    timeline.add(index1.getInterval(), "v1", new SingleElementPartitionChunk(segment1));
    segmentIdentifiers = Lists.newArrayList();
    for (TimelineObjectHolder<String, ?> holder : timeline.lookup(new Interval("2011-01-12/2011-01-17"))) {
        segmentIdentifiers.add(makeIdentifier(holder.getInterval(), holder.getVersion()));
    }
    return QueryRunnerTestHelper.makeFilteringQueryRunner(timeline, factory);
}
Also used : CharSource(com.google.common.io.CharSource) IncrementalIndex(io.druid.segment.incremental.IncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) VersionedIntervalTimeline(io.druid.timeline.VersionedIntervalTimeline) DataSegment(io.druid.timeline.DataSegment) Segment(io.druid.segment.Segment) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) SingleElementPartitionChunk(io.druid.timeline.partition.SingleElementPartitionChunk) Interval(org.joda.time.Interval)

Example 8 with CharSource

use of com.google.common.io.CharSource in project druid by druid-io.

the class TestIndex method makeRealtimeIndex.

public static IncrementalIndex makeRealtimeIndex(final String resourceFilename, boolean rollup) {
    final URL resource = TestIndex.class.getClassLoader().getResource(resourceFilename);
    if (resource == null) {
        throw new IllegalArgumentException("cannot find resource " + resourceFilename);
    }
    log.info("Realtime loading index file[%s]", resource);
    CharSource stream = Resources.asByteSource(resource).asCharSource(Charsets.UTF_8);
    return makeRealtimeIndex(stream, rollup);
}
Also used : CharSource(com.google.common.io.CharSource) URL(java.net.URL)

Example 9 with CharSource

use of com.google.common.io.CharSource in project MinecraftForge by MinecraftForge.

the class FMLDeobfuscatingRemapper method setupLoadOnly.

public void setupLoadOnly(String deobfFileName, boolean loadAll) {
    try {
        File mapData = new File(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String, String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList) {
            String[] parts = Iterables.toArray(splitter.split(line), String.class);
            String typ = parts[0];
            if ("CL".equals(typ)) {
                parseClass(builder, parts);
            } else if ("MD".equals(typ) && loadAll) {
                parseMethod(parts);
            } else if ("FD".equals(typ) && loadAll) {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    } catch (IOException ioe) {
        FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
Also used : CharSource(com.google.common.io.CharSource) Splitter(com.google.common.base.Splitter) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 10 with CharSource

use of com.google.common.io.CharSource in project commons by twitter.

the class Configuration method load.

/**
   * Loads the {@literal @CmdLine} argument configuration data stored in the classpath.
   *
   * @return The {@literal @CmdLine} argument configuration materialized from the classpath.
   * @throws ConfigurationException if any configuration data is malformed.
   * @throws IOException if the configuration data can not be read from the classpath.
   */
public static Configuration load() throws ConfigurationException, IOException {
    Map<String, URL> resources = getLiveResources();
    if (resources.isEmpty()) {
        LOG.fine("No @CmdLine arg resources found on the classpath");
    } else {
        LOG.fine("Loading @CmdLine config for: " + resources.keySet());
    }
    CharSource input = CharSource.concat(Iterables.transform(resources.values(), URL_TO_READER));
    return input.readLines(new ConfigurationParser());
}
Also used : CharSource(com.google.common.io.CharSource) URL(java.net.URL)

Aggregations

CharSource (com.google.common.io.CharSource)13 IncrementalIndex (io.druid.segment.incremental.IncrementalIndex)5 IncrementalIndexSegment (io.druid.segment.IncrementalIndexSegment)4 OnheapIncrementalIndex (io.druid.segment.incremental.OnheapIncrementalIndex)4 File (java.io.File)4 IOException (java.io.IOException)3 Splitter (com.google.common.base.Splitter)2 StringInputRowParser (io.druid.data.input.impl.StringInputRowParser)2 Segment (io.druid.segment.Segment)2 DataSegment (io.druid.timeline.DataSegment)2 VersionedIntervalTimeline (io.druid.timeline.VersionedIntervalTimeline)2 SingleElementPartitionChunk (io.druid.timeline.partition.SingleElementPartitionChunk)2 FileInputStream (java.io.FileInputStream)2 URL (java.net.URL)2 Interval (org.joda.time.Interval)2 BeforeClass (org.junit.BeforeClass)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Injector (com.google.inject.Injector)1 DelimitedParseSpec (io.druid.data.input.impl.DelimitedParseSpec)1 DimensionsSpec (io.druid.data.input.impl.DimensionsSpec)1