Example usage for java.util BitSet BitSet

List of usage examples for java.util BitSet BitSet

Introduction

In this page you can find the example usage for java.util BitSet BitSet.

Prototype

private BitSet(long[] words) 

Source Link

Document

Creates a bit set using words as the internal representation.

Usage

From source file:org.apache.hadoop.hbase.security.visibility.DefaultVisibilityLabelServiceImpl.java

@Override
public VisibilityExpEvaluator getVisibilityExpEvaluator(Authorizations authorizations) throws IOException {
    // If a super user issues a get/scan, he should be able to scan the cells
    // irrespective of the Visibility labels
    if (isReadFromSystemAuthUser()) {
        return new VisibilityExpEvaluator() {
            @Override//  w  w  w.  j  a  v  a 2  s.c o  m
            public boolean evaluate(Cell cell) throws IOException {
                return true;
            }
        };
    }
    List<String> authLabels = null;
    for (ScanLabelGenerator scanLabelGenerator : scanLabelGenerators) {
        try {
            // null authorizations to be handled inside SLG impl.
            authLabels = scanLabelGenerator.getLabels(VisibilityUtils.getActiveUser(), authorizations);
            authLabels = (authLabels == null) ? new ArrayList<String>() : authLabels;
            authorizations = new Authorizations(authLabels);
        } catch (Throwable t) {
            LOG.error(t);
            throw new IOException(t);
        }
    }
    int labelsCount = this.labelsCache.getLabelsCount();
    final BitSet bs = new BitSet(labelsCount + 1); // ordinal is index 1 based
    if (authLabels != null) {
        for (String authLabel : authLabels) {
            int labelOrdinal = this.labelsCache.getLabelOrdinal(authLabel);
            if (labelOrdinal != 0) {
                bs.set(labelOrdinal);
            }
        }
    }

    return new VisibilityExpEvaluator() {
        @Override
        public boolean evaluate(Cell cell) throws IOException {
            boolean visibilityTagPresent = false;
            // Save an object allocation where we can
            if (cell.getTagsLength() > 0) {
                Iterator<Tag> tagsItr = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
                        cell.getTagsLength());
                while (tagsItr.hasNext()) {
                    boolean includeKV = true;
                    Tag tag = tagsItr.next();
                    if (tag.getType() == VISIBILITY_TAG_TYPE) {
                        visibilityTagPresent = true;
                        int offset = tag.getTagOffset();
                        int endOffset = offset + tag.getTagLength();
                        while (offset < endOffset) {
                            Pair<Integer, Integer> result = StreamUtils.readRawVarint32(tag.getBuffer(),
                                    offset);
                            int currLabelOrdinal = result.getFirst();
                            if (currLabelOrdinal < 0) {
                                // check for the absence of this label in the Scan Auth labels
                                // ie. to check BitSet corresponding bit is 0
                                int temp = -currLabelOrdinal;
                                if (bs.get(temp)) {
                                    includeKV = false;
                                    break;
                                }
                            } else {
                                if (!bs.get(currLabelOrdinal)) {
                                    includeKV = false;
                                    break;
                                }
                            }
                            offset += result.getSecond();
                        }
                        if (includeKV) {
                            // We got one visibility expression getting evaluated to true. Good to include this
                            // KV in the result then.
                            return true;
                        }
                    }
                }
            }
            return !(visibilityTagPresent);
        }
    };
}

From source file:org.jahia.services.content.JCRNodeWrapperImpl.java

@Override
public BitSet getPermissionsAsBitSet() {
    BitSet b = null;//  ww w.j ava2 s  .  c om
    try {
        AccessControlManager accessControlManager = getAccessControlManager();
        if (accessControlManager == null) {
            return b;
        }
        Privilege[] app = accessControlManager.getPrivileges(localPathInProvider);
        Privilege[] pr = accessControlManager.getSupportedPrivileges(localPathInProvider);
        b = new BitSet(pr.length);
        if (app.length == pr.length) {
            // in case of admin user all supported permissions are present
            b.set(0, pr.length);
        } else {
            Set<Privilege> effective = new HashSet<Privilege>();
            for (Privilege privilege : app) {
                effective.add(privilege);
                if (privilege.isAggregate()) {
                    for (Privilege p : privilege.getAggregatePrivileges()) {
                        effective.add(p);
                    }
                }
            }
            int position = 0;
            for (Privilege privilege : pr) {
                if (effective.contains(privilege)) {
                    b.set(position);
                }
                position++;
            }
        }
    } catch (RepositoryException e) {
        logger.error("Cannot check perm ", e);
    }
    return b;
}

