示例#1
0
void SchemaDumper::dumpTable (QStringList &output, const QString &name)
{
	// Don't dump the migrations table
	if (name==Migrator::migrationsTableName) return;

	output << qnotr ("- name: \"%1\"").arg (name);
	dumpColumns (output, name);
	dumpIndexes (output, name);
}
示例#2
0
static IfsBoolean dumpIndexFile(char *index_filename, unsigned format)
{
    IfsClock duration = 0;
    time_t seconds = 0;
    IfsIndexEntry firstEntry, lastEntry;
    NumEntries numEntries = 0;
	IfsHandle ifsHandle = NULL;

    void (*countIndexes)(ullong ifsIndex) = NULL;
	char* (*parseWhat)(IfsHandle ifsHandle, char * temp,
						const IfsIndexDumpMode ifsIndexDumpMode, const IfsBoolean) = NULL;
    void (*dumpIndexes)(void) = NULL;

    if(!index_filename)
    {
    	printf("Index file name pointer is null\n");
    	return IfsFalse;
    }

    ifsHandle = g_try_malloc0(sizeof(IfsHandleImpl));
    if (ifsHandle == NULL)
    {
        printf("Could not allocate memory\n");
        return IfsFalse;
    }

    switch(format)
    {
    	case 4:	// H.264
			IfsSetCodec(ifsHandle, IfsCodecTypeH264);
			break;
    	case 2:
    	default:
    		IfsSetCodec(ifsHandle, IfsCodecTypeH262);
    		break;
    }
    printf("Opening index file: %s\n", index_filename);
	ifsHandle->pNdex = fopen(index_filename, "rb");
	if (ifsHandle->pNdex)
	{
		if (fread(&ifsHandle->entry, 1, sizeof(IfsIndexEntry),
				ifsHandle->pNdex) == sizeof(IfsIndexEntry))
		;
	}
	else
	{
		printf("Error opening/reading the index file: %s\n", index_filename);
		if(ifsHandle)
			g_free(ifsHandle);
		return IfsFalse;
	}

	switch (ifsHandle->codecType)
	{
		case IfsCodecTypeH261:
		case IfsCodecTypeH262:
		case IfsCodecTypeH263:
			IfsSetMode(IfsIndexDumpModeAll, IfsH262IndexerSettingVerbose);
			parseWhat = ifsHandle->codec->h262->ParseWhat;
            countIndexes = ifsHandle->codec->h262->CountIndexes;
            dumpIndexes = ifsHandle->codec->h262->DumpIndexes;
			break;
		case IfsCodecTypeH264:
			IfsSetMode(IfsIndexDumpModeDef, IfsH264IndexerSettingVerbose);
			parseWhat = ifsHandle->codec->h264->ParseWhat;
            countIndexes = ifsHandle->codec->h264->CountIndexes;
            dumpIndexes = ifsHandle->codec->h264->DumpIndexes;
			break;
		case IfsCodecTypeH265:
			IfsSetMode(IfsIndexDumpModeDef, IfsH265IndexerSettingVerbose);
			parseWhat = ifsHandle->codec->h265->ParseWhat;
            countIndexes = ifsHandle->codec->h265->CountIndexes;
            dumpIndexes = ifsHandle->codec->h265->DumpIndexes;
			break;
		default:
			printf("IfsReturnCodeBadInputParameter: ifsHandle->codec not set\n");
			break;
	}

    firstEntry = ifsHandle->entry;

    if (ifsHandle->ndex)
        printf("\n%s:\n\n", ifsHandle->ndex);

	printf("Packet(where)  Index Information (what happened at that time and location)\n");
	printf(	"-------------  -----------------------------------------------------------\n");
	do
	{
		char temp1[32]; // IfsToSecs only
		char temp[256]; // ParseWhat

		countIndexes(ifsHandle->entry.what);

		printf("%6ld %s  %s\n", ifsHandle->entry.realWhere,
			 IfsToSecs(ifsHandle->entry.when, temp1),
			 parseWhat(ifsHandle, temp, IfsIndexDumpModeDef,
			 IfsTrue));
		numEntries++;
	} while (fread(&ifsHandle->entry, 1, sizeof(IfsIndexEntry),
			ifsHandle->pNdex) == sizeof(IfsIndexEntry));

    lastEntry = ifsHandle->entry;
    duration = lastEntry.when - firstEntry.when;

    printf("\n");

    dumpIndexes();
    printf("\n");
    char temp[32]; // IfsToSecs only
    seconds = firstEntry.when / NSEC_PER_SEC;
    printf("Date/Time Start   %s %s", IfsToSecs(firstEntry.when, temp),
            asctime(gmtime(&seconds)));
    seconds = lastEntry.when / NSEC_PER_SEC;
    printf("Date/Time Ended   %s %s", IfsToSecs(lastEntry.when, temp),
            asctime(gmtime(&seconds)));
    printf("Recording Lasted  %s seconds\n", IfsToSecs(duration, temp));
    printf("First packet indexed %7ld/%7ld\n", firstEntry.realWhere,
            firstEntry.virtWhere);
    printf("Last packet indexed  %7ld/%7ld\n", lastEntry.realWhere,
            lastEntry.virtWhere);
    printf("Number of entries %10ld\n", numEntries);
    printf("Rate of indexing  %20.9f entries/second\n", (numEntries * 1.0)
            / ((duration * 1.0) / (NSEC_PER_SEC * 1.0)));
    printf("                  %20.9f packets/entry\n",
            ((lastEntry.virtWhere - firstEntry.virtWhere) * 1.0)
                    / (numEntries * 1.0));
    return IfsTrue;
}