From source file:org.wso2.andes.subscription.TopicSubscriptionBitMapStore.java

/**
 * {@inheritDoc}/*  w w w. j av a 2 s .c  om*/
 */
@Override
public Set<AndesSubscription> getMatchingSubscriptions(String destination, DestinationType destinationType) {
    Set<AndesSubscription> subscriptions = new HashSet<>();

    if (StringUtils.isNotEmpty(destination)) {

        // constituentDelimiter is quoted to avoid making the delimiter a regex symbol
        String[] constituents = destination.split(Pattern.quote(constituentsDelimiter), -1);

        int noOfCurrentMaxConstituents = constituentTables.size();

        // If given destination has more constituents than any subscriber has, then create constituent tables
        // for those before collecting matching subscribers
        if (constituents.length > noOfCurrentMaxConstituents) {
            for (int i = noOfCurrentMaxConstituents; i < constituents.length; i++) {
                addEmptyConstituentTable();
            }
        }

        // Keeps the results of 'AND' operations between each bit sets
        BitSet andBitSet = new BitSet(subscriptionList.size());

        // Since BitSet is initialized with false for each element we need to flip
        andBitSet.flip(0, subscriptionList.size());

        // Get corresponding bit set for each constituent in the destination and operate bitwise AND operation
        for (int constituentIndex = 0; constituentIndex < constituents.length; constituentIndex++) {
            String constituent = constituents[constituentIndex];
            Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);

            BitSet bitSetForAnd = constituentTable.get(constituent);

            if (null == bitSetForAnd) {
                // The constituent is not found in the table, hence matching with 'other' constituent
                bitSetForAnd = constituentTable.get(OTHER_CONSTITUENT);
            }

            andBitSet.and(bitSetForAnd);
        }

        // If there are more constituent tables, get the null constituent in each of them and operate bitwise AND
        for (int constituentIndex = constituents.length; constituentIndex < constituentTables
                .size(); constituentIndex++) {
            Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);
            andBitSet.and(constituentTable.get(NULL_CONSTITUENT));
        }

        // Valid subscriptions are filtered, need to pick from subscription pool
        int nextSetBitIndex = andBitSet.nextSetBit(0);
        while (nextSetBitIndex > -1) {
            subscriptions.add(subscriptionList.get(nextSetBitIndex));
            nextSetBitIndex = andBitSet.nextSetBit(nextSetBitIndex + 1);
        }

    } else {
        log.warn("Cannot retrieve subscriptions via bitmap handler since destination to match is empty");
    }

    return subscriptions;
}

From source file:org.wso2.andes.subscription.ClusterSubscriptionBitMapHandler.java

/**
 * Get matching subscribers for a given non-wildcard destination.
 *
 * @param destination The destination without wildcard
 * @return Set of matching subscriptions
 *//*from  ww w.j av  a 2 s  . c  o m*/
@Override
public Set<AndesSubscription> getMatchingWildCardSubscriptions(String destination) {
    Set<AndesSubscription> subscriptions = new HashSet<AndesSubscription>();

    if (StringUtils.isNotEmpty(destination)) {

        // constituentDelimiter is quoted to avoid making the delimiter a regex symbol
        String[] constituents = destination.split(Pattern.quote(constituentsDelimiter));

        int noOfCurrentMaxConstituents = constituentTables.size();

        // If given destination has more constituents than any subscriber has, then create constituent tables
        // for those before collecting matching subscribers
        if (constituents.length > noOfCurrentMaxConstituents) {
            for (int i = noOfCurrentMaxConstituents; i < constituents.length; i++) {
                addEmptyConstituentTable();
            }
        }

        // Keeps the results of 'AND' operations between each bit sets
        BitSet andBitSet = new BitSet(wildCardSubscriptionList.size());

        // Since BitSet is initialized with false for each element we need to flip
        andBitSet.flip(0, wildCardSubscriptionList.size());

        // Get corresponding bit set for each constituent in the destination and operate bitwise AND operation
        for (int constituentIndex = 0; constituentIndex < constituents.length; constituentIndex++) {
            String constituent = constituents[constituentIndex];
            Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);

            BitSet bitSetForAnd = constituentTable.get(constituent);

            if (null == bitSetForAnd) {
                // The constituent is not found in the table, hence matching with 'other' constituent
                bitSetForAnd = constituentTable.get(OTHER_CONSTITUENT);
            }

            andBitSet.and(bitSetForAnd);
        }

        // If there are more constituent tables, get the null constituent in each of them and operate bitwise AND
        for (int constituentIndex = constituents.length; constituentIndex < constituentTables
                .size(); constituentIndex++) {
            Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);
            andBitSet.and(constituentTable.get(NULL_CONSTITUENT));
        }

        // Valid subscriptions are filtered, need to pick from subscription pool
        int nextSetBitIndex = andBitSet.nextSetBit(0);
        while (nextSetBitIndex > -1) {
            subscriptions.add(wildCardSubscriptionList.get(nextSetBitIndex));
            nextSetBitIndex = andBitSet.nextSetBit(nextSetBitIndex + 1);
        }

    } else {
        log.warn("Cannot retrieve subscriptions via bitmap handler since destination to match is empty");
    }

    return subscriptions;
}

From source file:org.apache.openjpa.kernel.StateManagerImpl.java

public BitSet getUnloaded(FetchConfiguration fetch) {
    // collect fields to load from data store based on fetch configuration
    BitSet fields = getUnloadedInternal(fetch, LOAD_FGS, null);
    return (fields == null) ? new BitSet(0) : fields;
}

From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java

private void writeFileATimes(final DataOutput header) throws IOException {
    int numAccessDates = 0;
    for (final SevenZArchiveEntry entry : files) {
        if (entry.getHasAccessDate()) {
            ++numAccessDates;/*from  w  ww.ja  v  a 2s.  c om*/
        }
    }
    if (numAccessDates > 0) {
        header.write(NID.kATime);

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final DataOutputStream out = new DataOutputStream(baos);
        if (numAccessDates != files.size()) {
            out.write(0);
            final BitSet aTimes = new BitSet(files.size());
            for (int i = 0; i < files.size(); i++) {
                aTimes.set(i, files.get(i).getHasAccessDate());
            }
            writeBits(out, aTimes, files.size());
        } else {
            out.write(1); // "allAreDefined" == true
        }
        out.write(0);
        for (final SevenZArchiveEntry entry : files) {
            if (entry.getHasAccessDate()) {
                out.writeLong(Long.reverseBytes(SevenZArchiveEntry.javaTimeToNtfsTime(entry.getAccessDate())));
            }
        }
        out.flush();
        final byte[] contents = baos.toByteArray();
        writeUint64(header, contents.length);
        header.write(contents);
    }
}

From source file:org.apache.tez.runtime.library.common.writers.TestUnorderedPartitionedKVWriter.java

private void baseTest(int numRecords, int numPartitions, Set<Integer> skippedPartitions, boolean shouldCompress)
        throws IOException, InterruptedException {
    PartitionerForTest partitioner = new PartitionerForTest();
    ApplicationId appId = ApplicationId.newInstance(10000, 1);
    TezCounters counters = new TezCounters();
    String uniqueId = UUID.randomUUID().toString();
    OutputContext outputContext = createMockOutputContext(counters, appId, uniqueId);

    Configuration conf = createConfiguration(outputContext, IntWritable.class, LongWritable.class,
            shouldCompress, -1);/*from w  w w  .  j  a v  a  2s  . c  o  m*/
    CompressionCodec codec = null;
    if (shouldCompress) {
        codec = new DefaultCodec();
        ((Configurable) codec).setConf(conf);
    }

    int numOutputs = numPartitions;
    long availableMemory = 2048;
    int numRecordsWritten = 0;

    Map<Integer, Multimap<Integer, Long>> expectedValues = new HashMap<Integer, Multimap<Integer, Long>>();
    for (int i = 0; i < numOutputs; i++) {
        expectedValues.put(i, LinkedListMultimap.<Integer, Long>create());
    }

    UnorderedPartitionedKVWriter kvWriter = new UnorderedPartitionedKVWriterForTest(outputContext, conf,
            numOutputs, availableMemory);

    int sizePerBuffer = kvWriter.sizePerBuffer;
    int sizePerRecord = 4 + 8; // IntW + LongW
    int sizePerRecordWithOverhead = sizePerRecord + 12; // Record + META_OVERHEAD

    IntWritable intWritable = new IntWritable();
    LongWritable longWritable = new LongWritable();
    for (int i = 0; i < numRecords; i++) {
        intWritable.set(i);
        longWritable.set(i);
        int partition = partitioner.getPartition(intWritable, longWritable, numOutputs);
        if (skippedPartitions != null && skippedPartitions.contains(partition)) {
            continue;
        }
        expectedValues.get(partition).put(intWritable.get(), longWritable.get());
        kvWriter.write(intWritable, longWritable);
        numRecordsWritten++;
    }
    List<Event> events = kvWriter.close();

    int recordsPerBuffer = sizePerBuffer / sizePerRecordWithOverhead;
    int numExpectedSpills = numRecordsWritten / recordsPerBuffer;

    verify(outputContext, never()).fatalError(any(Throwable.class), any(String.class));

    // Verify the status of the buffers
    if (numExpectedSpills == 0) {
        assertEquals(1, kvWriter.numInitializedBuffers);
    } else {
        assertTrue(kvWriter.numInitializedBuffers > 1);
    }
    assertNull(kvWriter.currentBuffer);
    assertEquals(0, kvWriter.availableBuffers.size());

    // Verify the counters
    TezCounter outputRecordBytesCounter = counters.findCounter(TaskCounter.OUTPUT_BYTES);
    TezCounter outputRecordsCounter = counters.findCounter(TaskCounter.OUTPUT_RECORDS);
    TezCounter outputBytesWithOverheadCounter = counters.findCounter(TaskCounter.OUTPUT_BYTES_WITH_OVERHEAD);
    TezCounter fileOutputBytesCounter = counters.findCounter(TaskCounter.OUTPUT_BYTES_PHYSICAL);
    TezCounter spilledRecordsCounter = counters.findCounter(TaskCounter.SPILLED_RECORDS);
    TezCounter additionalSpillBytesWritternCounter = counters
            .findCounter(TaskCounter.ADDITIONAL_SPILLS_BYTES_WRITTEN);
    TezCounter additionalSpillBytesReadCounter = counters.findCounter(TaskCounter.ADDITIONAL_SPILLS_BYTES_READ);
    TezCounter numAdditionalSpillsCounter = counters.findCounter(TaskCounter.ADDITIONAL_SPILL_COUNT);
    assertEquals(numRecordsWritten * sizePerRecord, outputRecordBytesCounter.getValue());
    assertEquals(numRecordsWritten, outputRecordsCounter.getValue());
    assertEquals(numRecordsWritten * sizePerRecordWithOverhead, outputBytesWithOverheadCounter.getValue());
    long fileOutputBytes = fileOutputBytesCounter.getValue();
    if (numRecordsWritten > 0) {
        assertTrue(fileOutputBytes > 0);
        if (!shouldCompress) {
            assertTrue(fileOutputBytes > outputRecordBytesCounter.getValue());
        }
    } else {
        assertEquals(0, fileOutputBytes);
    }
    assertEquals(recordsPerBuffer * numExpectedSpills, spilledRecordsCounter.getValue());
    long additionalSpillBytesWritten = additionalSpillBytesWritternCounter.getValue();
    long additionalSpillBytesRead = additionalSpillBytesReadCounter.getValue();
    if (numExpectedSpills == 0) {
        assertEquals(0, additionalSpillBytesWritten);
        assertEquals(0, additionalSpillBytesRead);
    } else {
        assertTrue(additionalSpillBytesWritten > 0);
        assertTrue(additionalSpillBytesRead > 0);
        if (!shouldCompress) {
            assertTrue(additionalSpillBytesWritten > (recordsPerBuffer * numExpectedSpills * sizePerRecord));
            assertTrue(additionalSpillBytesRead > (recordsPerBuffer * numExpectedSpills * sizePerRecord));
        }
    }
    assertTrue(additionalSpillBytesWritten == additionalSpillBytesRead);
    assertEquals(numExpectedSpills, numAdditionalSpillsCounter.getValue());

    BitSet emptyPartitionBits = null;
    // Verify the event returned
    assertEquals(1, events.size());
    assertTrue(events.get(0) instanceof CompositeDataMovementEvent);
    CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(0);
    assertEquals(0, cdme.getSourceIndexStart());
    assertEquals(numOutputs, cdme.getCount());
    DataMovementEventPayloadProto eventProto = DataMovementEventPayloadProto
            .parseFrom(ByteString.copyFrom(cdme.getUserPayload()));
    assertFalse(eventProto.hasData());
    if (skippedPartitions == null && numRecordsWritten > 0) {
        assertFalse(eventProto.hasEmptyPartitions());
        emptyPartitionBits = new BitSet(numPartitions);
    } else {
        assertTrue(eventProto.hasEmptyPartitions());
        byte[] emptyPartitions = TezCommonUtils
                .decompressByteStringToByteArray(eventProto.getEmptyPartitions());
        emptyPartitionBits = TezUtilsInternal.fromByteArray(emptyPartitions);
        if (numRecordsWritten == 0) {
            assertEquals(numPartitions, emptyPartitionBits.cardinality());
        } else {
            for (Integer e : skippedPartitions) {
                assertTrue(emptyPartitionBits.get(e));
            }
            assertEquals(skippedPartitions.size(), emptyPartitionBits.cardinality());
        }
    }
    if (emptyPartitionBits.cardinality() != numPartitions) {
        assertEquals(HOST_STRING, eventProto.getHost());
        assertEquals(SHUFFLE_PORT, eventProto.getPort());
        assertEquals(uniqueId, eventProto.getPathComponent());
    } else {
        assertFalse(eventProto.hasHost());
        assertFalse(eventProto.hasPort());
        assertFalse(eventProto.hasPathComponent());
    }

    // Verify the actual data
    TezTaskOutput taskOutput = new TezTaskOutputFiles(conf, uniqueId);
    Path outputFilePath = null;
    Path spillFilePath = null;
    try {
        outputFilePath = taskOutput.getOutputFile();
    } catch (DiskErrorException e) {
        if (numRecordsWritten > 0) {
            fail();
        } else {
            // Record checking not required.
            return;
        }
    }
    try {
        spillFilePath = taskOutput.getOutputIndexFile();
    } catch (DiskErrorException e) {
        if (numRecordsWritten > 0) {
            fail();
        } else {
            // Record checking not required.
            return;
        }
    }

    // Special case for 0 records.
    TezSpillRecord spillRecord = new TezSpillRecord(spillFilePath, conf);
    DataInputBuffer keyBuffer = new DataInputBuffer();
    DataInputBuffer valBuffer = new DataInputBuffer();
    IntWritable keyDeser = new IntWritable();
    LongWritable valDeser = new LongWritable();
    for (int i = 0; i < numOutputs; i++) {
        if (skippedPartitions != null && skippedPartitions.contains(i)) {
            continue;
        }
        TezIndexRecord indexRecord = spillRecord.getIndex(i);
        FSDataInputStream inStream = FileSystem.getLocal(conf).open(outputFilePath);
        inStream.seek(indexRecord.getStartOffset());
        IFile.Reader reader = new IFile.Reader(inStream, indexRecord.getPartLength(), codec, null, null, false,
                0, -1);
        while (reader.nextRawKey(keyBuffer)) {
            reader.nextRawValue(valBuffer);
            keyDeser.readFields(keyBuffer);
            valDeser.readFields(valBuffer);
            int partition = partitioner.getPartition(keyDeser, valDeser, numOutputs);
            assertTrue(expectedValues.get(partition).remove(keyDeser.get(), valDeser.get()));
        }
        inStream.close();
    }
    for (int i = 0; i < numOutputs; i++) {
        assertEquals(0, expectedValues.get(i).size());
        expectedValues.remove(i);
    }
    assertEquals(0, expectedValues.size());
}

From source file:org.apache.flink.streaming.connectors.kafka.KafkaITCase.java

@Test
public void regularKafkaSourceTest() throws Exception {
    LOG.info("Starting KafkaITCase.regularKafkaSourceTest()");

    String topic = "regularKafkaSourceTestTopic";
    createTestTopic(topic, 1, 1);//from  w w  w.j  a  v  a  2s. c om

    final StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(1);
    // add consuming topology:
    DataStreamSource<Tuple2<Long, String>> consuming = env
            .addSource(new KafkaSource<Tuple2<Long, String>>(zookeeperConnectionString, topic, "myFlinkGroup",
                    new Utils.TypeInformationSerializationSchema<Tuple2<Long, String>>(
                            new Tuple2<Long, String>(1L, ""), env.getConfig()),
                    5000));
    consuming.addSink(new SinkFunction<Tuple2<Long, String>>() {
        private static final long serialVersionUID = 1L;

        int elCnt = 0;
        int start = -1;
        BitSet validator = new BitSet(101);

        @Override
        public void invoke(Tuple2<Long, String> value) throws Exception {
            LOG.debug("Got value = " + value);
            String[] sp = value.f1.split("-");
            int v = Integer.parseInt(sp[1]);

            assertEquals(value.f0 - 1000, (long) v);

            if (start == -1) {
                start = v;
            }
            Assert.assertFalse("Received tuple twice", validator.get(v - start));
            validator.set(v - start);
            elCnt++;
            if (elCnt == 100) {
                // check if everything in the bitset is set to true
                int nc;
                if ((nc = validator.nextClearBit(0)) != 100) {
                    throw new RuntimeException("The bitset was not set to 1 on all elements. Next clear:" + nc
                            + " Set: " + validator);
                }
                throw new SuccessException();
            }
        }
    });

    // add producing topology
    DataStream<Tuple2<Long, String>> stream = env.addSource(new SourceFunction<Tuple2<Long, String>>() {
        private static final long serialVersionUID = 1L;
        boolean running = true;

        @Override
        public void run(SourceContext<Tuple2<Long, String>> ctx) throws Exception {
            LOG.info("Starting source.");
            int cnt = 0;
            while (running) {
                ctx.collect(new Tuple2<Long, String>(1000L + cnt, "kafka-" + cnt++));
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ignored) {
                }
            }
        }

        @Override
        public void cancel() {
            LOG.info("Source got cancel()");
            running = false;
        }
    });
    stream.addSink(new KafkaSink<Tuple2<Long, String>>(brokerConnectionStrings, topic,
            new Utils.TypeInformationSerializationSchema<Tuple2<Long, String>>(new Tuple2<Long, String>(1L, ""),
                    env.getConfig())));

    tryExecute(env, "regular kafka source test");

    LOG.info("Finished KafkaITCase.regularKafkaSourceTest()");
}

From source file:gov.nasa.jpf.constraints.solvers.cw.CWSolver.java

static void populateLookupTables(RealVectorSpace space, List<Expression<Boolean>> constraints,
        List<Expression<Boolean>>[] constraintsByVariableIndex,
        Map<Expression<Boolean>, BitSet> variableIndicesByConstraint) {
    int numberOfVariables = space.dimensions().size();
    for (Expression<Boolean> constraint : constraints) {
        BitSet variableIndices = new BitSet(numberOfVariables);
        variableIndicesByConstraint.put(constraint, variableIndices);
        for (Variable<?> variable : ExpressionUtil.freeVariables(constraint)) {
            int varIndex = space.indexOf(variable);
            variableIndices.set(varIndex);
            if (constraintsByVariableIndex[varIndex] == null) {
                constraintsByVariableIndex[varIndex] = new ArrayList<>();
            }/*w  w  w  . ja va2  s  .  com*/
            constraintsByVariableIndex[varIndex].add(constraint);
        }
    }
}

From source file:org.apache.openjpa.kernel.StateManagerImpl.java

/**
 * Internal version of {@link OpenJPAStateManager#getUnloaded} that avoids
 * creating an empty bit set by returning null when there are no unloaded
 * fields./*from  ww  w. j  av a  2 s . c om*/
 */
private BitSet getUnloadedInternal(FetchConfiguration fetch, int mode, BitSet exclude) {
    if (exclude == StoreContext.EXCLUDE_ALL)
        return null;

    BitSet fields = null;
    FieldMetaData[] fmds = _meta.getFields();
    boolean load;
    for (int i = 0; i < fmds.length; i++) {
        if (_loaded.get(i) || (exclude != null && exclude.get(i)))
            continue;

        switch (mode) {
        case LOAD_SERIALIZE:
            load = !fmds[i].isTransient();
            break;
        case LOAD_FGS:
            load = fetch == null || fetch.requiresFetch(fmds[i]) != FetchConfiguration.FETCH_NONE;
            break;
        default: // LOAD_ALL
            load = true;
        }

        if (load) {
            if (fields == null)
                fields = new BitSet(fmds.length);
            fields.set(i);
        }
    }
    return fields;
}